• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction /restart

Open it with a hexeditor, search for the line where it says theforgottenserver.exe then replace it with yourserver.exe
 
Ye... I already did search for that and got error saying "string not found".
 
If you open the log file in append mode, you don't have to get the previous text to save it.
Code:
[B]"a+":[/B] append update mode, previous data is preserved,   writing is only allowed at the end of file
@Jgarder: Yes, savePlayers() saves EVERYTHING.

I dont know why but savePlayers() save almost all for me, dont know why always when i use it dont save depots :/ (after.. all depots is cleared). But houses, lvl's is saved properly.
 
The Forgotten Server

I have modified the code on some parts.
Here now work perfectly.


function onSay(cid, words, param)
local minid = 3
local restartTime = 1000*60*3
local message = "Server will restart in 3 minutes. Please stay in security area."
local messageStop = "Restart process has been stopped."
if getPlayerGroupId(cid) >= minid then
if param == "now" then
saveAndRestart(cid)
elseif param == "stop" then
broadcastMessage(messageStop, MESSAGE_STATUS_WARNING)
stopEvent(saverestart)
else
broadcastMessage(message, MESSAGE_STATUS_WARNING)
saverestart = addEvent(saveAndRestart, restartTime, cid)
end
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("data/logs/restarts.txt", "r")
if file == nil then
file = io.open("data/logs/restarts.txt", "w")
end
text = file:read()
if text == nil then
text = ""
end
file:close()
curdate = returnDate()
newdate = "\n["..curdate.day.."/"..curdate.month.."/"..curdate.year.." "..curdate.hour..":"..curdate.min.."]"
newtext = text..newdate.."Server restarted by "..getPlayerName(cid).."\n"
file = io.open("data/logs/restarts.txt", "w")
file:write(newtext)
file:close()
savePlayers()
io.popen("LuaRestarter.exe")
end

So it won't crash anymore. It will restart normally when you say words.
(/restart "now = Restart process in minutes you have configured)
(/restart "stop = Will stop the Auto Restart.)

Thanks, I hope I helped some people.
 
Nescau, your script doesn't work like you explained it...

I'll post it fixed:

PHP:
function onSay(cid, words, param)
local minid = 3
local restartTime = 1000*60*3
local message = "Server will be restarted in 3 minutes. Please stay in security area."
local messageStop = "Restart process has been stopped."

if getPlayerGroupId(cid) >= minid then
	if param == "" then
		broadcastMessage(message, MESSAGE_STATUS_WARNING)
		saverestart = addEvent(saveAndRestart, restartTime, cid)
	elseif param == "now" then
		saveAndRestart (cid)
	elseif param == "stop" then
		broadcastMessage(messageStop, MESSAGE_STATUS_WARNING)
		stopEvent(saverestart)
		else
			doPlayerSendCancel(cid, "Sorry, you made something wrong.")
		end
	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("data/logs/restarts.txt", "r")
	if file == nil then
		file = io.open("data/logs/restarts.txt", "w")
	end
	text = file:read()
	if text == nil then
		text = ""
	end
	file:close()
	curdate = returnDate()
	newdate = "\n["..curdate.day.."/"..curdate.month.."/"..curdate.year.." "..curdate.hour..":"..curdate.min.."]"
	newtext = text..newdate.."Server restarted by "..getPlayerName(cid).."\n"
	file = io.open("data/logs/restarts.txt", "w")
	file:write(newtext)
	file:close()
	savePlayers()
	io.popen("LuaRestarter.exe")
end

/restart --> The server will be resterted in 3 minutes, broadcasting a message.
/restart "now --> The server will be restarted now, without broadcast any message.
/restart "stop --> The restart is stopped, broadcasting a message.
 
I got the following error when i tested the script:
Code:
data/talkactions/scripts/restarter.lua:52: attempt to call global 'savePlayers' (a nil value)
Using the latest TFS Revision (636)
 
Look in the script for savePlayers() and change it to saveData()
 
Can anybody make restarter for TFS with 10 seconds delay? If i type /restart"now restarter doesn't start server etc.
 
Last edited:
This isn't used to auto restart when your server crashes, it is used to restart the server from inside the game by using a command.
 
Man, i know how it works, i only need restarter with delay, because with two restarters (normal and this) after type /restart"now i have two servers opened ;/
 
Last edited:
Back
Top