OnPlayerUpdate performance question
#1

Hi, and thanks for taking the time to look at my thread. I'm currently developing my own gamemode (roleplay gamemode, specifically) and it's actually coming along rather well.

My question is, under the OnPlayerUpdate callback, would there be a big performance loss if I updated the PlayerData as shown below on each tick, and if so would there still be this performance loss?

Код:
public OnPlayerUpdate(playerid)
{
	...
	PlayerData[playerid][pHealth] = GetPlayerHealth(playerid);
	PlayerData[playerid][pFoo] = bar;
	PlayerData[playerid][pVar] = val;
	...

	return 1;
}
Reply
#2

I remember the last time I tried to do it it got the player health and was removing/adding it each second idk why I personally dont recommend this...
Reply
#3

Just make another callback, and use a timer to call it every x amount of seconds.
Reply
#4

Quote:
Originally Posted by Steven82
Посмотреть сообщение
Just make another callback, and use a timer to call it every x amount of seconds.
Thanks for the response, do you have any suggestions as to how many seconds it would be reasonable to have as the interval for polling this new callback?
Reply
#5

Yea, do what Steven82.

I personally recommend simply making a timer call ever, lets say, 5 seconds, if it only updates a few things.

I wouldn't recommend a SHITTON of variables in a timer every 5 seconds.

The way you are wanting to do this would cause quite alot of lag if there were a lot of variables that needed to be saved as-well as several players being online.
Reply
#6

Quote:
Originally Posted by Kindred
Посмотреть сообщение
Yea, do what Steven82.

I personally recommend simply making a timer call ever, lets say, 5 seconds, if it only updates a few things.

I wouldn't recommend a SHITTON of variables in a timer every 5 seconds.

The way you are wanting to do this would cause quite alot of lag if there were a lot of variables that needed to be saved as-well as several players being online.
Sweet, thanks. I'll try it this way and then do some stress-tests

Note that the players aren't actually being saved though, it's just the variables are having updated values Performing that many SQL queries a second would be suicide, lol.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)