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

globalsave and shutdown server

PuszekLDZ

https://tibia74.eu
Premium User
Joined
Jan 2, 2020
Messages
329
Solutions
1
Reaction score
85
Location
Lodz
I got problem with a globalsave and closing server at XX:XX hour...

Im using The OTX Server Version: (3.9 . DEV) - Codename: ( VANXI ) from @MartyX

I tried to use some script.. .but it wont work at all..

In config.lua isnt any of that lines to set save and shutdown and in globalactions was only a "serverSave" on 2h delay...

maybe anyone got solution fo that? hmm? @MartyX ?

thanks anyway :) i hope some one could help me or tell me where to look at it...
 
Solution
No, try replacing the script with the last one that I wrote, you said you edited the 60000, right?

If it doesn't work, use this one
Lua:
local shutdown = true
local clean = false
local closeServer = false
local minutes = 5 -- Min 1 minute
local notify = true

local function ServerSave()
    if shutdown then
        Game.setGameState(GAME_STATE_SHUTDOWN)
    else
    if clean then
        cleanMap()
    end
    if closeServer then
        Game.setGameState(GAME_STATE_CLOSED)
    end
    end
end

local function ServerSaveWarning(time)
    local remaningTime = tonumber(time) - 60000
    if notify then
local remainingNotifier = (remaningTime/60000) > 1 and (remaningTime/60000) or 1
        Game.broadcastMessage("Server is saving game in "...
my globalevents
XML:
<?xml version="1.0" encoding="UTF-8"?>
<globalevents>
    <globalevent type="startup" name="ServerStartup" script="startup.lua" />
    <globalevent type="record" name="PlayerRecord" script="record.lua" />

    <!-- Save 15 minutes / Clean 2 hours / Restart 06:00 -->
    <globalevent name="Server Save" interval="900000" script="serversave.lua" />
    <globalevent name="Clean Map" interval="7200000" script="cleanmap.lua" />
    <globalevent name="Server Save" time="20:26:00" script="server_save.lua" />
</globalevents>

server save (for restart)
Lua:
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
end

local function ServerSaveWarning(time)
    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 remaningTime > 60000 then
        addEvent(ServerSaveWarning, 60000, remaningTime)
    else
        addEvent(ServerSave, 60000)
    end
end

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)
    return not configManager.getBoolean(configKeys.SERVER_SAVE_SHUTDOWN)
end

and just server save (on 15min interval)
Lua:
function onThink(interval)
    saveServer()
    return true
end

with this setup i got something like this
lol_time.png
 
remove
globalSaveEnabled = yes
from config.lua

there is no such thing in config lua
thats a config lua part:
Lua:
-- Server Save
-- NOTE: serverSaveNotifyDuration in minutes
serverSaveNotifyMessage = true
serverSaveNotifyDuration = 5
serverSaveCleanMap = false
serverSaveClose = false
serverSaveShutdown = true
 
serverSaveNotifyMessage = true
serverSaveNotifyDuration = 24 * 60 * 60 --- every one day
serverSaveCleanMap = false
serverSaveClose = false
serverSaveShutdown = false

and edit this line
local remaningTime = configManager.getNumber(configKeys.SERVER_SAVE_NOTIFY_DURATION)
if configManager.getBoolean(configKeys.SERVER_SAVE_NOTIFY_MESSAGE) then
Game.broadcastMessage("Server is saving game in " .. (remaningTime) .." minute(s). Please logout.", MESSAGE_STATUS_WARNING)
end
 
@heba thanks a lot mate!!!!

serverSaveNotifyMessage = true
serverSaveNotifyDuration = 24 * 60 * 60 --- every one day
serverSaveCleanMap = false
serverSaveClose = false
serverSaveShutdown = false

and edit this line
local remaningTime = configManager.getNumber(configKeys.SERVER_SAVE_NOTIFY_DURATION)
if configManager.getBoolean(configKeys.SERVER_SAVE_NOTIFY_MESSAGE) then
Game.broadcastMessage("Server is saving game in " .. (remaningTime) .." minute(s). Please logout.", MESSAGE_STATUS_WARNING)
end

it working... i mean server is going down.. but i get that msg broadcasted
lol_time2.png

--- maybe You can help me that way...
I want to server to be closed and shutdown at 06:00:00 and for that i want to get 5 min broadcast:
-server is goind down in 5min .... 4min .... 3 min etc.
 
try this one
 
try this one

didnt work for me...
Post automatically merged:

edit:
i found that, no matter what i change in script (time) it will broadcast sick ammount of minutes
but it always shutdow in 2 min (each msg with 1 minute delay)
and after 2 minutes it save and shutdown...
i tried various numbers (changing that 60000 ammount) and it wont work... always close after 2min
 
Last edited:
Change
Lua:
serverSaveNotifyDuration = 24 * 60 * 60 --- every one day
To
Lua:
serverSaveNotifyDuration = 5

That value isn't the interval for the server save

Lua:
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
 
i got that
Lua:
serverSaveNotifyDuration = 5

and it wasnt work too

could it be something wrong with compilation?
 
No, try replacing the script with the last one that I wrote, you said you edited the 60000, right?

If it doesn't work, use this one
Lua:
local shutdown = true
local clean = false
local closeServer = false
local minutes = 5 -- Min 1 minute
local notify = true

local function ServerSave()
    if shutdown then
        Game.setGameState(GAME_STATE_SHUTDOWN)
    else
    if clean then
        cleanMap()
    end
    if closeServer then
        Game.setGameState(GAME_STATE_CLOSED)
    end
    end
end

local function ServerSaveWarning(time)
    local remaningTime = tonumber(time) - 60000
    if notify then
local remainingNotifier = (remaningTime/60000) > 1 and (remaningTime/60000) or 1
        Game.broadcastMessage("Server is saving game in " .. remainingNotifier .."  minute(s). Please logout.", MESSAGE_STATUS_WARNING)
    end

    if remaningTime > 60000 then
        addEvent(ServerSaveWarning, 60000, remaningTime)
    else
        addEvent(ServerSave, 60000)
    end
end

function onTime(interval)
    if notify then
        Game.broadcastMessage("Server is saving game in " .. (minutes) .."  minute(s). Please logout.", MESSAGE_STATUS_WARNING)
    end
    addEvent(ServerSaveWarning, 60000, minutes * 60000)
    return not shutdown
end
 
Last edited:
Solution
OMG @Hyresu You are fc*n code god :)
Thanks a lot :)
Love Ya of all my heart 😍

No, try replacing the script with the last one that I wrote, you said you edited the 60000, right?

If it doesn't work, use this one
Lua:
local shutdown = true
local clean = false
local closeServer = false
local minutes = 5 -- Min 1 minute
local notify = true

local function ServerSave()
    if shutdown then
        Game.setGameState(GAME_STATE_SHUTDOWN)
    else
    if clean then
        cleanMap()
    end
    if closeServer then
        Game.setGameState(GAME_STATE_CLOSED)
    end
    end
end

local function ServerSaveWarning(time)
    local remaningTime = tonumber(time) - 60000
    if notify then
local remainingNotifier = (remaningTime/60000) > 1 and (remaningTime/60000) or 1
        Game.broadcastMessage("Server is saving game in " .. remainingNotifier .."  minute(s). Please logout.", MESSAGE_STATUS_WARNING)
    end

    if remaningTime > 60000 then
        addEvent(ServerSaveWarning, 60000, remaningTime)
    else
        addEvent(ServerSave, 60000)
    end
end

function onTime(interval)
    if notify then
        Game.broadcastMessage("Server is saving game in " .. (minutes) .."  minute(s). Please logout.", MESSAGE_STATUS_WARNING)
    end
    addEvent(ServerSaveWarning, 60000, minutes * 60000)
    return not shutdown
end
 
Back
Top