31.12.2013, 22:51
Guys how I can save stats when server turns off by exit rcon command? Using Y_INI
(btw, tried it in OnPlayerDisconnect not work)
(btw, tried it in OnPlayerDisconnect not work)
If you make a /exit command or something you can call your saving system to save all the players then use SendRconCommand("exit"); to then exit the gamemode
|
Yeah, thanks dude I need to put that timer to OnGameModeInit, right?
And wont it cause much cpu use? When I use that timer? |
public OnGameModeInit()
{
SetTimer("SaveAccs", 1000*120, true); //2 minute, repeating timer. I preferred 4-5 mins.
return 1;
}
forward SaveAccs();
public SaveAccs()
{
for(new i; i< GetMaxPlayers(); i++)
{
if(!IsPlayerConnected(i)) continue;
if(!IsPlayerLoggedIn(i)) continue;
SavePlayerStats(i); //The saving function.
}
return 1;
}
CMD:restart(playerid, params[])
{
//code (saving the stats)
SetTimer("RestartTimer",7000,0);
return 1;
}
forward RestartTimer();
public RestartTimer()
{
SendRconCommand("exit");
}