In my gamemode I use mysql as a data saving system. Most of the player data I will save the moment it is changed to avoid problems in case of server crash or crash, and I also save the player data when restarting the server (/ gmx).
What I noticed is that when I restart the server, OnGameModeExit is saved and OnPlayerDisconnect is saved, doubling each player's save. For example: when I restart the server (/ gmx) the player's money is saved in OnGameModeExit and OnPlayerDisconnect, being saved 2 times without need.
How do I avoid this duplication of calls? Do I need to save player data on OnGameModeExit or just OnPlayerDisconnect?
Is OnPlayerDisconnect called by default by OnGameModeExit?
PHP Code:
public OnPlayerDisconnect()
{
Player_DestroyAllVehicles(playerid);
Player_SaveRanking(playerid);
Player_SaveConfig(playerid);
Player_SaveMoney(playerid);
? ? Player_SaveData(playerid);
? ? Player_ClearVars(playerid);
Player_ClearAcessories(playerid);
Player_ClearInfo(playerid);
Inventory_Reset(playerid);
}
PHP Code:
public OnGameModeExit()
{
foreach(new i : Player)
{
Player_DestroyAllVehicles(i);
Player_SaveRanking(i);
Player_SaveConfig(i);
Player_SaveMoney(i);
Player_SaveData(i);
Player_ClearVars(i);
Player_ClearAcessories(i);
Player_ClearInfo(i);
Inventory_Reset(i);
}
DestroyAllDynamicMapIcons();
DestroyAllDynamic3DTextLabels();
DestroyAllDynamicPickups();
mysql_close(ConexaoSQL);
return 1;
}
What I noticed is that when I restart the server, OnGameModeExit is saved and OnPlayerDisconnect is saved, doubling each player's save. For example: when I restart the server (/ gmx) the player's money is saved in OnGameModeExit and OnPlayerDisconnect, being saved 2 times without need.
How do I avoid this duplication of calls? Do I need to save player data on OnGameModeExit or just OnPlayerDisconnect?
Is OnPlayerDisconnect called by default by OnGameModeExit?