Teleport command problem
#1

pawn Код:
if(strcmp(cmd,"/goto",true) == 0)
    {
        new tmp[256],string[128];
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_LIGHTRED,"USAGE: /goto [playerid]");
        if(dini_Int(file(playerid),"Admin") > 0)
        {
            if(strval(tmp) == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_LIGHTRED,"Invalid playerid.");
            format(string,sizeof(string),"Admin: %s has teleported to %s",GetName(playerid,false),GetName(strval(tmp),false));
            SendClientMessageToAll(COLOR_LIGHTRED,string);
            new Float:x,Float:y,Float:z;
            GetPlayerPos(strval(tmp),x,y,z);
            SetPlayerPos(playerid,x+1,y,z+1);
        }
        else
        {
            SendClientMessage(playerid,COLOR_LIGHTRED,"You are not an admin.");
        }
        return 1;
    }
It teleports even if playerid doesn't exist.
Reply
#2

Add

pawn Код:
if(!IsPlayerConnected( strval(tmp) ) ) return SendClientMessage(playerid, COLOR_LIGHTRED, "Player is not online");
To somewhere in that code.
Reply
#3

Use 'IsPlayerConnected(playerid)'
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)