KillTimer doesn't work
#1

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"1000true); 
PHP код:
forward CountDown();
public 
CountDown()
{
    foreach(
Joinersi)
    {
        
printf("counter = %i"counter);
        new 
countstr[128];
        if(
counter != 0)
        {
            
format(countstrsizeof(countstr), "Game starts in: %i"counter);
            
GameTextForPlayer(icountstr10004);
            
counter--;
        }
        else
        {
            
GameTextForPlayer(i"START!"10004);
            
KillTimer(CountTimer);
        }
    }
    return 
1;

The timer doesn't stop and just keeps printing 0
Reply
#2

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

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

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

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

Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)