diff --git a/data/globalevents/scripts/serversave.lua b/data/globalevents/scripts/serversave.lua index f6210abf28..5a2c95638c 100644 --- a/data/globalevents/scripts/serversave.lua +++ b/data/globalevents/scripts/serversave.lua @@ -1,14 +1,21 @@ local function ServerSave() - if configManager.getBoolean(configKeys.SERVER_SAVE_CLEAN_MAP) then - cleanMap() - end - - if configManager.getBoolean(configKeys.SERVER_SAVE_CLOSE) then - Game.setGameState(GAME_STATE_CLOSED) - end - if configManager.getBoolean(configKeys.SERVER_SAVE_SHUTDOWN) then Game.setGameState(GAME_STATE_SHUTDOWN) + else + local closeAtServerSave = configManager.getBoolean(configKeys.SERVER_SAVE_CLOSE) + if closeAtServerSave then + Game.setGameState(GAME_STATE_CLOSED) + end + + saveServer() + + if configManager.getBoolean(configKeys.SERVER_SAVE_CLEAN_MAP) then + cleanMap() + end + + if closeAtServerSave then + Game.setGameState(GAME_STATE_NORMAL) + end end end