SA-MP Forums Archive
OnPlayerDisconnect Callback - 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: OnPlayerDisconnect Callback (/showthread.php?tid=312025)



OnPlayerDisconnect Callback - Konstantinos - 19.01.2012

It saves only when player disconnect with reason 1 Left normally (/q or ESC menu and quit)
If the player crashed or kicked/banned, the data aren't saved.
Is there any way to check the reason like the part of code below and in the two cases to save the Player's Data?
pawn Код:
public OnPlayerDisconnect( playerid, reason )
{
    OnPlayerLogout( playerid ); // Save Player Data

    return 1;
}
pawn Код:
// Instead of Message to save the data| OnPlayerLogout( playerid ); |
    new
        LeavingMsg[ 64 ];

    switch( reason ) {
        case 0: format( LeavingMsg, sizeof( LeavingMsg ), "%s left the server. (Timed out)", GetName( playerid ) );
        case 1: format( LeavingMsg, sizeof( LeavingMsg ), "%s left the server. (Leaving)", GetName( playerid ) );
        case 2: format( LeavingMsg, sizeof( LeavingMsg ), "%s left the server. (Kicked/Banned)", GetName( playerid ) );
    }
    SendClientMessageToAll( COLOR_YELLOW, LeavingMsg );



Re: OnPlayerDisconnect Callback - milanosie - 19.01.2012

Make it save every 2 minutes with a timer? So the rollback wont be bigger then 2 minuts if someone crashes