'LinKin Posted February 13, 2014 Share Posted February 13, 2014 Hello, I want an advice from a more experienced person regarding the following situation: Should I update the 'playtime' column in a SQL database (default from mta registry.db) each second? Imagine there are 30 players in the server, and each one requiring his own update (addition + 1 sec) in their 'playtime' column every second. Is there some crash risk? Or should I use get/setElementData. So that when a player joins the server, it gets his playtime (previously stored in SQL db). And store it into the ElementData. And after he quits, take the value from the ElementData and store it into the SQL db. Is this one more safe? Thanks. Link to comment
Jacobob14 Posted February 13, 2014 Share Posted February 13, 2014 what you want is that Paytime saved when entering and leaving the server ?? Link to comment
Moderators Citizen Posted February 13, 2014 Moderators Share Posted February 13, 2014 Both solutions won't produce any crash, so they are both safe. BUT ! I wouldn't recommend the first solution (updating each sec) because it will use resources to update a data in database that's not that important. Since it's just for some stats, it's not needed to update it each sec. I would use the second solution but I would also use a timer to update that data every 10 minutes in case of crash. As far I know, the onPlayerQuit event isn't triggered when the player's game crash (can someone please confirm ?). With this "mixed" solution, it won't spam the database and it will prevent players to loose 10+mins of playing time for their stats in case of crash (server or client). Regards, Citizen Link to comment
glowdemon1 Posted February 13, 2014 Share Posted February 13, 2014 I personally have the same feelings as above me^. I've made my own playtime script and I set the current tick count of the server as elementData on the player and whenever a player leaves, I substract the old tickcount from the new tick count and multiply it by 1000 to get the amount of seconds spent. I've never had problems with this. Plus it's not a that big loss if you lose your playtime, considering the odds of losing it. Seeing the chances of your server crashing + the fact that the average player disconnects/reconnects every two hours or so. Perhaps a backup each 30mins wouldn't hurt. Link to comment
ixjf Posted February 13, 2014 Share Posted February 13, 2014 Both solutions won't produce any crash, so they are both safe. BUT ! I wouldn't recommend the first solution (updating each sec) because it will use resources to update a data in database that's not that important. Since it's just for some stats, it's not needed to update it each sec. I would use the second solution but I would also use a timer to update that data every 10 minutes in case of crash.As far I know, the onPlayerQuit event isn't triggered when the player's game crash (can someone please confirm ?). With this "mixed" solution, it won't spam the database and it will prevent players to loose 10+mins of playing time for their stats in case of crash (server or client). Regards, Citizen Whenever the client crashes, the connection times out (server --> client), therefore onPlayerQuit is triggered. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now