SA-MP Forums Archive
Question about OnPlayerUpdate - 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: Question about OnPlayerUpdate (/showthread.php?tid=598261)



Question about OnPlayerUpdate - Dragonic - 10.01.2016

Simple question that I'm not 100% sure about:

Well I had like 5-6 things running at OnPlayerUpdate. With only me and my beta-testers online everything was running smoothly but then I thought: what would happen when I release my server and it gets maybe 20-30 players online? OnPlayerUpdate activates alot of times per minute, then...

If I put everything that is under OnPlayerUpdate in a timer that activates every 0,5s will it have less cpu usage or it'll stay the same?


Re: Question about OnPlayerUpdate - BiosMarcel - 10.01.2016

Yeah you shouldn't use onPlayerUpdate too much, cause it updates at a fixed interval and everytime the player does smth, i have already had problems cause i made almost everything in onPlayerUpdate.


Re: Question about OnPlayerUpdate - Dragonic - 10.01.2016

Hm.. Just to make sure. Well, when playing you can't notice the difference between a timer that activates 2 times per second and one that activates 100+ per second so I should be fine with my script


Re: Question about OnPlayerUpdate - GTLS - 10.01.2016

You can try update each 2 min., that would not create Problem.


Re: Question about OnPlayerUpdate - Dragonic - 10.01.2016

Naah, I need it to update fast, but not as fast as OnPlayerUpdate. I'm using one that updates a few funcions every 0,5s and other that updates one little funcion every 0,05s.


Re: Question about OnPlayerUpdate - PrO.GameR - 10.01.2016

Quote:
Originally Posted by Dragonic
Посмотреть сообщение
Simple question that I'm not 100% sure about:

Well I had like 5-6 things running at OnPlayerUpdate. With only me and my beta-testers online everything was running smoothly but then I thought: what would happen when I release my server and it gets maybe 20-30 players online? OnPlayerUpdate activates alot of times per minute, then...

If I put everything that is under OnPlayerUpdate in a timer that activates every 0,5s will it have less cpu usage or it'll stay the same?
OPU is a feature, miss-usage will result in lag n stuff, USING it won't hurt.
OPU gets called every 30 ms, 1 sec is 1000 ms, so yeah, a timer of 0.5s will be better than OPU if that does the trick for you but if you are already using that and it's alright with a smooth lag free gameplay no need to change it.


Re: Question about OnPlayerUpdate - Jefff - 10.01.2016

You can change refreshing in OPU

pawn Код:
new tick = GetTickCount();

if( ( tick - LastTick[playerid] ) > 500 ) // update every 500ms
{
    LastTick[playerid] = tick;
    // code
}



Re: Question about OnPlayerUpdate - Pottus - 11.01.2016

You use OPU when it makes sense to use it remember it is called when a player updates to the server so in some situations you will want to do something when that happens.