What will be better, this ... or this ...
#1

Hello,

I want to make a Dini save timer and I made it for each player, I mean
when a player connects his/her time will be counted to 30 minutes, after
the 30 minutes has been past, all his/her stats will save. I save that with
this code:
Код:
SetTimerEx("SaveStats", 1800000, true, "i", playerid);
Under OnPlayerConnect.
So what will be beter, if I do under OnGameModeInit and save everyone's
stats at a time or save stats by when players connect after 30 minutes?
So this code:
Код:
SetTimer("SaveStats", 1800000, true)
Under OnGameModeInit..
What's better, and which Timer is the best?
I hope this info. was enough to get helped..

K. Regards,
I. C.
Reply
#2

Why not save them OnPlayerDisconnect?
Reply
#3

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
Why not save them OnPlayerDisconnect?
If the server crash all stats will be lossed?

I'm saving the stats as they change, i.e if a player gets +1 in score I directly save it to the database to prevent missuse. Then I'm saving positions at OnPlayerDisconnect(). This is how I do it, but you should find a way that suits your gamemode.
Reply
#4

Quote:
Originally Posted by Not available
Посмотреть сообщение
If the server crash all stats will be lossed?

I'm saving the stats as they change, i.e if a player gets +1 in score I directly save it to the database to prevent missuse. Then I'm saving positions at OnPlayerDisconnect(). This is how I do it, but you should find a way that suits your gamemode.
I second this. I'm going to add a timer for ever 10-15mins to save players, but i save them after every update, new level, new cash, new admin level, then positions saved on disconnect.
Reply
#5

Quote:
Originally Posted by Not available
Посмотреть сообщение
I'm saving the stats as they change, i.e if a player gets +1 in score I directly save it to the database to prevent missuse.
That goes against the whole point of using variables.
However, a timer that loops through all online players and save their stats every 30 minutes is the better option,
so SetTimer and use the loop inside the timer.
Reply
#6

Quote:
Originally Posted by Mike Garber
Посмотреть сообщение
That goes against the whole point of using variables.
However, a timer that loops through all online players and save their stats every 30 minutes is the better option,
so SetTimer and use the loop inside the timer.
How come? The server will get a lot to handle at once instead of small queries. Make a function that updates the certain variable you want and stores in mysql/files whatever you use.
Reply
#7

Quote:
Originally Posted by Not available
Посмотреть сообщение
How come? The server will get a lot to handle at once instead of small queries. Make a function that updates the certain variable you want and stores in mysql/files whatever you use.
If you keep writing to a file or sending queries all the time (if there's a decent amount of players that use the features regularly) the server performance will be slower then If you saved all online player data once every 30 minutes and on OnPlayerDisconnect.

If you optimize the code It shouldn't create so called "lag spikes" either, and even If It did create a 1 second lag spike every 30 minutes, that would be better then have people lagging all the time instead.
Trust me, I'm currently using a script that does It like you suggested, and It doesn't work very well, one of the reasons I'm creating a new gamemode.
Reply
#8

I've done this before, just save theire stats on a function. that goes off every 30 mins or so. badaboom.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)