Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Sebastian on May 28, 2017, 04:52 PM

Title: ? Best moments to save player's data
Post by: Sebastian on May 28, 2017, 04:52 PM
I've seen numerous ways of saving data: some good, some worse
But which one would actually be the greatest ?
(making almost imposible to lose any data by a crash or anything else)
Title: Re: ? Best moments to save player's data
Post by: . on May 28, 2017, 05:12 PM
It all depends on the cost of saving the data.
Title: Re: ? Best moments to save player's data
Post by: EK.IceFlake on May 28, 2017, 05:18 PM
Save it on-demand to 6 MySQL servers all hosted on different continents.
Title: Re: ? Best moments to save player's data
Post by: KAKAN on May 28, 2017, 05:29 PM
Quote from: EK.IceFlake on May 28, 2017, 05:18 PMSave it on-demand to 6 MySQL servers all hosted on different continents.
redundancy, one word for your whole sentence xd
Title: Re: ? Best moments to save player's data
Post by: NicusorN5 on May 28, 2017, 05:35 PM
When the player is using a cmd, or is getting killer I think.
Title: Re: ? Best moments to save player's data
Post by: Sebastian on May 28, 2017, 05:48 PM
No one likes to lose things for dumb reasons... so the database must be saved frequently.
But when actually ? without lagging

onPlayerPart ?
onPlayerSpawn ?
saving it at an interval of 20mins ?
onPlayerDeath ?
Title: Re: ? Best moments to save player's data
Post by: DizzasTeR on May 28, 2017, 07:28 PM
onPlayerPart is fine.

:edit: Before any dumbass shows up and says "WHAT IF SERVER CRASHES HUH? HUH? HUH?!!?!!?!? Then just remember to fix your broken scripts so it doesn't crash.
Title: Re: ? Best moments to save player's data
Post by: NewK on May 28, 2017, 07:32 PM
On the CTF (5.0) server, I save it on the exact moment when there's changes to make. For example OnPlayerKill. Whenever there's a kill, I save it on that exact moment to the DB. This would usuallly lag the server, but I do it on a different thread, so it doesn't.

I have a thread pool system in place for every time I need to interact with the DB. All DB interactions are made on a different thread so it doesn't lagg the server. Also doesn't matter how frequent DB changes happen because I can limit the amount of threads on my thread pool and I can also set the time limit for which the threads may remain idle before being removed from the thread pool. I can control all of this while the server is running with IRC commands.

You can't really do any of this on the squirrel plugin though, I use the Java plugin so that's why this is possible. This is in my opinion the biggest advantage the Java plugin has. The ability to manage threads and do whatever you want asynchronously if you ever need to. Squirrel users are missing out on alot of great stuff by not using the java plugin.
Title: Re: ? Best moments to save player's data
Post by: Sebastian on May 28, 2017, 07:55 PM
I've heard a lot of good things about java plugin, PLENTY of advantages.
Seems like you got one BIG enough to proof it's worthy.

But I'm still using Squirrel, and learning java is not worthy for me as it won't be needed in my profession.
Scripting is just fun for me, and I had alot by doing it in vcmp, with squirrel.

Right now I'm kinda working on something that might be my last project in vcmp, and I'm really wondering what (and when) you guys suggesting to save the data, to keep it updated as frequently as posible, and in the most economic/not-lagging way.
I wanna hear the best suggestions you've got.

Truly thank you for your answer!
Title: Re: ? Best moments to save player's data
Post by: . on May 28, 2017, 08:10 PM
Quote from: Doom_Kill3R on May 28, 2017, 07:28 PM...Then just remember to fix your broken scripts so it doesn't crash.

What if the server itself crashes? Not something rare here.
Title: Re: ? Best moments to save player's data
Post by: kennedyarz on May 28, 2017, 08:39 PM
@sseebbyy, just do this. Make an Autosave function in your script. Then set a function like NewTimer but not NewTimer. Make it work with OnTimeChange that is saved every 10 seconds and also set Autosave () on OnPlayerPart; And you will not have problems.
Title: Re: ? Best moments to save player's data
Post by: DizzasTeR on May 28, 2017, 10:18 PM
Quote from: . on May 28, 2017, 08:10 PM
Quote from: Doom_Kill3R on May 28, 2017, 07:28 PM...Then just remember to fix your broken scripts so it doesn't crash.

What if the server itself crashes? Not something rare here.

It doesn't crash itself. Atleast mine doesn't.
Title: Re: ? Best moments to save player's data
Post by: PunkNoodle on May 29, 2017, 12:12 AM
My 2 cents, save when onPlayerPart and also with an interval of 15 or 30 mins for example. In this way if the server crashes you'll lose only half an hour of data maximum (if you chose 30 mins interval). The operation of saving to a database each interval isn't a lag-causing operation itself that mostly depends on how optimised are the scripts.
Title: Re: ? Best moments to save player's data
Post by: Sebastian on May 29, 2017, 12:17 AM
@PunkNoodle Yes, I will probably keep doing that.
Title: Re: ? Best moments to save player's data
Post by: Sebastian on May 29, 2017, 12:53 AM
I will add a poll to this topic, to see which variant îs the Best of Best.
But first, what variants should appear? 

