Stats not saving after server restart
#1

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;
}
Reply
#2

You can kick them, or use OnPlayerDissconect(playerid,1); as a function
Reply
#3

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.
Reply
#4

nice tuto ,tnx
Reply
#5

How you restart the server? Save stats when you restart the server (if you use a command or timer)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)