26.07.2014, 15:07
How can I make countdown timer for example 10 seconds? I don't want to do 10 new callbacks and 10 timers because it's silly what is other way of doing it?
//under a callback
SetTimer("CountDown",10000,false);
//outside all callbacks
forward CountDown();
public CountDown()
{
}
new TimerCreator;
//callback
new counter = 11;
TimerCreator = SetTimer("CountDown",1000,true);
//callback not.
forward CountDown();
public CountDown()
{
counter = counter - 1;
if(counter == -1)
{
KillTimer(TimerCreator);
}
else GameTextForPlayer(playerid,counter,100,3);
}
new CountDown = 10;
new vartimer;
vartimer = SetTimer("CountDown",1000,false);
//outside all callbacks
forward CountDown();
public CountDown()
{
CountDown --;
if(CountDown == 9) GameTextForAll("9", 5000, 3 );
if(CountDown == 8) GameTextForAll("8", 5000, 3 );
if(CountDown == 7) GameTextForAll("7", 5000, 3 );
// goes on
//......
if(CountDown == 0) GameTextForAll("Countdown finish", 5000, 3 ); KillTimer(vartimer);
}