SA-MP Forums Archive
Checking if a timer is running? - 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: Checking if a timer is running? (/showthread.php?tid=326331)



Checking if a timer is running? - 2KY - 17.03.2012

How would I do so? By assigning it a value like so?

pawn Code:
new Timer1;

Timer1 = SetTimerEx( "Test1", 10000, false );

if(Timer1 == -1)
{
}
would that work? :3


Re: Checking if a timer is running? - MP2 - 17.03.2012

When the timer ends, the variable will still contain the timer's ID, so no, it won't work.

Let's see..

pawn Code:
new timer;

blahblah = SetTimerEx(..)
timer++;

public thetimerfunction(..)
{
    // Blah blah
    timer--;
}

// Check if running
if(timer) // Timer is running
You should bare in mind that you can have two timers running at once, the same function, so you don't want =1 or =0 you want ++ and --.