Jump to content

Whats The Best Method to Save Data In Mysql Database?


Rouzbeh

Recommended Posts

Hi, im scripting a scratch RPG script, and i have a question: which method is better to save data in mysql, send data to database on Element Data Change OR When Player gone Offline and stop resource?

i think if save only on player logout and stop resource i'll have some problems like if server crash or close un-normaly data not save...

at all what method is the best ?

Link to comment
Well, when the element data changes is very dangerous and will spam your database so bad that your server crashes every time a player does something with friends.

I would rather do it when the resource stops and an hourly save.

ow ok so i save it hourly , on player quit and on resource stop.

Never make your permanent data depend on your element data. It's easily hackable. Change your original data and only then change element data, according to what your permanent data says.

i dont used element datas in my script until now, so you say i keep it only on events?

Link to comment

I personally write user data to mysql every time i want to change it. No impact on the server what so ever.

Main idea of multiplayer - never trust client. And any client can modify element data and/or send fake events. You better create a separate resource with exported functions which you can be called only from the server. Or you can use events and check if there is a "client" variable and cancel it if it exists ("client" variable presence means the event was called from client side)

Link to comment
I personally write user data to mysql every time i want to change it. No impact on the server what so ever.

Main idea of multiplayer - never trust client. And any client can modify element data and/or send fake events. You better create a separate resource with exported functions which you can be called only from the server. Or you can use events and check if there is a "client" variable and cancel it if it exists ("client" variable presence means the event was called from client side)

right... very thanks

Link to comment

It also depends on what you're saving. For example if you save the player's position, rotation, interior, dimension, money and etc - you'll be fine to save it every 10-15 minutes or so.

You can also add the option for the player to force save, and add a cooldown so they can't spam it.

Don't be too shy, SQL databases tend to be underestimated.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...