[HELP] Goto Command
#4

Fixed

pawn Код:
CMD:go(playerid, params[])
{
    new ID;//creates a new something idk what we call it :P but it is defined later on or used in something this 1 is used in next line
    if(sscanf(params, "u", ID)) SendClientMessage(playerid, 0xFF0000FF, "USAGE: /goto [id]");//checks if you have written something after /goto if no it sends error
    else if(!IsPlayerConnected(ID) || ID == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself"); <--------------This is the error line.
    else//ELSE what will happen if no errors
    {
        new Float:x, Float:y, Float:z;//creates new floats
        GetPlayerPos(ID, x, y, z);//gets the player id(which we have entered after /goto position and like saves them into x,y,z defined above as floats
        SetPlayerPos(playerid, x+1, y+1, z);//sets the player position the id of that player +1 in x +1 in y and z remains same as it defines height
    }
    return 1;
}
Variables are case-sensitive, the error was because it was lowercased.

Make a global variable or a Boolean, and then set it to true or 1 when the player connects. Then, when they do /goff, set it to 0. Then, on the command, check if the Boolean or global variable is value 0 for the playerid, and if it is, you can't teleport to them.

EDIT: TIP: Use [.pawn] and [./pawn] tags instead of the current ones you are using in the future (without the period, of course).
Reply


Messages In This Thread
[HELP] Goto Command - by kbalor - 27.06.2012, 06:44
Re: [HELP] Goto Command - by [A]ndrei - 27.06.2012, 06:46
Re: [HELP] Goto Command - by kbalor - 27.06.2012, 06:47
Re: [HELP] Goto Command - by Kindred - 27.06.2012, 06:50
Re: [HELP] Goto Command - by kbalor - 27.06.2012, 06:58
Re: [HELP] Goto Command - by Kindred - 27.06.2012, 07:06
Re: [HELP] Goto Command - by kbalor - 27.06.2012, 07:18
Re: [HELP] Goto Command - by Kindred - 27.06.2012, 07:23
Re: [HELP] Goto Command - by kbalor - 27.06.2012, 07:31
Re: [HELP] Goto Command - by Skaizo - 27.06.2012, 08:20

Forum Jump:


Users browsing this thread: 2 Guest(s)