Quote:
Originally Posted by HellSphinX
It's easy. Read the comments carefully and if something needs more explanation, feel free to ask:
pawn Код:
// To get this to work, you gotta declare a per-player global variable to use it for counting down new CountDown[MAX_PLAYERS]; // You will also need a variable to hold the player timer, so we can use it on KillTimer() new PlayerTimer[MAX_PLAYERS];
// The following code should be placed under your command or where the action begins CountDown[playerid] = 5; // set the count down variable to 5, so it counts down from 5 to 0 PlayerTimer[playerid] = SetTimerEx("ExecuteCommand", 1000, true, "i", playerid); // creating a repeatedly timer with an interval of 1 second, and passing the playerid that we will execute the cmd on // As SetTimerEx returns the timer id, so we made the PlayerTimer var hold the timerid so we can kill it later. // - // Now, let's forward the function that the timer is gonna call forward ExecuteCommand(playerid);
public ExecuteCommand(playerid) { CountDown[playerid] --; // decreases the CountDown variable by 1 if(CountDown[playerid] == 0) // (IF) the CountDown variable reached 0 { KillTimer(PlayerTimer[playerid]); // kill the timer, so it won't call this function again. // Execute your command here // Example: GivePlayerWeapon(playerid, 24, 300); return 1; } else // (ELSE) if the CountDown variable hasn't reached 0 yet. { // Tell the player how many seconds left // Example: new str[20]; format(str, sizeof str, "%i second(s) left", CountDown[playerid]); GameTextForPlayer(playerid, str, 1000, 3); } return 1; }
|
I will check it tomorrow THANKS MAN