SA-MP Forums Archive
Set Timer for Saving?? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Set Timer for Saving?? (/showthread.php?tid=224951)



Set Timer for Saving?? - BlackWolf120 - 12.02.2011

hi,
just wondering.
I use dini to save the player data to a file.
It always saves when leaving (OnPlayerDisconnect).
But now id like to know if i should set a timer for saving.
Cause in case the server crashes the players progress wouldnt be saved right?
That could be very hard for some players playing for a long time without any break (disconnects).
But otherwise it could cause lag on my server, right?
So should i set a timer for every player to save e.g. every 20 mins?

Id be happy about some answers.

regards...


Re: Set Timer for Saving?? - Ash. - 12.02.2011

I do this, i have a 10 minute timer to save data, i also run a check on a 60 second timer that runs after the data save timer to make sure the players data corresponds to what was saved, and if not, it saves it over the incorrect data

It doesnt cause lag, i even run a timer to save server information to file, to be called by a website or a data request (to keep the actual server process free from extra processing)


Re: Set Timer for Saving?? - BlackWolf120 - 12.02.2011

ok thx for ur answer funky.
I think im gonna set up a kind of saving timer.
But id be happy if some more scripters could tell me their oppinions.

Btw: How/what system do u use for saving the server status and sending it to ur website?
Id like to do that to but i dont know how. Would be nice if u could give me a link or some hints.


Re: Set Timer for Saving?? - Ash. - 12.02.2011

Well, using DINI, i save the information (like max players) and save it to a file. I then use PHP to parse the INI file and echo to the website. It is currently not in action at the moment due to a refurbishment of my website, you can check out my "Player Check" script which runs on the same system

http://www.trucking-world.net/conten...t.php?name=Ash
[That "checks" my account]
Go to; http://www.trucking-world.net/content/scripts/check/ to see the form.


Re: Set Timer for Saving?? - BlackWolf120 - 12.02.2011

ok thx again


Re: Set Timer for Saving?? - Ash. - 12.02.2011

This may help, if you are intending on doing the same
http://uk2.php.net/manual/en/functio...e-ini-file.php


Re: Set Timer for Saving?? - BlackWolf120 - 12.02.2011

yep this helps thx funky!


Re: Set Timer for Saving?? - Mean - 12.02.2011

It would slow down the server for that few seconds it saves. Better use some faster method for saving like Y_Ini. But yes, I got a timer that runs every 5 minutes and saves all stats, on Y_Ini, and it doesn't make any Lag-Spikes.


Re: Set Timer for Saving?? - Ash. - 12.02.2011

Quote:
Originally Posted by Mean
Посмотреть сообщение
It would slow down the server for that few seconds it saves. Better use some faster method for saving like Y_Ini. But yes, I got a timer that runs every 5 minutes and saves all stats, on Y_Ini, and it doesn't make any Lag-Spikes.
Never had any problems or lag with dini either

(I need to switch to y_ini though, im starting to actually despise dini)


Re: Set Timer for Saving?? - Lorenc_ - 12.02.2011

Why 2 timers?
Theres no point in too, timers aren't suppose be repeated for just one small function, idk if you get me although, put the save player data thing inside another repeating timer you have currently got, running heaps of timers can get often laggy, i did something like this before:

pawn Код:
SetTimer("GlobalTimer", 1, true);

public GlobalTimer()
{
       new StatsTimer = 120000; //2 minutes
       StatsTimer--;
       if(StatsTimer == 0)
       {
              StatsTimer = 120000; // 2minutes again.
       }
}
Just make an variable with an amount of miliseconds then decrease it by one. Im really not sure if it'll lag. Didnt happen to me...