SA-MP Forums Archive
Should a database save every-time a player disconnects? - 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: Should a database save every-time a player disconnects? (/showthread.php?tid=655467)



Should a database save every-time a player disconnects? - JMCortinax - 21.06.2018

Simple question, I've converted my script to use a database for player + vehicle data instead of INI files. Should the database be written to every-time a player disconnects?

Thanks in advance.


Re: Should a database save every-time a player disconnects? - DerickClark - 21.06.2018

Yes. cause you need to keep up with player data at all times of loses!


Re: Should a database save every-time a player disconnects? - JMCortinax - 21.06.2018

Great thank you! I thought that but just needed verification.

How often would you recommend saving the vehicle data (Location, Mods etc)? Each time OnPlayerExitVehicle is called?


Re: Should a database save every-time a player disconnects? - Dignity - 21.06.2018

Quote:
Originally Posted by DerickClark
Посмотреть сообщение
Yes. cause you need to keep up with player data at all times of loses!
No.. Saving all the data when a player quits is bad practice.


You send queries to the database when data changes. Not a big bundle of shit where half the values remain the same.

Does the player buy a skin? Update their skin variable in the database.
Do they bank some money? Update the bank money variable.

Nothing else.

You update the database when it changes in the game.


Re: Should a database save every-time a player disconnects? - DerickClark - 21.06.2018

Quote:
Originally Posted by Dignity
Посмотреть сообщение
No.. Saving all the data when a player quits is bad practice.


You send queries to the database when data changes. Not a big bundle of shit where half the values remain the same.

Does the player buy a skin? Update their skin variable in the database.
Do they bank some money? Update the bank money variable.

Nothing else.

You update the database when it changes in the game.
But you can do that also update during the game.


Re: Should a database save every-time a player disconnects? - GoldenLion - 21.06.2018

You should only save things that update frequently (such as online time, etc) when the player disconnects, but update instantly things that don't update too often such as admin level, vehicle ownership, etc.