Timers - 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: Timers (
/showthread.php?tid=624671)
Timers -
Micko123 - 20.12.2016
Is it possible to kill all timers with one 'for loop'. Can I somehow collect all timers in one place??
Re: Timers -
BiosMarcel - 20.12.2016
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
Re: Timers -
BiosMarcel - 20.12.2016
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:
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 = 0; count < sizeof(timers); count++)
{
KillTimer(timers[count]);
}
THat's kinda dirty tho, don't do it xD
Re: Timers -
GoldenLion - 20.12.2016
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);
Re: Timers -
SickAttack - 20.12.2016
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.
Re: Timers -
Micko123 - 21.12.2016
Thank you all guys