Player not connected-Invalid Player id and You can't goto to yourself. "Goto command"
#1

Hi, I've created this goto command, just
what string I have to put to show a player this 3 "warning or error" in to the game?
Player not connected
Invalid player id or You can't goto to your self
Here's the code:
Код:
if(strcmp(cmd, "/goto", true) == 0)
    {
    new str[256];
    tmp = strtok2(cmdtext, idx);
    if(!strlen(tmp))
    {
    SendClientMessage(playerid, 0xbbff0000 , "/goto [playerid]");
    return 1;
    }
    new tmpplayer = ReturnUser(tmp);
    new Float:tmpx, Float:tmpy, Float:tmpz;
    new name[MAX_PLAYER_NAME];
    GetPlayerName(tmpplayer, name, sizeof(name));
    GetPlayerPos(tmpplayer, tmpx, tmpy, tmpz);
    SetPlayerPos(playerid, tmpx, tmpy, tmpz+1);
    format(str, sizeof(str), "You have teleported to %s(ID:%d)", name, tmpplayer);
    SendClientMessage(playerid, 0x00bbbb00 , str);
    return 1;
    }
Thanks for the help!
Reply
#2

pawn Код:
if(!IsPlayerConnected(tmpplayer)) return SendClientMessage(playerid, 0xFFFFFFF, "Player not connected!"); //checks if the input of /goto is a connected player
    if(tmpplayer == playerid) return SendClientMessage(playerid, 0xFFFFFFF, "You cannot /goto yourself!"); //checks if the ID u put is the same as the playerid's
    if(tmpplayer == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFFFFFFF, "Invalid ID!");//checks if its an invalid ID
BTW, why put INVALID_PLAYER_ID and not just IsPlayerConnected? Just giving my opinion.
Here you go anyway
Reply
#3

If the player is not connected, then it's INVALID_PLAYER_ID. So, double checking is pointless.
Reply
#4

True that ^
Anyway I just posted what he requested, he'll be the one to double think about putting INVALID_PLAYER_ID, or not to put that
Reply
#5

It work... thanks JimmyCh
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)