Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Support [Server] Duplicate CallBack call

 
  • 0 Vote(s) - 0 Average
Server Duplicate CallBack call
RhaegarX
Offline

Burgershot Member
Posts: 66
Threads: 12
Joined: Nov 2020
Reputation: 4
#1
2021-03-19, 04:45 PM (This post was last modified: 2021-03-19, 04:47 PM by RhaegarX.)
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?
Kodokushi
Offline

Burgershot Member
Posts: 3
Threads: 1
Joined: Mar 2021
Reputation: 0
#2
2021-03-19, 05:02 PM (This post was last modified: 2021-03-19, 05:04 PM by Kodokushi.)
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'.
RhaegarX
Offline

Burgershot Member
Posts: 66
Threads: 12
Joined: Nov 2020
Reputation: 4
#3
2021-03-19, 05:15 PM
(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.
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#4
2021-03-19, 05:47 PM
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
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
RhaegarX
Offline

Burgershot Member
Posts: 66
Threads: 12
Joined: Nov 2020
Reputation: 4
#5
2021-03-19, 06:06 PM (This post was last modified: 2021-03-19, 06:09 PM by RhaegarX.)
(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?
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#6
2021-03-19, 09:56 PM
(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.
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
RhaegarX
Offline

Burgershot Member
Posts: 66
Threads: 12
Joined: Nov 2020
Reputation: 4
#7
2021-03-20, 04:33 PM
(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
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#8
2021-03-20, 08:55 PM
Still, I don't recommend usage of /rcon gmx, fresh start is always my go-to
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#9
2021-03-21, 12:16 PM
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.
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#10
2021-03-21, 05:42 PM
(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
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode