• 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!

Setting up a server save system.

dominique120

Science & Reason
Senator
Premium User
Joined
Jun 16, 2013
Messages
3,881
Solutions
3
Reaction score
1,043
Location
Númenor
I would like to have a script that saves every 2 or so hours like on many OT servers,but, I would also like o have a weekly globalsave that restarts the server to load any bug fixes and new stuff.

Is this possible?

I have this save script ruining but I never see a save or a broadcast, so something may be wrong with it.

Register in globalevents:

Code:
<globalevent name="save" interval="1400000" event="script" value="save.lua"/>

Script:
Code:
local config = {
    broadcast = "yes"
}

config.broadcast = getBooleanFromString(config.broadcast)
local function executeSave(seconds)
    if(seconds == 0) then
        doSaveServer()
        return true
    end

    if(seconds == 120 or seconds == 30) then
        doBroadcastMessage("Full server save within " .. seconds .. " seconds, please stay in safe place!")
    end

    seconds = seconds - 30
    if(seconds >= 0) then
        addEvent(executeSave, 30 * 1000, seconds)
    end
end

function onThink(interval, lastExecution, thinkInterval)
    if(not config.broadcast) then
        doSaveServer()
        return true
    end

    executeSave(120)
    return true
end

I also have a clean but I think this is also broken.

Script:
Code:
function executeClean()
    doCleanMap()
    doBroadcastMessage("Clean done. Next clean in 2 hours.")
    return true
end

function onThink(interval)
    doBroadcastMessage("Cleanup in 30 seconds, pick up your stuff!")
    addEvent(executeClean, 40000)
    return true
end

Register in globalevents:
Code:
<globalevent name="clean" interval="7200000" event="script" value="clean.lua"/>

Thanks!
 
This script cleans and saves the server. Every day at the scheduled time.
Script
Code:
local config = {
times = {"05:00"}, -- Time that the server will close
minutes = 50 -- How many minutes remain closed for cleaning and save
}
function CloseAndSave()
if doSetGameState(GAMESTATE_CLOSED) then
addEvent(doCleanMap,1*60*1000)
end
doSaveServer(false)
addEvent(doSetGameState, config.minutes*60*1000, GAMESTATE_NORMAL)
end
function onThink(interval, lastExecution)
if isInArray(config.times, tostring(os.date("%X")):sub(1, 5)) then
doBroadcastMessage("The server will be closed to be safe and clean, will be right back in "..config.minutes.." minutes Thanks!")
addEvent(CloseAndSave, 1*60*1000)
end
return true
end

Tag:
Code:
<globalevent name="SaveAndClose" interval="60" event="script" value="saveclean.lua"/>

He makes the Rescue and Cleanup Map 5:00 in the morning every day.
Hope this helps.
A big hug and be with God!
 
Back
Top