Data Saving

How should I save data for a player.

Like when they disconnect, every few minutes, when they edit any data(spend money) etc.

I am afraid the server may crash and the hook isnt called, thus stopping the save.

I am using MySql so I want to try to be as resourceful as possible.

How would it “corrupt the save”? If the hook isn’t called, then it won’t save the data period thus meaning that the database will have their pre-crash data.

Save the data everytime it changes. When a player picks up money, save it. When the player buys a pistol, save his money (and maybe the pistol too if yuo want). When he changes his name, save it.

That would be like a query a second, I am trying to prevent that from happening.

Just keep all the data in tables, and save it every few minutes, plus when the server changes level/shuts down.

They might lose some stuff if the server crashes, but they’d have to be really unlucky.

Where exactly, do you need to save their data every second?

**[Player.SetPData

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.SetPData)**