04.03.2011, 09:18
Because OnPlayerDisconnect can't be called when player time outs. You need to make a timer to save all players stats.
Later in script
Also, make sure you include a_npc,
You need it because the loop I made works like foreach, it excludes NPCs and skips non-connected players.
pawn Код:
// GameModeInit
SetTimer( "SaveStats", 120000, 1 ); // Saves all stats every 2 minutes.
pawn Код:
forward SaveStats( );
public SaveStats( )
{
for( new playerid = 0; playerid < MAX_PLAYERS; playerid++ ) if( IsPlayerConnected( playerid ) && !IsPlayerNPC( playerid ) )
{
// Your save code, from OnPlayerDisconnect goes here
}
return 1;
}
pawn Код:
#include < a_npc >