Delay after writing a command
#7

Do something like this:

pawn Код:
new CountDown[MAX_PLAYERS];
new PlayerTimer[MAX_PLAYERS];
new CanUseMissle[MAX_PLAYERS];
CanUseMissle[MAX_PLAYERS] = 0;
CountDown[playerid] = 5;
PlayerTimer[playerid] = SetTimerEx("ExecuteCommand", 1000, true, "i", playerid);
forward ExecuteCommand(playerid);

public ExecuteCommand(playerid)
{
    CountDown[playerid] --;
    if(CountDown[playerid] == 0)
    {
        KillTimer(PlayerTimer[playerid]);
        CanUseMissle[playerid] = 1;
        return 1;
    }
    else
        new str[20];
        format(str, sizeof str, "%i second(s) left", CountDown[playerid]);
        GameTextForPlayer(playerid, str, 1000, 3);
    }
    return 1;
}
CMD:fire(playerid, params[])
{
    SetTimerEx("ExecuteCommand", 1000, true, "i", playerid);
    SendClientMessage(playerid, -1, "You have started to arm the missle.");
    return 1;
}
CMD:missle(playerid, params[])
{
    if(CanUseMissle[playerid] == 0)
    {
        SendClientMessage(playerid, -1, "You need to use the command /fire first.");
    }
    else if(CanUseMissle[playerid] == 1)
    {
        // Your missle command stuff
        SendClientMessage(playerid, -1, "You have fired a missle!");
        CanUseMissle[playerid] = 0;
    }
    return 1;
}
You have to edit certain things, but that's a basic example.
Reply


Messages In This Thread
Delay after writing a command - by BoomShnizel - 05.11.2012, 14:28
Re: Delay after writing a command - by sampreader - 05.11.2012, 14:30
Re: Delay after writing a command - by BoomShnizel - 05.11.2012, 14:35
Re: Delay after writing a command - by [KHK]Khalid - 05.11.2012, 15:07
Re: Delay after writing a command - by BoomShnizel - 05.11.2012, 16:16
Re: Delay after writing a command - by BoomShnizel - 05.11.2012, 17:16
Re: Delay after writing a command - by Abreezy - 05.11.2012, 18:22
Re: Delay after writing a command - by cosbraa - 05.11.2012, 20:22
Re: Delay after writing a command - by BoomShnizel - 06.11.2012, 03:37

Forum Jump:


Users browsing this thread: 4 Guest(s)