Countdown timer?
#1

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?
Reply
#2

pawn Код:
//under a callback
SetTimer("CountDown",10000,false);

//outside all callbacks
forward CountDown();
public CountDown()
{
}
This is how to create a 10 seconds countdown timer.
Reply
#3

Okay but I want to make that on screen will be text you know.. 10,9,8,7,6 this is what I'm trying to make.
Reply
#4

pawn Код:
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);
}
EDIT: sorry, some mistake in the previous post. take this
Reply
#5

Search!

https://sampforum.blast.hk/showthread.php?tid=363519
https://sampforum.blast.hk/showthread.php?tid=343709
Reply
#6

pawn Код:
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);
}
Reply
#7

if you're gonna set the repeat-case to false, it will never count down until 0.
And you must kill the timer somewhere
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)