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

TFS 1.X+ 1.2 save server without shutdown and closeserver

Svira

Active Member
Joined
Jan 27, 2008
Messages
263
Solutions
11
Reaction score
35
Hello, why my script closing server on first massage and open server 1min after save? When somebody enter see "Server grtting started" and must wait...

Code:
local shutdownAtServerSave = false
local cleanMapAtServerSave = false

local function serverSave()
    if shutdownAtServerSave then
        Game.setGameState(GAME_STATE_SHUTDOWN)
    else
        Game.setGameState(GAME_STATE_NORMAL)
    end

    if cleanMapAtServerSave then
        cleanMap()
    end

    saveServer()
end

local function secondServerSaveWarning()
    Game.broadcastMessage('Server is saving game in one minute.', MESSAGE_STATUS_WARNING)
    addEvent(serverSave, 60000)
end

local function firstServerSaveWarning()
    Game.broadcastMessage('Server is saving game in 3 minutes.', MESSAGE_STATUS_WARNING)
    addEvent(secondServerSaveWarning, 120000)
end

function onThink(interval, lastExecution)
    Game.broadcastMessage('Server is saving game in 5 minutes.', MESSAGE_STATUS_WARNING)
    Game.setGameState(GAME_STATE_STARTUP)
    addEvent(firstServerSaveWarning, 120000)
    return not shutdownAtServerSave
end

I need simply auto save server. Without c++ i Have auto save on close but need simple script...
 
Then this isn't the script you're using. There is no shutdown because you clearly have it set to false.
 
Can anyone help me?
Every minute I have a message about saving the server, it's terrible
a red message appears every minute, starting at 3500min ...

I would like to change the displayed message
-Server is saving game in 60 minute(s). Please logout.
-Server is saving game in 5 minute(s). Please logout.
-Server is saving game in 1 minute(s). Please logout!.

What do I need to change?

I use TFS 1.3
and this is my serversave.lua
Code:
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)
    end
    -- Updating daily reward next server save.
    updateGlobalStorage(DailyReward.storages.lastServerSave, os.time())
end

local function ServerSaveWarning(time)
    -- minus one minutes
    local remaningTime = tonumber(time) - 60000
    if configManager.getBoolean(configKeys.SERVER_SAVE_NOTIFY_MESSAGE) then
        Game.broadcastMessage("Server is saving game in " .. (remaningTime/60000) .."  minute(s). Please logout.", MESSAGE_STATUS_WARNING)
    end
    -- if greater than one minute, schedule another warning
    -- else the next event will be the server save
    if remaningTime > 60000 then
        addEvent(ServerSaveWarning, 60000, remaningTime)
    else
        addEvent(ServerSave, 60000)
    end
end

-- Function that is called by the global events when it reaches the time configured
-- interval is the time between the event start and the the effective save, it will send an notify message every minute
function onTime(interval)
    local remaningTime = configManager.getNumber(configKeys.SERVER_SAVE_NOTIFY_DURATION) * 60000
    if configManager.getBoolean(configKeys.SERVER_SAVE_NOTIFY_MESSAGE) then
        Game.broadcastMessage("Server is saving game in " .. (remaningTime/60000) .."  minute(s). Please logout.", MESSAGE_STATUS_WARNING)
    end
    addEvent(ServerSaveWarning, 60000, remaningTime)    -- Schedule next event in 1 minute(60000)
    return not configManager.getBoolean(configKeys.SERVER_SAVE_SHUTDOWN)
end
 
Hello, why my script closing server on first massage and open server 1min after save? When somebody enter see "Server grtting started" and must wait...

Code:
local shutdownAtServerSave = false
local cleanMapAtServerSave = false

local function serverSave()
    if shutdownAtServerSave then
        Game.setGameState(GAME_STATE_SHUTDOWN)
    else
        Game.setGameState(GAME_STATE_NORMAL)
    end

    if cleanMapAtServerSave then
        cleanMap()
    end

    saveServer()
end

local function secondServerSaveWarning()
    Game.broadcastMessage('Server is saving game in one minute.', MESSAGE_STATUS_WARNING)
    addEvent(serverSave, 60000)
end

local function firstServerSaveWarning()
    Game.broadcastMessage('Server is saving game in 3 minutes.', MESSAGE_STATUS_WARNING)
    addEvent(secondServerSaveWarning, 120000)
end

function onThink(interval, lastExecution)
    Game.broadcastMessage('Server is saving game in 5 minutes.', MESSAGE_STATUS_WARNING)
    Game.setGameState(GAME_STATE_STARTUP)
    addEvent(firstServerSaveWarning, 120000)
    return not shutdownAtServerSave
end

I need simply auto save server. Without c++ i Have auto save on close but need simple script...

Game.setGameState(GAME_STATE_STARTUP) <--- this line at 'function onThink(interval, lastExecution)' refuses connection... this prevents players to connect to game while server is preparing to 'close' even if you have set "shutdown = false"
but I don't understand, what do you want really...
If you want to stop refusing conections and continue playing without shutdown, I suggest you to use this script:

Lua:
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


function onThink(interval)
    addEvent(saveData, 1000)
    return not shutdownAtServerSave
end

and this on globalevents.xml
<globalevent name="Progress Saving" interval="600000" script="saveprogress.lua" />
 
Last edited:
Game.setGameState(GAME_STATE_STARTUP) <--- this line at 'function onThink(interval, lastExecution)' refuses connection... this prevents players to connect to game while server is preparing to 'close' even if you have set "shutdown = false"
but I don't understand, what do you want really...
If you want to stop refusing conections and continue playing without shutdown, I suggest you to use this script:

Lua:
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


function onThink(interval)
    addEvent(saveData, 1000)
    return not shutdownAtServerSave
end

and this on globalevents.xml
<globalevent name="Progress Saving" interval="600000" script="saveprogress.lua" />

So if I want the server to save and be on all the time then I have to delete my serversave.lua file and add saveprogress.lua?
 
So if I want the server to save and be on all the time then I have to delete my serversave.lua file and add saveprogress.lua?
oh not sure if it works for 1.3 bro, that's for tfs 1.2... I was giving the solution for @Svira but I just realized the date of the topic lol...
 
Back
Top