One for sure should BE:
onPlayerPart + 25mins interval
Title: Re: ? Best moments to save player's data
Post by: KAKAN on May 29, 2017, 07:53 AM
Quote from: Doom_Kill3R on May 28, 2017, 10:18 PM
Quote from: . on May 28, 2017, 08:10 PM
Quote from: Doom_Kill3R on May 28, 2017, 07:28 PM...Then just remember to fix your broken scripts so it doesn't crash.

What if the server itself crashes? Not something rare here.

It doesn't crash itself. Atleast mine doesn't.
As far as I'm concerned, the official squirrel plugin has some memory releasing issues, which might crash your server in Linux OS, since it loves memory and doesn't let you harm it. But, ofcourse, it limits to how many timers you're using and how often you're creating and deleting them( I guess the problem lies there. )
Title: Re: ? Best moments to save player's data
Post by: Mötley on Jun 02, 2017, 12:38 AM
Sort and compare while a player is on the server, Find a safe way to store the players original data without needing to open the database.

This way if a player has a update of five kills, 3 additional deaths, and some other changed data you could save it every five minutes. Or whatever you desire while looping through the accounting data



Not fully recommending it but..
You could mix something like hashes or ini, If ini use the players password as the bracket, not the name due to clan tags breaking ini. This way you could have a debug log of accounts at all times.

Then you could do some command to sort and compare the database to the debugged log 'ini/hashes' of the accounts. You could find out if anything was fucked. If not just clear the file. No reason to make the server loop through a lot of data.

You could do that in any safer method.
Just putting thoughts out.

Sort and compare is what I typically do, If there are no changes why do anything.
Title: Re: ? Best moments to save player's data
Post by: aXXo on Jun 02, 2017, 09:58 PM
From my practical VCMP experience, I'd recommend not to bother too much about script/server lag. The average VCMP player lags like shit, so if there is a lag issue, the bottleneck is his own Internet connection/PC.

I've seen scripts writing data in a loop every second, with 20+ players online. No complains about lag(EAD).
In Vicewar, I INSERT'ed every kill straight to MySQL. The event had 25k kills in 24 hours with 45 players average online. Players were so busy FPS lagging, that no-one complaint about script lag(if any).
Title: Re: ? Best moments to save player's data
Post by: Cool on Jun 03, 2017, 01:12 AM
Quote from: aXXo on Jun 02, 2017, 09:58 PMFrom my practical VCMP experience, I'd recommend not to bother too much about script/server lag. The average VCMP player lags like shit, so if there is a lag issue, the bottleneck is his own Internet connection/PC.

I've seen scripts writing data in a loop every second, with 20+ players online. No complains about lag(EAD).
In Vicewar, I INSERT'ed every kill straight to MySQL. The event had 25k kills in 24 hours with 45 players average online. Players were so busy FPS lagging, that no-one complaint about script lag(if any).
AXXO you are wrong Vicewar script was lagging like hell
Title: Re: ? Best moments to save player's data
Post by: Xmair on Jun 03, 2017, 06:08 AM
Quote from: CoolAXXO you are wrong Vicewar script was lagging like hell
Says the one with 300 ping.
Title: Re: ? Best moments to save player's data
Post by: KAKAN on Jun 03, 2017, 06:44 AM
Quote from: Cool on Jun 03, 2017, 01:12 AMAXXO you are wrong Vicewar script was lagging like hell
Ever checked your packet loss?

Quote from: aXXo on Jun 02, 2017, 09:58 PMFrom my practical VCMP experience, I'd recommend not to bother too much about script/server lag. The average VCMP player lags like shit, so if there is a lag issue, the bottleneck is his own Internet connection/PC.

I've seen scripts writing data in a loop every second, with 20+ players online. No complains about lag(EAD).
In Vicewar, I INSERT'ed every kill straight to MySQL. The event had 25k kills in 24 hours with 45 players average online. Players were so busy FPS lagging, that no-one complaint about script lag(if any).
Agreed.
Title: Re: ? Best moments to save player's data
Post by: DizzasTeR on Jun 03, 2017, 11:35 AM
I recently moved to @aXXo 's method as well. Just update everything into mysql whenever its needed. I don't know if it has any issues with SQLite.
Title: Re: ? Best moments to save player's data
Post by: . on Jun 03, 2017, 12:04 PM
Quote from: Doom_Kill3R on Jun 03, 2017, 11:35 AMI don't know if it has any issues with SQLite.

The only time you'll have issues with that are on servers from providers that oversell their services. I've seen these to go so slow to the point where you read with a few kb/s from their storage. My internet connection had faster speeds. So yeah, in those cases, your server is going to lag regardless of where you decide to save.

Which is why you should look for server providers with SSD storage. Regardless of how little storage they provide. Because you need speed not space. For example, on my VPS I get around 1 gb/s R/W speeds (probably some NVMe sh!t). Obviously I can save wherever and whenever I want.

Or, I've seen people using MySQL databases on remote servers. Basically, they send their stuff to a remote MySQL server via a TCP connection. So on top of the disk lag you also add the network lag. And then come here and complain their servers are slow af.

And I haven't even started the on sh!tty code that some people write. Creating timers that run every frame or listening to player/vehicle movement events and doing various useless computation there. I've seen people doing database queries and then checking if they actually needed to do that database query. I was like: wtf?

When you save your data, has an insignificant role compared to the significance of writing efficient code and designing the database in a way that allows you to distribute the workload evenly throughout the runtime of a server. Stop chasing butterflies people. This isn't the bottleneck you're looking for.

Basically, what I'm trying to say is that where and how you save the data plays a much bigger role then when you save it.