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

TalkAction /restart

@up it work just rename ur server.exe file to theforgottenserver.exe and it will work :)
 
np, but all i can say about this restart is:
THIS IS THE BEST RESTARTER I EVER SAW UR TRUSTED GM'S CAN RESTART NOW!!!
 
If I may edit your script:
Code:
function onSay(cid, words, param)
	local minid = 3
	local restartTime = 5*60*1000
	local message = "Server will restart in 5 minutes, data will be saved"
	local messageStop = "Restart process has been stopped"
	if getPlayerGroupId(cid) >= minid then
		if param == "now" or param == "0" then
			saveAndRestart(cid)
		elseif param == "stop" then
			broadcastMessage(messageStop)
			stopEvent(saverestart)
		elseif getNumber(param) ~= 0 then
			broadcastMessage("Server will restart in " .. getNumber(param) .. " minutes, data will be saved")
			saverestart = addEvent(saveAndRestart, getNumber(param)*60*1000, cid)
		else
			broadcastMessage(message)
			saverestart = addEvent(saveAndRestart, restartTime, cid)
		end
	end
end

function getNumber(str)
	x = string.gsub(str,"%a","")
	x = tonumber(x)
	if x ~= nill and x > 0 then
		return x
	else
		return 0
	end
end

function returnDate()
	curdate = os.date("*t")
	if curdate.day < 10 then
		curdate.day = "0"..curdate.day
	end
	if curdate.month < 10 then
		curdate.month = "0"..curdate.month
	end
	if curdate.hour < 10 then
		curdate.hour = "0"..curdate.hour
	end
	if curdate.min < 10 then
		curdate.min = "0"..curdate.min
	end
	return curdate
end                                                             

function saveAndRestart(cid)
	file = io.open("./logs/restarts.txt", "r")
	if file == nil then
		file = io.open("./logs/restarts.txt", "w")
	end
	text = file:read()
	if text == nil then
		text = ""
	end
	file:close()
	curdate = returnDate()
	newdate = "["..curdate.day.."/"..curdate.month.."/"..curdate.year.." "..curdate.hour..":"..curdate.min.."]"
	newtext = text..newdate.."Server restarted by "..getPlayerName(cid).."\n"
	file = io.open("./logs/restarts.txt", "w")
	file:write(newtext)
	file:close()
	saveData()
	io.popen("LuaRestarter.exe")
end

Now you can say any time interval in minutes like:
/restart"7
and if you say
/restart"0
it will be the same as
/restart"now

But it's your script! So it's up to you if you include this part.
 
[08/12/2008 17:45:34] Lua Script Error: [TalkAction Interface]
[08/12/2008 17:45:34] in a timer event called from:
[08/12/2008 17:45:34] data/talkactions/scripts/auto_restart.lua:eek:nSay

[08/12/2008 17:45:34] data/talkactions/scripts/auto_restart.lua:54: attempt to index global 'file' (a nil value)
[08/12/2008 17:45:34] stack traceback:
[08/12/2008 17:45:34] data/talkactions/scripts/auto_restart.lua:54: in function <data/talkactions/scripts/auto_restart.lua:49>

When it has 1 minute left, can u make it give a warning also?
 
Last edited:
Didn't work, when i type /restart, ingame after 5 minutes there is run LuaRestarter.exe from my ots directory and it do nothing.
 
@4220niller

This error apear after 5 minutes to restar the server...

Exceção Não Tratada: System.ComponentModel.Win32Exception: O sistema não pode en
contrar o arquivo especificado
em System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startI
nfo)
em System.Diagnostics.Process.Start()
em System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
em System.Diagnostics.Process.Start(String fileName)
em restart.Module1.Main()

Can you help me??? many thx, great script...
 
can't you make it so I can restart in any minutes I want? "/restart 6, 9, 12 etc"
you would need to change like:

local time = param (to check the number I type)

hmm I think it doesnt work on tfs 0.2.2
 
The restarter appears but the server never shutsdown and restart it only save the players, whats name should tfs exe should have?
 
Win:
Code:
doSaveServer()
os.execute("tskill theforgottenserver")
os.execute("start path/to/tfs.exe")

Linux:
Code:
doSaveServer()
os.execute("killall `theforgottenserver`")
os.execute("/path/to/theforgottenserver")

Instead of using restarter :d
 
Back
Top