A question about y_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: A question about y_timers (
/showthread.php?tid=639048)
A question about y_timers -
RedGun2015 - 10.08.2017
I want to do a global timer, but i don't know how to use y_timers, for now i'm using SetTimerEx and Public function, but i want to change.
I want to be constantly called (every 1 second)
I have this in my gamemode:
Code:
OnGameModeInit:
global_timer = SetTimer("timerglobal", 1000, 1);
GameModeExitFunc:
KillTimer(unjailtimer);
////
forward timerglobal
public timerglobal()
{
....
return 1;
}
And i changed like this:
Code:
OnGameModeInit:
defer global_timer();
GameModeExitFunc:
stop global_timer();
////
task global_timer[1000]()
{
....
}
Is it ok how did I replace or something is wrong?
Re: A question about y_timers -
Misiur - 10.08.2017
Task is different than timer. It runs always, no need to start it manually with defer (alto this means you can't stop it). If you are doing a loop of players in your global_timer, then ptask is right for you