Rouzbeh Posted February 4, 2015 Share Posted February 4, 2015 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
tosfera Posted February 4, 2015 Share Posted February 4, 2015 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. Link to comment
Gallardo9944 Posted February 4, 2015 Share Posted February 4, 2015 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. Link to comment
Rouzbeh Posted February 4, 2015 Author Share Posted February 4, 2015 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
Gallardo9944 Posted February 4, 2015 Share Posted February 4, 2015 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
WASSIm. Posted February 4, 2015 Share Posted February 4, 2015 yo can make save data on element data change but make time save for anti spamming Link to comment
Rouzbeh Posted February 4, 2015 Author Share Posted February 4, 2015 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
Rouzbeh Posted February 4, 2015 Author Share Posted February 4, 2015 yo can make save data on element data change but make time save for anti spamming this is not good way , can be delay ... Link to comment
Rouzbeh Posted February 4, 2015 Author Share Posted February 4, 2015 Im done With Tosfera's and Galardo's posts but im now worry about roll backs only, my means if server or vps crashes in beetween save times , user datas will lost and rollback to last saved time...not? Link to comment
Gallardo9944 Posted February 4, 2015 Share Posted February 4, 2015 Your information will stay after you change it. Server crash won't affect it. So you better save more often to keep the data up to date in case something happens. Link to comment
neves768 Posted February 4, 2015 Share Posted February 4, 2015 Save when player disconnect/quit from server or when your server stop! It's the best method... Timers can delay or flood MySQL with requests. Link to comment
Dealman Posted February 5, 2015 Share Posted February 5, 2015 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now