-
Hello
Hogy lehet megcsinálni:
/gotooff(evvel lehet tiltani a játékoshoz a teleportálást)
/goton(evvel meg engedélyezni)
és egy /goto parancs
elõre is kösz
-
1. /goto [ON/OFF]
Ezt váltózóval.
2. Admin szkriptekbe van. :D
-
kösz az ötletet...
Már csak kivitelezem és kész :dodge:
-
Ha akarod összeállítom neked gyorsan:)
-
Hello!
Én sscanf-al megtudtam oldani, tökéletesen mûködik így is, de ez csak egy sima /goto parancs:
#include <a_samp>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == \'\\0\') && (dcmd_%1(playerid, \"\"))) || (((%3)[(%2) + 1] == \' \') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(goto, 4, cmdtext);
return 0;
}
dcmd_goto(playerid, params[])
{
new giveplayerid;
if (sscanf(params, \"u\", giveplayerid)) SendClientMessage(playerid, 0xa61515FF, \"Használat: /goto [playerid]\");
else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xa61515FF, \"Hiba: Nincs ilyen játékos!\");
else{
new name1[MAX_PLAYER_NAME],string[200];
GetPlayerName(playerid, name1, sizeof(name1));
new name2[MAX_PLAYER_NAME];
GetPlayerName(giveplayerid, name2, sizeof(name2));
format(string, sizeof string, \"%s odeteleportált %s nevû játékoshoz!\", name1, name2);
SendClientMessageToAll(0xB3D5B2AA,string);
new Float:x, Float:y, Float:z;
GetPlayerPos(giveplayerid, x, y, z);
SetPlayerPos(playerid,x,y,z);
}
return 1;
}
stock sscanf(string[], format[], {Float,_}:...)
{
#if defined isnull
if (isnull(string))
#else
if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
#endif
{
return format[0];
}
#pragma tabsize 4
new
formatPos = 0,
stringPos = 0,
paramPos = 2,
paramCount = numargs(),
delim = \' \';
while (string[stringPos] && string[stringPos] <= \' \')
{
stringPos++;
}
while (paramPos < paramCount && string[stringPos])
{
switch (format[formatPos++])
{
case \'\\0\':
{
return 0;
}
case \'i\', \'d\':
{
new
neg = 1,
num = 0,
ch = string[stringPos];
if (ch == \'-\')
{
neg = -1;
ch = string[++stringPos];
}
do
{
stringPos++;
if (\'0\' <= ch <= \'9\')
{
num = (num * 10) + (ch - \'0\');
}
else
{
return -1;
}
}
while ((ch = string[stringPos]) > \' \' && ch != delim);
setarg(paramPos, 0, num * neg);
}
case \'h\', \'x\':
{
new
num = 0,
ch = string[stringPos];
do
{
stringPos++;
switch (ch)
{
case \'x\', \'X\':
{
num = 0;
continue;
}
case \'0\' .. \'9\':
{
num = (num << 4) | (ch - \'0\');
}
case \'a\' .. \'f\':
{
num = (num << 4) | (ch - (\'a\' - 10));
}
case \'A\' .. \'F\':
{
num = (num << 4) | (ch - (\'A\' - 10));
}
default:
{
return -1;
}
}
}
while ((ch = string[stringPos]) > \' \' && ch != delim);
setarg(paramPos, 0, num);
}
case \'c\':
{
setarg(paramPos, 0, string[stringPos++]);
}
case \'f\':
{
new changestr[16], changepos = 0, strpos = stringPos;
while(changepos < 16 && string[strpos] && string[strpos] != delim)
{
changestr[changepos++] = string[strpos++];
}
changestr[changepos] = \'\\0\';
setarg(paramPos,0,_:floatstr(changestr));
}
case \'p\':
{
delim = format[formatPos++];
continue;
}
case \'\\\'\':
{
new
end = formatPos - 1,
ch;
while ((ch = format[++end]) && ch != \'\\\'\') {}
if (!ch)
{
return -1;
}
format[end] = \'\\0\';
if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
{
if (format[end + 1])
{
return -1;
}
return 0;
}
format[end] = \'\\\'\';
stringPos = ch + (end - formatPos);
formatPos = end + 1;
}
case \'u\':
{
new
end = stringPos - 1,
id = 0,
bool:num = true,
ch;
while ((ch = string[++end]) && ch != delim)
{
if (num)
{
if (\'0\' <= ch <= \'9\')
{
id = (id * 10) + (ch - \'0\');
}
else
{
num = false;
}
}
}
if (num && IsPlayerConnected(id))
{
setarg(paramPos, 0, id);
}
else
{
#if !defined foreach
#define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
#define __SSCANF_FOREACH__
#endif
string[end] = \'\\0\';
num = false;
new
name[MAX_PLAYER_NAME];
id = end - stringPos;
foreach (Player, playerid)
{
GetPlayerName(playerid, name, sizeof (name));
if (!strcmp(name, string[stringPos], true, id))
{
setarg(paramPos, 0, playerid);
num = true;
break;
}
}
if (!num)
{
setarg(paramPos, 0, INVALID_PLAYER_ID);
}
string[end] = ch;
#if defined __SSCANF_FOREACH__
#undef foreach
#undef __SSCANF_FOREACH__
#endif
}
stringPos = end;
}
case \'s\', \'z\':
{
new
i = 0,
ch;
if (format[formatPos])
{
while ((ch = string[stringPos++]) && ch != delim)
{
setarg(paramPos, i++, ch);
}
if (!i)
{
return -1;
}
}
else
{
while ((ch = string[stringPos++]))
{
setarg(paramPos, i++, ch);
}
}
stringPos--;
setarg(paramPos, i, \'\\0\');
}
default:
{
continue;
}
}
while (string[stringPos] && string[stringPos] != delim && string[stringPos] > \' \')
{
stringPos++;
}
while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= \' \'))
{
stringPos++;
}
paramPos++;
}
do
{
if ((delim = format[formatPos++]) > \' \')
{
if (delim == \'\\\'\')
{
while ((delim = format[formatPos++]) && delim != \'\\\'\') {}
}
else if (delim != \'z\')
{
return delim;
}
}
}
while (delim > \' \');
return 0;
}
-
Háát, nem vagyok elragadtatva Stricica. :-\\
Tessék,
CMD:goto ( playerid, params [ ] )
{
new gID, string [ 128 ];
new Float:X, Float:Y, Float:Z;
if ( sscanf ( params, \"u\", gID ) ) return SendClientMessage(playerid, COLOR_RED, \"Használat: /goto [Játékos ID/Név]\");
else if ( !IsPlayerConnected ( gID ) && gID == INVALID_PLAYER_ID && GetPVarInt ( gID, \"pGoto\") == 0 ) return SendClientMessage(playerid, COLOR_RED, \"Hiba: A játékos nem elérhetõ, magadat választottad.\");
GetPlayerPos ( gID, X, Y, Z );
SetPlayerInterior ( playerid, GetPlayerInterior ( gID ) );
SetPlayerVirtualWorld ( playerid, GetPlayerVirtualWorld ( gID ) );
if ( GetPlayerState ( playerid ) != 2 ) return SetPlayerPos ( playerid, X+2, Y, Z );
{
SetVehiclePos ( GetPlayerVehicleID ( playerid ), X+3, Y, Z );
LinkVehicleToInterior ( GetPlayerVehicleID ( playerid ), GetPlayerInterior ( gID ) );
SetVehicleVirtualWorld ( GetPlayerVehicleID ( playerid ), GetPlayerVirtualWorld ( gID ) );
format ( string, 128,\"%s odateleportált hozzád!\", PlayerName ( playerid ) ); SendClientMessage ( gID, 0x000000FF, string );
format ( string, 128,\"Oda teleportáltál: %s-hez(hoz)!\", PlayerName ( gID ) ); SendClientMessage ( playerid, 0x000000FF, string );
}
return 1;
}
CMD:setgoto ( playerid, params [ ] )
{
if ( GetPVarInt ( playerid, \"pGoto\" ) == 0 ) {
SetPVarInt ( playerid, \"pGoto\", 1 );
SendClientMessage ( playerid, 0x000000FF, \"Engedélyezted, hogy hozzád teleportálhassanak!\" );
} else {
SetPVarInt ( playerid, \"pGoto\", 0 );
SendClientMessage ( playerid, 0x000000FF, \"Letiltottad, hogy hozzád teleportálhassanak!\" );
}
return 1;
}
stock PlayerName ( playerid )
{
new pname [ MAX_PLAYER_NAME ];
GetPlayerName ( playerid, pname, MAX_PLAYER_NAME );
return pname;
}
Szerk.: Epsilon kedvéért, átírtam Player Variablesre. :angel:
-
Hát bocs, tõlem ennyire futotta :D (még kezdõ vagyok.. ::| )
-
Sikerült megoldani? Mûködik? Ha igen, zárd a témát.
-
Epsilon szervere :-\\
Amúgy, nem véletlenül került elkészítése a PVar függvénycsoport. Használni kéne...
Ugyanis így a játékos mindenkinek, aki késõbb az õ azonosítószámát használja beállítja.
-
#include <a_samp>
#include <zcmd>
#include <sscanf>
#include <colors>
#define FILTERSCRIPT
public OnFilterScriptInit()
{
print(\"\\n--------------------------------------\");
print(\" Goto\");
print(\"--------------------------------------\\n\");
return 1;
}
CMD:goto(playerid,params[])
{
new celid, string[128], Float:hely[3], nev[MAX_PLAYER_NAME][2];
if(sscanf(params, \"u\", celid)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, \"HASZNÁLAT: /goto (játékosid/név)\");
else if(!IsPlayerConnected(celid) && celid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, \"HIBA: Nincs ilyen játékos a szerveren, vagy az adott játékos te vagy!\");
GetPlayerPos(celid, hely[0], hely[1], hely[2]); SetPlayerInterior(playerid, GetPlayerInterior(celid));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(celid));
if(GetPVarInt(celid, \"goto\") == 1)
{
if(GetPlayerState(playerid) == 2)
{
SetVehiclePos(GetPlayerVehicleID(playerid),hely[0]+2, hely[1], hely[2]); LinkVehicleToInterior(GetPlayerVehicleID(playerid), GetPlayerInterior(celid));
SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), GetPlayerVirtualWorld(celid)); GetPlayerName(playerid, nev[0], sizeof(nev)); GetPlayerName(celid, nev[1], sizeof(nev));
format(string,sizeof(string),\"%s elteleportált hozzád!\", nev[0]); SendClientMessage(celid, COLOR_LIGHTBLUE, string);
format(string,sizeof(string),\"Elteleportáltál %s-hez(hoz)!\", nev[1]); SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}else{
SetPlayerPos(playerid, hely[0], hely[1], hely[2]); SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(celid)); SetPlayerInterior(playerid, GetPlayerInterior(celid));
}
}else{
format(string,sizeof(string),\"%s letiltotta a gotozást!\", nev[1]);
SendClientMessage(playerid, COLOR_RED, string);
}
return 1;
}
CMD:setgoto(playerid, params[])
{
if(GetPVarInt(playerid, \"goto\") == 0) {
SetPVarInt(playerid, \"goto\", 1);
SendClientMessage(playerid, COLOR_LIGHTBLUE, \"Engedélyezted a gotozást magadhoz!\");
}else{
SetPVarInt(playerid, \"goto\", 0);
SendClientMessage(playerid, COLOR_LIGHTBLUE, \"Letiltottad a gotozást magadhoz!\");
}
return 1;
}
-
CMD:setgoto(playerid, params[])
{
if(GetPVarInt(playerid, \"goto\") == 0) {
SetPVarInt(playerid, \"goto\", 1);
SendClientMessage(playerid, COLOR_LIGHTBLUE, \"Engedélyezted a gotozást magadhoz!\");
}else{
SetPVarInt(playerid, \"goto\", 1);
SendClientMessage(playerid, COLOR_LIGHTBLUE, \"Letiltottad a gotozást magadhoz!\");
}
return 1;
}
Engedélyezésnél és létiltásnál is 1 a \'goto\' kérték, ezért minden esetbe fog tudni teleportálni.
-
kösz mindenkinek
OFF: Hogy lehet kijelölni normálisan mert egy más után másolja és így 26 error
-
OFF: Hogy lehet kijelölni normálisan mert egy más után másolja és így 26 error
Ha az enyémet másolnád, azt csak bekel illesztened a módba és kész is. ( Nem lesz hiba! )
-
Igen de nem lehet normálisan kimásolni..
Egymás mellé másolja
-
Ha jól is másolnád be, nem csoda, hogy hibaüzeneteket kapsz.
A szerkesztett kód hibás.
-
A szerkesztett kód hibás.
Javítva!
Mikor megírtam, akkor értem haza a buliból és bekapcsolva volt a gép és akkor írtam ide.
Nem teszteltem és nem a gép elõtt töltöttem a szilvesztert ellentétbe egyesekkel. ::|
Ezért volt benne 1-2 hiba.