SA-MP Forums Archive
Question about saving stats - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question about saving stats (/showthread.php?tid=647378)



Question about saving stats - Uvais - 04.01.2018

This is just a small and stupid question, I wanted to know if i save stats under "OnPlayerUpdate" using my savestats stock, will it cause any lag or something?


Re: Question about saving stats - RogueDrifter - 04.01.2018

At most, OnPlayerUpdate is getting called many many times a second i highly recommend saving stats in 2 cases:
1- The moment they change.
2- Using a 3 minute timer.


Re: Question about saving stats - Uvais - 04.01.2018

So if i put SetTimer("SaveStats", 600000, true); under OnGamemodeinit and put my savestats stock under public callback, it will save stats without lagging?


Re: Question about saving stats - GangstaSunny. - 04.01.2018

Depends on the size of your stocks. I would recommend to save stats as soon as the player lost the connection (example goes: /q - ESC+exit game - alt+f4 - timeout - crash)


Re: Question about saving stats - RogueDrifter - 04.01.2018

Quote:
Originally Posted by Uvais
Посмотреть сообщение
So if i put SetTimer("SaveStats", 600000, true); under OnGamemodeinit and put my savestats stock under public callback, it will save stats without lagging?
Yeah try that and see how it goes and lets hope that you don't use dini.
EDIT:@Gangsta if his server crashes due to a hacker/bug then player stats wont save.


Re: Question about saving stats - GangstaSunny. - 04.01.2018

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
Yeah try that and see how it goes and lets hope that you don't use dini.
EDIT:@Gangsta if his server crashes due to a hacker/bug then player stats wont save.
creating a timer to save every connected player every 3 minutes? not even with MySQL - btw Yes MySQL is fast er in this way but intern file writing is a lot faster than extern MySQL Server and client usage.


Re: Question about saving stats - RogueDrifter - 04.01.2018

Quote:
Originally Posted by GangstaSunny.
Посмотреть сообщение
creating a timer to save every connected player every 3 minutes? not even with MySQL - btw Yes MySQL is fast er in this way but intern file writing is a lot faster than extern MySQL Server and client usage.
I didn't suggest mysql, i'm clearly saying if you depend on saving player stats the moment he disconnects or crashes there's always a possibility of the server itself crashing and then player stats wont save also desynced players won't get their stats saved, probably.


Re: Question about saving stats - GangstaSunny. - 04.01.2018

desynced player stats will be safe (never got problems since 2011).

Okay Yes if the Server crashes the players stats wont save, but this also counts for the last 2:59 minutes. the only way to solve this is to got a stable Server and (just for the case) to save the most important stuff as soon as changed.


Re: Question about saving stats - RogueDrifter - 04.01.2018

Quote:
Originally Posted by GangstaSunny.
Посмотреть сообщение
desynced player stats will be safe (never got problems since 2011).

Okay Yes if the Server crashes the players stats wont save, but this also counts for the last 2:59 minutes. the only way to solve this is to got a stable Server and (just for the case) to save the most important stuff as soon as changed.
True but not much can happen every 3 minutes, although if you depend on disconnect and someone is playing for... say 5-7 hours and loses his progress, i'd never join again, true it's more safe to save the moment they change that's why i suggested that above at my first post.


Re: Question about saving stats - Uvais - 04.01.2018

I've added the timer, It's working perfect. Thanks for the help. Oh and I use Y_INI