Timers
#1

Is it possible to kill all timers with one 'for loop'. Can I somehow collect all timers in one place??
Reply
#2

If they all were in an array, it would work, but otherwise you can't , afaik.

I might be wrong according to his post: http://forum.sa-mp.com/showpost.php?...07&postcount=4

Reply
#3

Quote:
Originally Posted by Micko123
Посмотреть сообщение
Is it possible to kill all timers with one 'for loop'. Can I somehow collect all timers in one place??
You could do it like that:

PHP код:
new timers[5]; 
To access them, since you don't want to use the index:

PHP код:
#define TIMER_NAME_1 0
#define TIMER_NAME_2 1
#define TIMER_NAME_3 2
#define TIMER_NAME_4 3
#define TIMER_NAME_5 4
timers[TIMER_NAME_1] = new Timer(...); 
To kill them:

PHP код:
for(new count 0count sizeof(timers); count++)
{
    
KillTimer(timers[count]);

THat's kinda dirty tho, don't do it xD
Reply
#4

Well, you could simply loop like 100 or more times and do KillTimer as you can kill timers that are not running as far as I know. I don't think it would be a good idea though, but it should work. Just like that:
Код:
for (new i; i < 100; i++) KillTimer(i);
Reply
#5

Either save all timer IDs in an array, hook the set timer functions, or make a function that kills the timers without a loop.

I think YSF has a function that can get the active timers btw.
Reply
#6

Thank you all guys
Reply


Forum Jump:


Users browsing this thread: