Countdown timer? - 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 timer? (
/showthread.php?tid=528153)
Countdown timer? -
Lajko1 - 26.07.2014
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?
Re: Countdown timer? -
NaClchemistryK - 26.07.2014
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.
Re: Countdown timer? -
Lajko1 - 26.07.2014
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.
Re: Countdown timer? -
NaClchemistryK - 26.07.2014
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
Re: Countdown timer? -
[KHK]Khalid - 26.07.2014
Search!
https://sampforum.blast.hk/showthread.php?tid=363519
https://sampforum.blast.hk/showthread.php?tid=343709
Re: Countdown timer? -
Champ - 26.07.2014
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);
}
Re: Countdown timer? -
NaClchemistryK - 26.07.2014
if you're gonna set the repeat-case to false, it will never count down until 0.
And you must kill the timer somewhere