[HELP] Autosave when server crashes/shutdown.
#1

Hey I'm working on Calgon base mysql script and I'm trying to make autosave in OnGameModeExit
like when the server crashes or shutdown by closing the CMD window or by using /rcon gmx
its will automatic save the player data.

I tried to do this:
PHP код:
OnGameModeExit() {
    for (new 
0!= MAX_PLAYERS; ++i)
    {
        
savePlayer(i);
    }
    
mysql_close(iConnectionHandle);
    return 
1;

and when I'm login its spawn me at the air above the farm at blueberry.
anyone can help me please?

Thanks FuznesS.
Reply
#2

Quote:
Originally Posted by FuznesS
Посмотреть сообщение
Hey I'm working on Calgon base mysql script and I'm trying to make autosave in OnGameModeExit
like when the server crashes or shutdown by closing the CMD window or by using /rcon gmx
its will automatic save the player data.

I tried to do this:
PHP код:
 
and when I'm login its spawn me at the air above the farm at blueberry.
anyone can help me please?

Thanks FuznesS.
You want to save your position when the server crash/close ?
Reply
#3

You can't save on a crash.

But instead of putting that code in OnGameModeExit put it in OnPlayerDisconnect, since players disconnect before OnGameModeExit is called (IIRC). This will save player data when the server is closed, not crashed.
Reply
#4

I already got it in OnPlayerDisconnect, but I want when I'm using /rcon gmx they're spawn on the air.
So I want to fix that, and make save the players stats,
there is no way to save the players data by OnGameModeExit?
Reply
#5

If all your player variables still hold the correct values you should be able to save in OnGameModeExt, but keep in mind PVars reset when a player disconnects.

EDIT: You could set the players camera position somewhere else until you spawn them properly.
Reply
#6

Instead of using rcon gmx to restart your gamemode, make a command that saves all players and then sendrconcommand gmx.
Reply
#7

Quote:
Originally Posted by iggy1
Посмотреть сообщение
If all your player variables still hold the correct values you should be able to save in OnGameModeExt, but keep in mind PVars reset when a player disconnects.

EDIT: You could set the players camera position somewhere else until you spawn them properly.
Like this?
PHP код:
public OnPlayerRequestClass(playeridclassid)
{
    
SetPlayerPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraLookAt(playerid1958.37831343.157215.3746);
    return 
1;
}
public 
OnPlayerConnect(playerid) {
    
TogglePlayerSpectating(playeridtrue);
    return 
1;

and when the players successful login its will spawn him.

Quote:
Originally Posted by Sithis
Посмотреть сообщение
Instead of using rcon gmx to restart your gamemode, make a command that saves all players and then sendrconcommand gmx.
I already got one, but that impossible to save the player data when I'm closing the CMD window?
Reply
#8

Never say impossible, however why would you want to do that?
Reply
#9

Quote:
Originally Posted by Sithis
Посмотреть сообщение
Never say impossible, however why would you want to do that?
I have a question, if someone attacking my server or I close the server CMD window
when the server shutdown it will save my players data?
Reply
#10

You know, that when the server crashes OnGameModeExit() doesn't get called?

You can test it on your localhost, just put
pawn Код:
print("crash");
in the Callback and close the server process via Task Manager->Processes (simulates a server crash), than watch the server log.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)