Game server and database interactions

Hi all,
I’m new at multiplayer game programming and I’ve encountered some questions about that.
I particular I don’t know if it is better to load all player information into the server at the start and saving at specific intervals or if I should work and interact with the database all the time without having the data loaded in the server.

Thanks for your attention.

EDIT: I’m trying to make an mmorpg

What sort of game is it? Some game types wouldn’t matter if you saved data once per minute, but some would be ruined if they lost track of anything.

Oh yeah, sure, I had to specify xD It is an mmorpg

You should load the player data (name etc.) in at the login and save/load when needed.
F.E. Don’t continuously save your inventory into the database, but load it at the start of the game and save inventory into the database when the player disconnects.

Thanks a lot :wink:

If you are worried about server crashes then you can also update the database once every x minutes/hours or whenever nothing changed in the inventory for a minute or so.

If you don’t want item duping, then you have all actual item interactions take place on the server, then sync the client to the latest server state whenever it changes.

If you sync the inventory on login and logout you’re asking for all kinds of item dupe bugs/exploits. The only place to reliably pick up/drop/discard/trade an item is a transaction on the server.

^

I was thinking about saying the same thing, but then I realised that the OP was asking when THE SERVER should STORE DATA in the DATABASE.

Of course I will make the server able to control everything to avoid this kind of issues and cheating :wink:

Yes, for sure I will update the database every X minutes, 30 for example

You probably want to load everything at the start of the server and store back everything at the end or when a player disconnect or every TOT minutes.

You’re right, I completely misread the initial post. :-X