SA-MP Forums Archive
y_timers question - 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: y_timers question (/showthread.php?tid=659052)



y_timers question - wallee - 21.09.2018

Is it better to have 1 "task" of 1000ms with a foreach loop inside doing various checks or having a lot of "timers" for individual players? I have a lot of things and there could be a lot ... like really a lot (maybe up to a thousand timers at once). They will contain very little code though, like a variable reset.

So what would be better?


Re: y_timers question - kingmk - 21.09.2018

Yes, 1 "task" of 1000ms it's better and safe.

Код:
task GlobalTimer[1000]()
{	
       foreach(new i : Player)
       {
              //All functions for player who need looped. (Ex: OnPlayerIsInVehicle(i); -> Show player vehicle info like KM/h )
       }
       //All basic functions who need looped. (Ex UpdateTime(); )
}



Re: y_timers question - wallee - 22.09.2018

is there a way to hook ptasks? i tried this:

Код:
ptask Justatimer[1000](playerid)
{
	printf("Original code.");
}

hook:Justatimer(playerid)
{
	printf("Hooked code.")
}
and i get this when compiling:

Код:
warning 203: symbol is never used: "Justatimer@007"
the timer still runs, but the hooked code doesn't


Re: y_timers question - VVWVV - 22.09.2018

Quote:
Originally Posted by wallee
Посмотреть сообщение
is there a way to hook ptasks? i tried this:

Код:
ptask Justatimer[1000](playerid)
{
	printf("Original code.");
}

hook:Justatimer(playerid)
{
	printf("Hooked code.")
}
and i get this when compiling:

Код:
warning 203: symbol is never used: "Justatimer@007"
the timer still runs, but the hooked code doesn't
This is not implemented yet.


Re: y_timers question - VVWVV - 22.09.2018

******, does the library have an implementation for hooked timers?

Example:
pawn Код:
ptask foo[1000](playerid) { /*code*/ }
hook ptask foo[1000](playerid) { /*code*/ }



Re: y_timers question - wallee - 22.09.2018

This hangs the server:

Код:
hook @_yTJustatimer(playerid)
{
}
This works perfectly:

Код:
hook Justatimer(playerid)
{
}
Can i depend on the second thing or will it change?

(i'm currently using YSI4)


Re: y_timers question - wallee - 22.09.2018

Quote:
Originally Posted by ******
Посмотреть сообщение
You can't depend on it, no... Also, I know why it hangs, might need to fix that.
i don't mind changing my code, when i say "depend" i mean will the functionality of hooking timers stay in YSI in some way?


Re: y_timers question - wallee - 23.09.2018

thank you ******