How to check did we enter our id ? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to check did we enter our id ? (
/showthread.php?tid=505024)
How to check did we enter our id ? -
Djumza - 06.04.2014
Hello, here is my /goto command :
pawn Код:
CMD:goto(playerid,params[])
{
new id,Float:x,Float:y,Float:z,name[MAX_PLAYER_NAME],msg[128];
if(PlayerInfo[playerid][pAdmin] == 5) return SendClientMessage(playerid,COLOR_RED,"[SERVER]:You must be and Admin level 6 or higher to use this command!");
else if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid,COLOR_RED,"[SERVER]:You must be and Admin to use this command!");
else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"[SERVER]:Player is not connected anymore!");
else if(id == playerid) return SendClientMessage(playerid,COLOR_RED,"[SERVER]:You cant teleport to yourself!");
else if(sscanf(params,"u",id)) return SendClientMessage(playerid,COLOR_RED,"[SERVER]:Usage:/goto [name/id]");
else
{
GetPlayerPos(id,x,y,z);
SetPlayerPos(playerid,x+1,y+1,z);
GetPlayerName(id,name,sizeof(name));
format(msg,sizeof(msg),"[SERVER]:You've been teleported to %s(%d)!",name,id);
SendClientMessage(playerid,COLOR_GREEN,msg);
}
return 1;
}
But this dont work well.. sometimes it work for me,sometimes it just send me "[SERVER]:You cant teleport to yourself!" .. so i guess something isnt well with :
I tested this ten times with my friend, he sometimes can goto me,but also sometimes he just get that Error msg..
Any ideas how to fix this ?
Re: How to check did we enter our id ? -
Corekt - 06.04.2014
All those checks are being used before sscanf assigns a value to id, so really you're just comparing with the value 0. Place the sscanf function at the top right after declaring your variables, then do your checks afterwards.
Re: How to check did we enter our id ? -
Djumza - 06.04.2014
Thanks, dat have sense , ill test that as soon as i can
EDIT: Thank you a lot, its fixed