Hello i was looking all posts but in majority has not the same as the 12x otserv, we don't use globalevents.xml on this server,
I got a file called Server_save.lua , code:
On config.lua on server save i put like:
-- Server Save
-- NOTE: serverSaveNotifyDuration in minutes
serverSaveNotifyMessage = true
serverSaveNotifyDuration = 5
serverSaveCleanMap = true
serverSaveClose = false
serverSaveShutdown = false
Well global save at 08h , without close and shutdown.
But i want if was a script error or anything prevent a rollback in game, i try many saves scripts , for auto save each 1 hour, but not working, can anyone help me with this ? And get a simple message like Server Saved.
Thanks for your help
I got a file called Server_save.lua , code:
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())
-- Reset gamestore exp boost count.
db.query('UPDATE `player_storage` SET `value` = 0 WHERE `player_storage`.`key` = 51052')
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
local serversave = GlobalEvent("serversave")
function serversave.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
serversave:time("08:15:00")
serversave:register()
On config.lua on server save i put like:
-- Server Save
-- NOTE: serverSaveNotifyDuration in minutes
serverSaveNotifyMessage = true
serverSaveNotifyDuration = 5
serverSaveCleanMap = true
serverSaveClose = false
serverSaveShutdown = false
Well global save at 08h , without close and shutdown.
But i want if was a script error or anything prevent a rollback in game, i try many saves scripts , for auto save each 1 hour, but not working, can anyone help me with this ? And get a simple message like Server Saved.
Thanks for your help