Countdown system
#1

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

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;
}
Reply
#3

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);

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)