open.mp forum
[Server] Duplicate CallBack call - Printable Version

+- open.mp forum (https://forum.open.mp)
+-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
+--- Forum: Support (https://forum.open.mp/forumdisplay.php?fid=12)
+--- Thread: [Server] Duplicate CallBack call (/showthread.php?tid=1786)



Duplicate CallBack call - RhaegarX - 2021-03-19

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).

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?


RE: Duplicate CallBack call - Kodokushi - 2021-03-19

Code:
public OnGameModeExit() { ON_GAMEMODE_EXIT_SAVE = true; // ..SAVE return true } public OnPlayerDisconnect(playerid, reason) { if(ON_GAMEMODE_EXIT_SAVE == true) return false; // ..SAVE return true; }


I don't know if the values of the variables are kept after gmx, I never used that
If they are, you will have to modify the variable in OnGamemodeInit setting as 'false'.


RE: Duplicate CallBack call - RhaegarX - 2021-03-19

(2021-03-19, 05:02 PM)Kodokushi Wrote:
Code:
public OnGameModeExit() { ? ? ON_GAMEMODE_EXIT_SAVE = true; ? ? // ..SAVE ? ? return true } public OnPlayerDisconnect(playerid, reason) { ? ? if(ON_GAMEMODE_EXIT_SAVE == true) ? ? ? ? return false; ? ? // ..SAVE ? ? return true; }





I don't know if the values of the variables are kept after gmx, I never used that

If they are, you will have to modify the variable in OnGamemodeInit setting as 'false'.



When the player disconnects I save the data and reset the variables.


RE: Duplicate CallBack call - Pinch - 2021-03-19

For starters, dont use /gmx as it's unstable af



Use /rcon exit than start the server again.



Also, try on blank gm if the OPDC is called when you do /rcon gmx or /rcon exit, ion remember


RE: Duplicate CallBack call - RhaegarX - 2021-03-19

(2021-03-19, 05:47 PM)Pinch Wrote: For starters, dont use /gmx as it's unstable af

Use /rcon exit than start the server again.

Also, try on blank gm if the OPDC is called when you do /rcon gmx or /rcon exit, ion remember

Yes. I tested it on an empty gamemode and OnPlayerDisconnect is also being called when OnGameModeExit and / rcon gmx is called

[Image: hdDlyns.png]

[Image: bhBfw7k.png]

[Image: 1wNbZAh.png]

Would that make saving on OnGameModeExit useless?


RE: Duplicate CallBack call - Pinch - 2021-03-19

(2021-03-19, 06:06 PM)RhaegarX Wrote:
(2021-03-19, 05:47 PM)Pinch Wrote: For starters, dont use /gmx as it's unstable af



Use /rcon exit than start the server again.



Also, try on blank gm if the OPDC is called when you do /rcon gmx or /rcon exit, ion remember



Yes. I tested it on an empty gamemode and OnPlayerDisconnect is also being called when OnGameModeExit and / rcon gmx is called



[Image: hdDlyns.png]



[Image: bhBfw7k.png]



[Image: 1wNbZAh.png]



Would that make saving on OnGameModeExit useless?

Yes, don't save anything player-related OnGameModeExit then.


RE: Duplicate CallBack call - RhaegarX - 2021-03-20

(2021-03-19, 09:56 PM)Pinch Wrote:
(2021-03-19, 06:06 PM)RhaegarX Wrote:
(2021-03-19, 05:47 PM)Pinch Wrote: For starters, dont use /gmx as it's unstable af



Use /rcon exit than start the server again.



Also, try on blank gm if the OPDC is called when you do /rcon gmx or /rcon exit, ion remember



Yes. I tested it on an empty gamemode and OnPlayerDisconnect is also being called when OnGameModeExit and / rcon gmx is called



[Image: hdDlyns.png]



[Image: bhBfw7k.png]



[Image: 1wNbZAh.png]



Would that make saving on OnGameModeExit useless?

Yes, don't save anything player-related OnGameModeExit then.



Yes. I removed the save made on OnGameModeExit and everything works perfectly, OPDC is called when restarting the server and without duplicating the save


RE: Duplicate CallBack call - Pinch - 2021-03-20

Still, I don't recommend usage of /rcon gmx, fresh start is always my go-to


RE: Duplicate CallBack call - Y_Less - 2021-03-21

There's nothing wrong with gmx. Someone was claiming that on discord the other day as well with no proof or explanation. I don't know where these rumors come from, nor why people are so quick to believe them. If you think you've found a bug, document it reproducibly, otherwise stop spreading misinformation.


RE: Duplicate CallBack call - Pinch - 2021-03-21

(2021-03-21, 12:16 PM)Y_Less Wrote: There's nothing wrong with gmx. Someone was claiming that on discord the other day as well with no proof or explanation. I don't know where these rumors come from, nor why people are so quick to believe them. If you think you've found a bug, document it reproducibly, otherwise stop spreading misinformation.

Oh, sorry, someone very "knowledgeable" told me that actually so that's why I believed, like Illidan or someone like that idk