y_timers question
#1

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?
Reply
#2

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(); )
}
Reply
#3

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
Reply
#4

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.
Reply
#5

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

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

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)
Reply
#7

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?
Reply
#8

thank you ******
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)