How to check did we enter our id ?
#1

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 :
pawn Код:
else if(id == playerid)
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 ?
Reply
#2

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.
Reply
#3

Thanks, dat have sense , ill test that as soon as i can
EDIT: Thank you a lot, its fixed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)