[HELP] Autosave when server crashes/shutdown. -
FuznesS - 15.04.2013
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 i = 0; i != 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.
Re : [HELP] Autosave when server crashes/shutdown. -
DaTa[X] - 15.04.2013
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:
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 ?
Re: [HELP] Autosave when server crashes/shutdown. -
iggy1 - 15.04.2013
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.
Re: [HELP] Autosave when server crashes/shutdown. -
FuznesS - 15.04.2013
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?
Re: [HELP] Autosave when server crashes/shutdown. -
iggy1 - 15.04.2013
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.
Re: [HELP] Autosave when server crashes/shutdown. -
Sithis - 15.04.2013
Instead of using rcon gmx to restart your gamemode, make a command that saves all players and then sendrconcommand gmx.
Re: [HELP] Autosave when server crashes/shutdown. -
FuznesS - 15.04.2013
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(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid) {
TogglePlayerSpectating(playerid, true);
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?
Re: [HELP] Autosave when server crashes/shutdown. -
Sithis - 15.04.2013
Never say impossible, however why would you want to do that?
Re: [HELP] Autosave when server crashes/shutdown. -
FuznesS - 15.04.2013
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?
AW: [HELP] Autosave when server crashes/shutdown. -
ulbi1990 - 15.04.2013
You know, that when the server crashes OnGameModeExit() doesn't get called?
You can test it on your localhost, just put
in the Callback and close the server process via Task Manager->Processes (simulates a server crash), than watch the server log.