KillTimer doesn't work - 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: KillTimer doesn't work (
/showthread.php?tid=627001)
KillTimer doesn't work -
PeanutButter - 22.01.2017
I'm trying to make a countdown timer but for some reason the timer won't stop.
PHP код:
new counter = 4;
new CountTimer;
PHP код:
CountTimer = SetTimer("CountDown", 1000, true);
PHP код:
forward CountDown();
public CountDown()
{
foreach(Joiners, i)
{
printf("counter = %i", counter);
new countstr[128];
if(counter != 0)
{
format(countstr, sizeof(countstr), "Game starts in: %i", counter);
GameTextForPlayer(i, countstr, 1000, 4);
counter--;
}
else
{
GameTextForPlayer(i, "START!", 1000, 4);
KillTimer(CountTimer);
}
}
return 1;
}
The timer doesn't stop and just keeps printing 0
Re: KillTimer doesn't work -
Stones - 22.01.2017
Код:
new string[128];
format(string, 128, "%d", CountDownFromAmount);
GameTextForAll(string, 990, 5);
Код:
new CountDownFromAmount;
forward CountDownTimer();
Код:
CountDownFromAmount = 480; // 8min.
SetTimer("CountDownTimer", 999, 1);
Код:
public CountDownTimer()
{
CountDownFromAmount--;
if (CountDownFromAmount == 0)
{
GameTextForAll("End of the round!!", 3000, 5);
}
return 1;
}
Re: KillTimer doesn't work -
PeanutButter - 23.01.2017
I tried everything but nothing works. I even tried it with multiple countdown includes. It is probably because it is a filterscript. What could be interfering?
Re: KillTimer doesn't work -
MBilal - 23.01.2017
Код:
new counter = 4;
new CountTimer;
CountTimer = SetTimer("CountDown", 1000, true);
forward CountDown();
public CountDown()
{
printf("counter = %i", counter);
new countstr[64];
if(counter != 0)
{
format(countstr, sizeof(countstr), "Game starts in: %i", counter);
GameTextForAll( countstr, 1000, 4);
}
else
{
GameTextForAll("START!", 1000, 4);
KillTimer(CountTimer);
}
counter--;
return 1;
}
if you using it in any cmd that timer than update counter there 4. before that timer start
Re: KillTimer doesn't work -
PeanutButter - 23.01.2017
I found a way to temporarily fix it, just by making a variable to check if the timer should be active or not.
But this is probably not a good way to do it because the timer keeps running.
PHP код:
if(countactive == 1)
{
// code of the timer in here
}