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

Lua [TFS 1.0] Serversave OnThink

Romantix

Omnipotent
Joined
Apr 27, 2010
Messages
131
Reaction score
2
Location
Australia
Hello Otland,

I have an issue here with my serversave for TFS 1.0.

I am going to assume the function OnThink has not been compiled with my version of TFS 1.0 but I was hoping someone could confirm what this error message might mean:

sA5x7oc.png



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. Please go to a safe place.', MESSAGE_STATUS_WARNING)
addEvent(serverSave, 60000)
end
local function firstServerSaveWarning()
Game.broadcastMessage('Server is saving game in 3 minutes. Please go to a safe place.', MESSAGE_STATUS_WARNING)
addEvent(secondServerSaveWarning, 120000)
end
function onTime(interval)
Game.broadcastMessage('Server is saving game in 5 minutes. Please go to a safe place.', MESSAGE_STATUS_WARNING)
Game.setGameState(GAME_STATE_STARTUP)
addEvent(firstServerSaveWarning, 120000)
return not shutdownAtServerSave
end
 
Change:
function onTimer(interval)

to

function onThink(interval, lastExecution, thinkInterval)
 
Also i would change the serversave to something like this. Asfar i understand you just want to save the server everytime.
Code:
local function serverSave()
    saveServer()
    broadcastMessage('The game has been saved.', MESSAGE_STATUS_WARNING)
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 onTime(interval)
    broadcastMessage('Server is saving game in 5 minutes. Please logout.', MESSAGE_STATUS_WARNING)
    addEvent(firstServerSaveWarning, 120000)
    return true
end

The old script will cause that players won't be able to login, since it will go directly to startup mode until the save is done. It was built for a globalserver save.
 
Back
Top