Stats not saving after server restart - 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)
+--- Thread: Stats not saving after server restart (
/showthread.php?tid=376955)
Stats not saving after server restart -
kbalor - 12.09.2012
I'am using a server hosting and it restart every 5 hours or It depends what you want.
How to call OnPlayerDisconnect if I do restart?
On player disconnect I found this
pawn Код:
SavePlayerStats(playerid);
its really important coz it save every player stats once they leave the server. But its also important to call onplayerdisconnect it has everything.
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
KillTimer(MoneyTimer[playerid]);
Firedup[playerid] = 0;
if(AccInfo[playerid][LoggedIn] == 1)
SavePlayerStats(playerid);
if(udb_Exists(PlayerName2(playerid))) dUserSetINT(PlayerName2(playerid)).("Loggedin",0);
AccInfo[playerid][LoggedIn] = 0;
AccInfo[playerid][Level] = 0;
AccInfo[playerid][pVip] = 0;
AccInfo[playerid][Jailed] = 0;
AccInfo[playerid][pCaged] = 0;
AccInfo[playerid][MaxAdv] = 0;
AccInfo[playerid][Frozen] = 0;
AccInfo[playerid][Hide] = 0;
AccInfo[playerid][OnDuty] = 0;
AccInfo[playerid][pInvis] = 0;
AccInfo[playerid][pGps] = -1;
AccInfo[playerid][pSecondScore] = 0;
#if EnableTwoRcon == true
AccInfo[playerid][MaxRcon] = 0;
#endif
if(AccInfo[playerid][Jailed] == 1)
KillTimer( JailTimer[playerid] );
if(AccInfo[playerid][Frozen] == 1)
KillTimer( FreezeTimer[playerid] );
if(ServerInfo[Locked] == 1)
KillTimer( LockKickTimer[playerid] );
if(AccInfo[playerid][pCar] != -1) EraseVeh(AccInfo[playerid][pCar]);
//------------------------------------------------------------------------------
// Spectating
//------------------------------------------------------------------------------
for(new x=0; x<MAX_PLAYERS; x++)
if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && AccInfo[x][SpecID] == playerid)
AdvanceSpectate(x);
//------------------------------------------------------------------------------
#if EnableCamHack == true
if(AccInfo[playerid][InCamMod] == 1)
{
KillTimer(KeyTimer[playerid]);
AccInfo[playerid][InCamMod] = 0;
}
#endif
return 1;
}
Re: Stats not saving after server restart -
Roko_foko - 12.09.2012
You can kick them, or use OnPlayerDissconect(playerid,1); as a function
Re: Stats not saving after server restart -
Jeffry - 12.09.2012
Create a timer that saves the player's statistics every 30 seconds:
pawn Код:
public OnFilterScriptInit() //Or OnGameModeInit
{
SetTimer("SaveAll", 30000, 1);
return 1;
}
pawn Код:
forward SaveAll();
public SaveAll()
{
for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i) && !IsPlayerNPC(i)) SavePlayerStats(i);
return 1;
}
Then they will lose max. 30 seconds of their statistics, that's also a great feature in case your server crashes.
Before you make a restart, create a command which calls SaveAll(); again.
Re : Stats not saving after server restart -
Miro96 - 04.07.2013
nice tuto ,tnx
Re: Stats not saving after server restart -
ReVo_ - 04.07.2013
How you restart the server? Save stats when you restart the server (if you use a command or timer)