Quote:
Originally Posted by Jeffry
Hello sim_sima,
I suggest you to take a timer which saves the stats by a given amount of time. I am doing it this way too.
Add at TOP:
pawn Код:
#define SAVE_TIME 30 //Will save the stats every 30 seconds. new SaveTimer[MAX_PLAYERS] = {-1,...};
Add at OnPlayerConnect:
pawn Код:
SaveTimer[playerid] = SetTimerEx("SaveTheUser", SAVE_TIME*1000, 1, "d", playerid);
Add at OnPlayerDisconnect:
pawn Код:
if(SaveTimer[playerid] != -1) KillTimer(SaveTimer[playerid]); SaveTimer[playerid] = -1;
At OnGameModeExit:
pawn Код:
for(new i=0; i<MAX_PLAYERS; i++) { if(SaveTimer[i] != -1) { KillTimer(SaveTimer[i]); SaveTimer[i] = -1; } }
Add at bottom:
pawn Код:
forward SaveTheUser(playerid); public SaveTheUser(playerid) { SavePlayer(playerid); //Just change the SavePlayer(playerid) to your stats-saving-function. return 1; }
If you have any questions, feel free to ask.
Jeffry
|
Thank you. But what if the server crashes or shuts down?
The OnGameModeExit isn't called when server shut down or crash.