SA-MP Forums Archive
Countdown system - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Countdown system (/showthread.php?tid=660125)



Countdown system - KamilPolska - 25.10.2018

How to make a countdown in TD?
5, 4, 3, 2, 1, START


Re: Countdown system - UFF - 25.10.2018

Something like this

pawn Код:
new timer; timercount = 0, str[100];


//On Your Function
timercount = 5; // 5 seconds
timer = SetTimer("CountDown", 1000, true); // CountDown

forward CountDown()
public CountDown()
{
    timercount--;
    if(timercount == 0)
    {
        format(str, sizeof(str), "~r~START!");
                KillTimer(timer);
    }
    else
    {
        format(str, sizeof(str), "~b~STARTS in: %i SECONDS.", timercount);
    }
    TextDrawSetString(textdrawname, str);
    return true;
}



Re: Countdown system - v1k1nG - 25.10.2018

PHP код:
#define COUNT_DOWN_TIMER 5 // 5 seconds countdown, edit this value as you wish
// Global Variables
new timerstr[64];
// Start the countdown, command or whatever
timer COUNT_DOWN_TIMER// Seconds to countdown, define above
SetTimerEx("CountDown"250false"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(strsizeof(str), "Starting in %i seconds."timer);
        
// GameTextForPlayer or
        // SendClientMessage or
        // TextDrawSetString
    
}
    if(
timer == 1){ // value 1 only
        
format(strsizeof(str), "Starting in %i second."timer); // 1 second IS NOT 1 secondS
        // GameTextForPlayer or
        // SendClientMessage or
        // TextDrawSetString
    
}
    if(
timer <= 0){ // Count down ended!
        
format(strsizeof(str), "Count down ended! Starting...");
        
// GameTextForPlayer or
        // SendClientMessage or
        // TextDrawSetString 
        
return 1// Don't call the count down anymore
    
}
    return 
SetTimerEx("CountDown"1000false"i"playerid);