OnPlayerUpdate or a Timer - 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: OnPlayerUpdate or a Timer (
/showthread.php?tid=452092)
OnPlayerUpdate or a Timer -
Magic_Time - 20.07.2013
What do you think?
What should I do to update the textdraws in my gamemode?
Place them below OnPlayerUpdate.
Or make a 1 second timer?
Won't the 1 second timer give lag to my server?
Re: OnPlayerUpdate or a Timer -
RedFusion - 20.07.2013
Depends if you really need to update your textdraws as fast as OnPlayerUpdate does.
I think you should use a timer and loop through every player with it.
Timers only lag in large quantities afaik, sounds unreasonable that 1 timer would make your server lag.
pawn Код:
forward YourFunctionName();
public YourFunctionName()
{
for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
{
if(!IsPlayerConnected(playerid)) continue;
//Add player textdraws here
}
return 1;
}
Re: OnPlayerUpdate or a Timer -
RajatPawar - 20.07.2013
Any damn day, a timer. A timer would update (around approximately) every 1 second while OPU updates 5 -6 or more than that each second.
Re: OnPlayerUpdate or a Timer -
Alternative112 - 20.07.2013
Definitely timer(s), you don't need to make them update as fast as OPU executes unless youre trying to make the text draws flash or something and give your players epilepsies.
Re: OnPlayerUpdate or a Timer -
MP2 - 20.07.2013
Quote:
Originally Posted by Gamer_Z
You know OnPlayerUpdate can get executed around 30-100 times a second for one player? I think using a timer (or even three timers and divide the workload) is less resource hogging.
|
I spent 15 minutes testing the frequency of OPU. Never got it above 43 (or 34, can't remember). 100 is impossible.