[solved]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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [solved]TIMER (
/showthread.php?tid=123074)
[solved]TIMER -
deather - 24.01.2010
This is my code. But the timer is not getting killed.
Код:
new CountDown;
forward Countdowntimer(playerid);
CountDown= SetTimer("Countdowntimer", 999, true);
KillTimer(CountDownTimer);
Re: Timer -
Striker_Moe - 24.01.2010
Youґre doing it wrong.
Код:
new Countdown;
forward Countdowntimer(playerid);
Countdown = SetTimer("Countdowntimer", 999, true);
KillTimer(Countdown);
Re: Timer -
deather - 24.01.2010
it isnt killing the timer....
Код:
[if(Countdown == 0)
{
ResetPlayerWeapons(playerid);
KillTimer(Countdown);
}
}/code]
Re: Timer -
mansonh - 24.01.2010
Countdown does not count down.
Countdown is the ID of the timer.
Then you can kill the timer using its ID which is Countdown.
Re: Timer -
deather - 24.01.2010
Quote:
Originally Posted by mansonh
Countdown does not count down.
Countdown is the ID of the timer.
Then you can kill the timer using its ID which is Countdown.
|
I really get confused
Re: Timer -
Niixie - 24.01.2010
Countdown doesnt have anything to do with CountDownTimer
Код:
Countdown = SetTimer("CountDownTimer", 999, true);
so when you do
Код:
KillTimer(Countdown);
it will kill Countdown
wich is
Код:
SetTimer("CountDownTimer", 999, true);
because of the =
You get it?
Re: Timer -
deather - 24.01.2010
So do i kill that Countdowntimer when it reaches zero?
Re: Timer -
mansonh - 24.01.2010
No, well you can but there is no point.
Countdown = SetTimer("CountDownTimer", 999, false);
Countdown is now the id of the Timer. which is set to run for 999 ms.
So after 999ms the Timer (which has id Countdown) will call the function given
CountDownTimer
So the first variable of SetTimer is the function to call, which is called after the ms given in the second param which in this case is 999.
If you only want the timer to run once, then the third variable should be false, then the timer will stop once it has called CountDownTimer.
So in this case there is no need to kill the timer, it automatically dies.
However if you want to repeatedly call a function you set the third variable to true.
Does that make more sense?
Re: Timer -
deather - 24.01.2010
Quote:
Originally Posted by mansonh
No, well you can but there is no point.
Countdown = SetTimer("CountDownTimer", 999, false);
Countdown is now the id of the Timer. which is set to run for 999 ms.
So after 999ms the Timer (which has id Countdown) will call the function given
CountDownTimer
So the first variable of SetTimer is the function to call, which is called after the ms given in the second param which in this case is 999.
If you only want the timer to run once, then the third variable should be false, then the timer will stop once it has called CountDownTimer.
So in this case there is no need to kill the timer, it automatically dies.
However if you want to repeatedly call a function you set the third variable to true.
Does that make more sense?
|
it could be better if you give me the script. Sry
Re: Timer -
mansonh - 24.01.2010
Код:
new Countdown = SetTimer("CountDownTimer", 999, false);
forward CountDownTimer();
public CountDownTimer()
{
//do whatever you want here, the timer is already finished because we used false so it won't repeat
}