[solved]TIMER
#1

This is my code. But the timer is not getting killed.

Код:
new CountDown;
forward Countdowntimer(playerid);

CountDown= SetTimer("Countdowntimer", 999, true);

KillTimer(CountDownTimer);
Reply
#2

Youґre doing it wrong.

Код:
new Countdown;
forward Countdowntimer(playerid);

Countdown = SetTimer("Countdowntimer", 999, true);

KillTimer(Countdown);
Reply
#3

it isnt killing the timer....
Код:
[if(Countdown == 0)
  {  
  ResetPlayerWeapons(playerid);
  KillTimer(Countdown);
  }
}/code]
Reply
#4

Countdown does not count down.
Countdown is the ID of the timer.

Then you can kill the timer using its ID which is Countdown.
Reply
#5

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
Reply
#6


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

So do i kill that Countdowntimer when it reaches zero?
Reply
#8

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

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
Reply
#10

Код:
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
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)