SA-MP Forums Archive
Teleport command problem - 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: Teleport command problem (/showthread.php?tid=303317)



Teleport command problem - printer - 12.12.2011

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.


Re: Teleport command problem - [HiC]TheKiller - 12.12.2011

Add

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


Re: Teleport command problem - KingHual - 12.12.2011

Use 'IsPlayerConnected(playerid)'