SlayingWorld
Active Member
As the title follows, i didn't want to leave my server save at every 24 hours to save. So i made an interval to save the server every hour just in case the server crashed or something like that. But every time the server saves, it kicks everyone out of the server, which is something i don't want. This is the code i have:
And this is how i have it in .xml
Is it normal for it to kick players on each save? Is the server meant to do that? Or is there a better code i can use?
Code:
local shutdownAtServerSave = false
local cleanMapAtServerSave = false
local function serverSave()
if shutdownAtServerSave then
Game.setGameState(GAME_STATE_SHUTDOWN)
else
Game.setGameState(GAME_STATE_CLOSED)
if cleanMapAtServerSave then
cleanMap()
end
Game.setGameState(GAME_STATE_NORMAL)
end
end
local function secondServerSaveWarning()
broadcastMessage("Server is saving game in one minute. Please move to a safe area.", MESSAGE_STATUS_WARNING)
addEvent(serverSave, 60000)
end
local function firstServerSaveWarning()
broadcastMessage("Server is saving game in 3 minutes. Please move to a safe area.", MESSAGE_STATUS_WARNING)
addEvent(secondServerSaveWarning, 120000)
end
function onThink(interval)
broadcastMessage("Server is saving game in 5 minutes. Please move to a safe area.", MESSAGE_STATUS_WARNING)
Game.setGameState(GAME_STATE_STARTUP)
addEvent(firstServerSaveWarning, 120000)
return not shutdownAtServerSave
end
And this is how i have it in .xml
Code:
<globalevent name="Server Save" interval="3600000" script="serversave.lua" />
Is it normal for it to kick players on each save? Is the server meant to do that? Or is there a better code i can use?