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

Server Save

Hahstudios

New Member
Joined
Mar 11, 2010
Messages
49
Solutions
3
Reaction score
1
Im having an issue with my server save for some akward reason its not working at all.
and as of the new tfs it isnt in the config file anymore.
im using tfs v1.2
HTML:
    <globalevent name="save" interval="100" event="script" value="serversave.lua"/>

HTML:
local config = {
    broadcast = {30},
    shallow = "no",
    delay = 120,
    events = 30
}

config.shallow = getBooleanFromString(config.shallow)

local function executeSave(seconds)
    if(isInArray(config.broadcast, seconds)) then
        local text = ""
        if(not config.shallow) then
            text = "Full s"
        else
            text = "S"
        end

        text = text .. "erver save within " .. seconds .. " seconds, please mind it may freeze!"
        doBroadcastMessage(text)
    end

    if(seconds > 0) then
        addEvent(executeSave, config.events * 1000, seconds - config.events)
    else
        doSaveServer(config.shallow)
    end
end

function onThink(interval, lastExecution, thinkInterval)
    if(table.maxn(config.broadcast) == 0) then
        doSaveServer(config.shallow)
    else
        executeSave(config.delay)
    end

    return true
end
plz help
 
Solution
globalevents.xml
60 * 60 * 1000 = 1h
Code:
<globalevent interval="1200000" name="autoSave" script="autosave.lua"/>

autosave.lua
Code:
function onThink(interval)
    saveServer()

    return true
end

You can add timers etc, but thats how base looks.

example:

Code:
local function savingServer()
    saveServer()
    Game.broadcastMessage('Server was sucessfully saved, next save in 20 minutes.', MESSAGE_STATUS_DEFAULT)
end

function onThink(interval)
    Game.broadcastMessage('Server will automatically save current state in 30 seconds, it may cause freeze.', MESSAGE_STATUS_DEFAULT)
    addEvent(savingServer, 30000)
    return true
end
im getting 0 log errors its like its not even activating for some reason but its in my global events as you can see there im stumped.
 
Your globalevent.xml is wrong.

example:
Code:
<globalevent name="ServerSave" time="9:55:00" script="serversave.lua" />
<globalevent name="x" interval="3000000" script="x.lua" />
 
How do you want the script to work, do you want server save like on real tibia or just save current progress every x minutes?
I will write it for you, because we will waste time like this.
 
globalevents.xml
60 * 60 * 1000 = 1h
Code:
<globalevent interval="1200000" name="autoSave" script="autosave.lua"/>

autosave.lua
Code:
function onThink(interval)
    saveServer()

    return true
end

You can add timers etc, but thats how base looks.

example:

Code:
local function savingServer()
    saveServer()
    Game.broadcastMessage('Server was sucessfully saved, next save in 20 minutes.', MESSAGE_STATUS_DEFAULT)
end

function onThink(interval)
    Game.broadcastMessage('Server will automatically save current state in 30 seconds, it may cause freeze.', MESSAGE_STATUS_DEFAULT)
    addEvent(savingServer, 30000)
    return true
end
 
Solution
so im a bit new to the scripting game but trying to learn as much as possible ofc. so should i change the bool save to true?
 
Back
Top