• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Global server save every 48 hour!

Steel Man

New Member
Joined
Jun 2, 2012
Messages
93
Reaction score
2
Hey otlanders,

Does anyone know how to make the server global save every 48 hours?
so the server will restart every 48 hours..

Thank you!
 
I'm not quite sure if this would work 100 percent correctly.

interval="172800000" = 48 * 60 * 60 * 1000 = 48 hours

XML:
<globalevent name="globalsave" interval="172800000" event="script" value="globalsave.lua"/>

Lua:
function prepareShutdown(minutes)    if(minutes <= 0) then
        doSetGameState(GAMESTATE_SHUTDOWN)
        return false
    end


    if(minutes == 1) then
        doBroadcastMessage("Server is going down in " .. minutes .. " minute for global save, please log out now!")
    elseif(minutes <= 3) then
        doBroadcastMessage("Server is going down in " .. minutes .. " minutes for global save, please log out.")
    else
        doBroadcastMessage("Server is going down in " .. minutes .. " minutes for global save.")
    end


    shutdownEvent = addEvent(prepareShutdown, 60000, minutes - 1)
    return true
end


function onThink(interval, lastExecution)
    return prepareShutdown(10) -- minutes to save and shutdown before time configured on globalevents.xml
end
 
Is possible to integrate an auto restart in console? Then we can enable/disable in config.lua

- - - Updated - - -

XML:
<globalevent name="globalsave" time="3:00" event="script" value="globalsave.lua"/>

Lua:
function prepareShutdown(minutes) if(minutes <= 0) then
        doSetGameState(GAMESTATE_SHUTDOWN)
        return false
    end
 
 
    if(minutes == 1) then
        doBroadcastMessage("Server is going down in " .. minutes .. " minute for global save, please log out now!")
    elseif(minutes <= 3) then
        doBroadcastMessage("Server is going down in " .. minutes .. " minutes for global save, please log out.")
    else
        doBroadcastMessage("Server is going down in " .. minutes .. " minutes for global save.")
    end
 
 
    shutdownEvent = addEvent(prepareShutdown, 60000, minutes - 1)
    return true
end


function onTime(interval)
	if os.date('%H') == "3" then
		return prepareShutdown(10)
	end
return TRUE
end

This way you can set WHICH HOUR you want to restart.
Default = 3h (dawn)
 
Last edited:
It was already set as function onTime in first place, just replaced it with onThink. :p

Setting it as 48:00 wouldn't work, would it? Since it's only 24 hours per day.
 
Is possible to integrate an auto restart in console? Then we can enable/disable in config.lua

- - - Updated - - -

XML:
<globalevent name="globalsave" time="3:00" event="script" value="globalsave.lua"/>



Lua:
function prepareShutdown(minutes) if(minutes <= 0) then
        doSetGameState(GAMESTATE_SHUTDOWN)
        return false
    end
 
 
    if(minutes == 1) then
        doBroadcastMessage("Server is going down in " .. minutes .. " minute for global save, please log out now!")
    elseif(minutes <= 3) then
        doBroadcastMessage("Server is going down in " .. minutes .. " minutes for global save, please log out.")
    else
        doBroadcastMessage("Server is going down in " .. minutes .. " minutes for global save.")
    end
 
 
    shutdownEvent = addEvent(prepareShutdown, 60000, minutes - 1)
    return true
end


function onTime(interval)
	if os.date('%H') == "3" then
		return prepareShutdown(10)
	end
return TRUE
end

This way you can set WHICH HOUR you want to restart.
Default = 3h (dawn)
Hey, thanks alot for posting here!
But is it possible to make it restart every 48 hours? I guess with this script its just
possible to make it every 24 hours, or am I totally wrong?

peace
 
Replace:
if os.date('%H') == "3" then

with:
if os.date('%H') == "3" and getWorldUpTime() > 24*60*60 then
 
XML:
<globalevent name="globalsave" time="3:00" event="script" value="globalsave.lua"/>

Lua:
function prepareShutdown(minutes) if(minutes <= 0) then
        doSetGameState(GAMESTATE_SHUTDOWN)
        return false
    end
 
 
    if(minutes == 1) then
        doBroadcastMessage("Server is going down in " .. minutes .. " minute for global save, please log out now!")
    elseif(minutes <= 3) then
        doBroadcastMessage("Server is going down in " .. minutes .. " minutes for global save, please log out.")
    else
        doBroadcastMessage("Server is going down in " .. minutes .. " minutes for global save.")
    end
 
 
    shutdownEvent = addEvent(prepareShutdown, 60000, minutes - 1)
    return true
end


function onTime(interval)
	if os.date('%H') == "3" and getWorldUpTime() > 24*60*60 then 
		return prepareShutdown(10)
	end
return TRUE
end
 
Back
Top