Question about OnPlayerUpdate
#1

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

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

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

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

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

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

You can change refreshing in OPU

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)