25.10.2018, 19:07
PHP код:
#define COUNT_DOWN_TIMER 5 // 5 seconds countdown, edit this value as you wish
// Global Variables
new timer, str[64];
// Start the countdown, command or whatever
timer = COUNT_DOWN_TIMER; // Seconds to countdown, define above
SetTimerEx("CountDown", 250, false, "i", playerid); // Be sure to pass playerid to CountDown callback, you will need it
forward CountDown(playerid); // You always need to forward custom callbacks before calling them
public CountDown(playerid){
timer--;
if(timer > 1){ // 2 3 4 5 etc
format(str, sizeof(str), "Starting in %i seconds.", timer);
// GameTextForPlayer or
// SendClientMessage or
// TextDrawSetString
}
if(timer == 1){ // value 1 only
format(str, sizeof(str), "Starting in %i second.", timer); // 1 second IS NOT 1 secondS
// GameTextForPlayer or
// SendClientMessage or
// TextDrawSetString
}
if(timer <= 0){ // Count down ended!
format(str, sizeof(str), "Count down ended! Starting...");
// GameTextForPlayer or
// SendClientMessage or
// TextDrawSetString
return 1; // Don't call the count down anymore
}
return SetTimerEx("CountDown", 1000, false, "i", playerid);
}