One time command.
#6

Quote:
Originally Posted by BlackRaven
Посмотреть сообщение
pawn Код:
command(once, playerid, params[])
{
    new pressed = false;
    if(pressed == false)
    {
        pressed = true;
        // do your code now!
    }
    return 1;
}
That condition will ALWAYS be true, you need to set a GLOBAL variable instead

pawn Код:
new
    typedCommand[MAX_PLAYERS];

CMD:once(playerid, params[])
{
    if(!typedCommand[playerid])
    {
        typedCommand[playerid] = 1;
        // Whatever you want the command to do
    }
    else
    {
        // Error message saying that they already used it
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    typedCommand[playerid] = 0; // Here we reset the variable so other players who join with same ID can use the command later
    return 1;
}

// You can also save the variable in player's file
EDIT: Too late
Reply


Messages In This Thread
One time command. - by dorperez - 01.02.2013, 16:05
Re: One time command. - by BlackRaven - 01.02.2013, 16:08
Re: One time command. - by dorperez - 01.02.2013, 16:09
Re: One time command. - by BlackRaven - 01.02.2013, 16:17
Re: One time command. - by LarzI - 01.02.2013, 16:29
Respuesta: Re: One time command. - by OPremium - 01.02.2013, 16:30
Re: One time command. - by dorperez - 01.02.2013, 16:32

Forum Jump:


Users browsing this thread: 1 Guest(s)