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

Script to restart the OT at a certain time

Cornwallis

Member
Joined
Jan 3, 2010
Messages
480
Reaction score
16
Is there a way that you can make a script to close the ot and then run it again at the same time everyday?
 
All of these got an error ;s
the error is:
data/globalevents/scripts/my_script.lua:8: 'end' expected (to close 'function' at line 7) near 'doSetGameState'

Also, does this script save the server before it shutsdown because 0.3.6pl1 doesnt do that.
 
LUA:
function onTimer()
	doBroadcastMessage('shutdown in 2 minutes.')
	return addEvent(onShutdown,2*60*1000)
end

function onShutdown()
	return doSetGameState(GAMESTATE_SHUTDOWN)
end
 
Last edited:
I didnt understand anything of that all.. you have write so many codes that i am getting confused.. please fix my script?:) I want it to save as rl tibia does.. Warning 5 minutes before server save.. save and then kick and then start again.

Config.lua
globalSaveEnabled = false
globalSaveHour = 8
shutdownAtGlobalSave = true
cleanMapAtGlobalSave = false

Globalevents.Xml
<?xml version="1.0" encoding="UTF-8"?>
<globalevents>
<globalevent name="effects" interval="1" event="script" value="talkingtiles.lua"/>
<globalevent name="save" interval="43200" event="script" value="save.lua"/>
<globalevent name="shop" interval="30" event="script" value="shop.lua"/>
<globalevent name="info" interval="120" event="script" value="information.lua"/>
<globalevent name="clean" interval="7200" event="script" value="clean.lua"/>
<globalevent name="serverstart" type="start" event="script" value="start.lua"/>
<globalevent name="playersrecord" type="record" event="script" value="record.lua"/>
</globalevents>

Save.lua
local config = {
broadcast = {120, 30},
shallow = "no",
delay = 120,
events = 30
}

config.shallow = getBooleanFromString(config.shallow)

local function executeSave(seconds)
if(isInArray(config.broadcast, seconds)) then
local text = ""
if(not config.shallow) then
text = "Full s"
else
text = "S"
end

text = text .. "erver save within " .. seconds .. " seconds, please mind it may freeze!"
end

if(seconds > 0) then
addEvent(executeSave, config.events * 1000, seconds - config.events)
else
doSaveServer(config.shallow)
end
end

function onThink(interval, lastExecution, thinkInterval)
if(table.maxn(config.broadcast) == 0) then
doSaveServer(config.shallow)
else
executeSave(config.delay)
end

return true
end
 
Back
Top