Quote:
Originally Posted by TheToretto
Well your server isn\'t going to crash the whole day, just add a command for the server owner to save all players\' stats. Without kicking them or calling OnPlayerDisconnect, then... Shutdown your server;
If your server is really really unstable, just put a global timer, not per player, which saves players data every 20 minutes, or less. Who give a fuck if you lose 10$ because you bought a condom in the 24/7, I mean, you won\'t lose much data, you can\'t get $2.000.000 in 10/20 minutes...
|
I would, and alot of other players.
Because in 10 minutes, you could buy a house, apply a different interior, buy some furniture and place it, buy a house-vehicle, repaint it and apply tuning components.
Whenever that\'s done and something happens before your timer saves the data, all that is lost.
By the time you relog, someone else might have bought that house.
I would never come back to your server because I know playing there doesn\'t guarantee proper data-saving.
Players don\'t know if you save every 10 minutes, only on disconnect or if you save whenever data changes.
They DO care if they lose data and some will be furious and never come back, even if you reimburse them.
They just see that some data hasn\'t been saved properly and will distrust your server because of unreliable saving functions.
In every MMORPG I\'ve played, data is saved whenever something changes.
I\'ve never lost alot of progress, even when timing out, server crashes, lagging followed by a disconnect, whatever reason, simply because they save whenever data changes.
You could gain a level or 2, do some quests or turn them in, go to another map, all that in less than 10 minutes.
I\'ve never respawned in the previous map, having to turn in quests for the second time or regain my 2 levels I gained right before the crash/timeout/whatever.
Also, only saving when the player disconnects will also guarantee you\'ll lose players.
Some players play for hours at a time and if something unexpected happens, his entire progress hasn\'t been saved.
A stupid hacker can mess up your server, making it crash and you\'ll have no data saved for hours on end for multiple players.
Even a timer which saves everything at once is usually not done.
This timer would save EVERYTHING, even sex, class, skin, name (if you allow name-changes), email, ... (things that very rarely change, if they ever do).
Would you really generate a huge query with hundreds of values that must be saved, even when the possibility exists that some players afk for hours? Then you would send a huge query to MySQL which in the end does absolutely nothing, because there is nothing to be updated/changed.
This is a pure waste of processing power, both for your server which must construct the entire query, but mostly for MySQL, which must break down the entire query, find every value in the database, check if the provided value is valid (you can\'t store an int in a float column so MySQL checks that), and eventually overwrite the value one by one (it won\'t overwrite the value if it hasn\'t changed).
Surely pc\'s nowadays have fast processors, but that\'s no excuse to be a lazy programmer.
Creating a huge query that covers all values and put it in a timer seems a smart thing to do (it\'s at least convenient), but it\'s just being lazy.
Having alot of smaller queries which are executed whenever something changes save you alot of trouble.
One bug in your huge query and NOTHING gets saved.
One bug in one small query only messes up that single query while keeping everything else intact.
One huge query is also alot more difficult to bug-fix and find the problem.
Also, saving only when something changes prevents queries to be sent when they\'re not even needed, saving alot of processing power.
A game\'s render engine also only renders whatever is being displayed on the screen.
What if that engine would render the entire game world at once, from which only 5% would be shown on your screen? It would also be convenient for the programmer and it would guarantee the required models would be rendered, but it\'s not the proper way to create a game.
Your game would lag immensely and is impossible to play.
Only do whatever needs to be done at the time it needs to be done.
Don\'t do unneccessary stuff.
This applies for everything you do, not only programming.
Do you paint your living room every month just in case there "might" be a spot, crack, some dirt, whatever on your wall, wasting expensive paint and alot of time in the process?
Or do you just repaint your living room when it\'s really time to paint it (you don\'t like it anymore, or there are too many spots/cracks/whatever), which would be every 10 years or so?
Do you dismantle your car\'s engine every month to prevent wear and tear, applying new grease to every moving part to prevent anything happening soon, even when nothing\'s wrong?
Or do you only do the required maintenance as told by the manufacturer (change oil every year) and go to the garage whenever something\'s broken?
If your teacher requires you to read page 55 (in a 200-page book), do you read the entire book, including page 55, just to be sure you\'ve read it, even when the class for that day only handles page 55?
Or do you simply do whatever she wants you to do, and read only page 55?
Do you go to the toilet every 10 minutes and sit down, waiting for 2 minutes just in case you would need to build a huge pile of brown stuff, making you sit on the toilet over 100 times a day without even the need to do poopoo?
Or do you only go to the toilet when nature calls?
In all cases, I\'m pretty sure you do the second option.
Why would you do the first option in programming?