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

Autosave.lua

Dorianek

Member
Joined
Nov 29, 2018
Messages
247
Reaction score
10
Location
Poland
Rich (BB code):
[Warning - Event::checkScript] Can not load script: scripts/autosave.lua
data/globalevents/scripts/autosave.lua:37: 'end' expected (to close 'function' at line 30) near <eof>


Can someone improve this script because I probably added something wrong

function onThink(interval, lastExecution)

I had this error [Warning - Event :: checkScript] Event onThink not found. scripts / save.lua

Rich (BB code):
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

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

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


function onThink(interval, lastExecution)
function onTime(interval)

    broadcastMessage("Server is saving game in 5 minutes. Please logout.", MESSAGE_STATUS_WARNING)
    Game.setGameState(GAME_STATE_STARTUP)
    addEvent(firstServerSaveWarning, 120000)
    return not shutdownAtServerSave
end

I know that there are two functions entered

function onThink (interval, lastExecution)
function onTime (interval)
but I do not know which one to use with my console error?

I had this error [Warning - Event :: checkScript] Event onThink not found. scripts / save.lua
 
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

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

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


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

If you have time instead of interval in the globalevents.xml then switch out line 30 for function onTime(interval)
 
Back
Top