User data 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: User data saving (
/showthread.php?tid=256221)
User data saving -
sim_sima - 19.05.2011
Hi guys.
I have made a gamemode that saves and loads user data using Dini.
I thourght about makeing a timer that saves the user data every second, so that the data are not only saved when the player disconnects. Is this a good idea? If not, what could the alternative be?
Thank you.
Re: User data saving -
Raimis_R - 19.05.2011
For me the best variant its
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
switch(reason)
{
case 0: SaveData(playerid); // You'r function
case 1: SaveData(playerid); // You'r function
case 2: SaveData(playerid); // You'r function
}
return 1;
}
Re: User data saving -
sim_sima - 19.05.2011
Quote:
Originally Posted by Raimis_R
For me the best variant its
pawn Код:
public OnPlayerDisconnect(playerid, reason) { switch(reason) { case 0: SaveData(playerid); // You'r function case 1: SaveData(playerid); // You'r function case 2: SaveData(playerid); // You'r function } return 1; }
|
And what if the server restarts or he loses connection to the internet?
Re: User data saving -
Steve M. - 19.05.2011
It's better to save user's data when he disconnects. Because if you save user's data every second it could make lagg.
Quote:
Originally Posted by sim_sima
And what if the server restarts or he loses connection to the internet?
|
It will save user's data because OnPlayerDisconnect() callback will be call.
Re: User data saving -
Anzipane! - 19.05.2011
Well, I save player information every 60 seconds and it doesn't cause lagg at all.
Re: User data saving -
Raimis_R - 19.05.2011
Quote:
Originally Posted by sim_sima
And what if the server restarts or he loses connection to the internet?
|
So here is 3 reasons
Left Game
Kicked/Banned
Crashed
Re: User data saving -
Hiddos - 19.05.2011
Quote:
Originally Posted by Raimis_R
For me the best variant its
pawn Код:
public OnPlayerDisconnect(playerid, reason) { switch(reason) { case 0: SaveData(playerid); // You'r function case 1: SaveData(playerid); // You'r function case 2: SaveData(playerid); // You'r function } return 1; }
|
Or just:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
SaveData(playerid);
return 1;
}
Re: User data saving -
cessil - 19.05.2011
you should do both, but 1 second is too quick, maybe every 10 minutes
Re: User data saving -
sim_sima - 19.05.2011
Quote:
Originally Posted by Hiddos
Or just:
pawn Код:
public OnPlayerDisconnect(playerid, reason) { SaveData(playerid); return 1; }
|
I already did that, and it doesnt work when the server restarts, because OnPlayerDisconnect only gets called when the player disconnects.
Re: User data saving -
sim_sima - 19.05.2011
Ok, i tryed this:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
switch(reason)
{
case 0: SaveData(playerid); // You'r function
case 1: SaveData(playerid); // You'r function
case 2: SaveData(playerid); // You'r function
}
return 1;
}
Well, it totally fucks up. My script saves position, and when i spawn, i just die and get freezed, unable to move :S