• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Auto /shutdown 10 every 18 hours.

TriamerA

The Mystic One.
Joined
Nov 16, 2008
Messages
1,257
Reaction score
18
Location
Poland
Hello since TFS 0.3.1 is always crashing after 18hours + I need a globalevent script which will execute /shutdown 10 command every 18 hours. Thanks in advance.
 
Last edited by a moderator:
Thread solved, here is the result:

XML:
data/creaturescript/creaturescripts.xml
Code:
<globalevent name="clean" interval="64800" script="shutdown.lua"/>


LUA:
data/creaturescripts/scripts/shutdown.lua
Code:
function onThink(interval, lastExecution)

local shutdownEvent = 0

	param = 10 -- how many minutes before it will be announced
	if(shutdownEvent ~= 0) then
		stopEvent(shutdownEvent)
	end
	prepareShutdown(math.abs(math.ceil(param)))

function prepareShutdown(minutes)
	if(minutes <= 0) then
		doSetGameState(GAMESTATE_SHUTDOWN)
	else
		if(minutes == 1) then
			doBroadcastMessage("Server is going down in " .. minutes .. " minute, please log out now!")
		elseif(minutes <= 3) then
			doBroadcastMessage("Server is going down in " .. minutes .. " minutes, please log out.")
		else
			doBroadcastMessage("Server is going down in " .. minutes .. " minutes.")
		end
		shutdownEvent = addEvent(prepareShutdown, 60000, minutes - 1)
	end
end

	return TRUE
end
 
Last edited by a moderator:
Yes I need it to restart every 18 hours of uptime, because after there is a risk that server will crash, I always had crashes after 20h+ of uptime at 0.3.1 , and there is a option in my autorestarter to do it, but then server wouldn't save, so good and simpy option is to make it in globalevents. Thanks for help anyway.
 
Try this:

shutdown.lua
LUA:
function onThink(interval, lastExecution)
	doShutdown()
	return TRUE
end

globalevents.xml
Code:
<globalevent name="shutdown" interval="64800" event="script" value="shutdown.lua"/>

It works, but....

EDIT: this close the OT without broadcasting.

:p
 
Last edited:
Check what i said,

I wrote Every AT: 18:00 (slawkens said so) that's why i posted, look at dslawkens post noob, He said that and i copied that he said... I know he want a script that shutdownsevery 18hours.

@Archez, better if it gives a message before shutdown.

LUA:
  function serverRestart()
		shutdown()
	return TRUE
end

  function onThink(interval, lastExecution)
		doBroadcastMessage("Server restart in 1 minute, please come back after 1 minute.", MESSAGE_STATUS_CONSOLE_RED)
		addEvent(serverRestart, 1000*60)
	return TRUE
end
 
Last edited:
Moderator Message: Thread cleaned.

Thread solved, will be moved to the released script section.

Thanks for discussion and participating in the thread.
 
Back
Top