User stats saveing on server shutdown
#2

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
Reply


Messages In This Thread
User stats saveing on server shutdown - by sim_sima - 08.06.2011, 17:44
Re: User stats saveing on server shutdown - by Jeffry - 08.06.2011, 17:53
Re: User stats saveing on server shutdown - by sim_sima - 08.06.2011, 18:02
Re: User stats saveing on server shutdown - by Steven82 - 08.06.2011, 18:09
Re: User stats saveing on server shutdown - by Jack Shred - 08.06.2011, 18:10
Re: User stats saveing on server shutdown - by Jeffry - 08.06.2011, 18:12
Re: User stats saveing on server shutdown - by Steven82 - 08.06.2011, 18:16
Re: User stats saveing on server shutdown - by Jeffry - 08.06.2011, 18:42
Re: User stats saveing on server shutdown - by sim_sima - 08.06.2011, 19:00
Re: User stats saveing on server shutdown - by sim_sima - 09.06.2011, 10:43

Forum Jump:


Users browsing this thread: 1 Guest(s)