OnPlayerUpdate
#1

I wonder if i could use a saving function for onplayerupdate for mysql variables i want to save
for example if player stats are saved through onplayerupdate will this cause problem to server like lagging or something like that?
Reply
#2

Why would you need to?

Just save the data on score/money/data change. Plus OnPlayerDisconnect. As Vince mentioned in a thread, people seem to want to save everything in one query. Don't do that either. Save the major stuff. IE: Money, score, skin etc and leave stuff out like, house id, admin level and stuff.
Reply
#3

Quote:
Originally Posted by vassilis
Посмотреть сообщение
will this cause problem to server like lagging or something like that/
Yes, very much so. It's comparable to a 30 millisecond timer (give or take, depends on what the player is doing). Only use OnPlayerUpdate if you know what it's meant for (custom callbacks come to mind). It's not your one-size-fits-all general server timer.
Reply
#4

OnPlayerUpdate is called EVERY TIME the client updates the server with new information. I remember ****** showing a graph / diagram, or something of what happens when the callback is called. Its a long list. Just save when the players stats update. Make sure how-ever you save though, that it doesn't cause the server to lag, and or hang while the data is being saved, that'd make gameplay an awful experience for players.

Simply put: No: it's a horrible idea! It will cause many issues, and is simply put, illogical.
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
Yes, very much so. It's comparable to a 30 millisecond timer (give or take, depends on what the player is doing). Only use OnPlayerUpdate if you know what it's meant for (custom callbacks come to mind). It's not your one-size-fits-all general server timer.
Thats what i thought too.Thanks for feedback fellas
Also one more question :
i added also saving at the variables it is neccessary(setlevel etc) but should i remove the saving on disconnect or i should let it just for a secondary saving system?
Reply
#6

bump i would like an answer if you don't mind
Reply
#7

If you're certain every query works, you can skip saving everything again during OnPlayerDisconnect.

Whenever a variable changes, like money, save it in the database with a small query, preferably inside a small function that updates the money on the server, as well as sending a small query to change the money value in the database (like I showed previously using Player_Reward in the other thread).

If you have such a system for everything, you don't need another huge query to save everything when a player logs out, as all data has been saved already when he was playing the game.
Because after the last save, data didn't change anymore, so no reason to save it again.

Whenever I add a new query to my script, I run the server, open Navicat and display the data in my tables.
When I run the game and I edit the value of that new variable (say jailtime), I put myself in jail and check the database, when the game is still running.
If it updates everytime, it works and you can skip saving that when you logout as it has been updated properly.
Reply
#8

Yes, It will lag your server as this OnPlayerUpdate is called very frequently per second per player. You should use OnPlayerDisconnect for saving player stats.
Reply
#9

Quote:
Originally Posted by De4dpOol
Посмотреть сообщение
Yes, It will lag your server as this OnPlayerUpdate is called very frequently per second per player. You should use OnPlayerDisconnect for saving player stats.
First of all read PPC reply before you reply.. and check my last question on topic
Reply
#10

To keep updating players stats time to time, I would suggest you to set a repeated timer of 5-7 minutes and do not use OnPlayerUpdate for updating stats it will crash your server or create too much of lag because INIs are not that fast.

dini: 63810 -over 1 minute
yini: 1564 - 1 second

Update is called several times within 1 second, forcing the INI system to write will cause server crash or data loss.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)