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

Exmortis

Member
Joined
Jun 27, 2008
Messages
189
Reaction score
5
I'm useing a script to restart my server that looks like this:
Code:
function onSay(cid, words, param)
	local minid = 3
	local restartTime = 1000
	local message = "Server is restarting now!"
	local messageStop = "Restart process has been stopped"
	if getPlayerGroupId(cid) >= minid then
		if param == "now" then
			saveAndRestart(cid)
		elseif param == "stop" then
			broadcastMessage(messageStop)
			stopEvent(saverestart)
		else
			broadcastMessage("Restart process has been stopped!", 18)
			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 = "["..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()
	saveData()
	io.popen("LuaRestarter.exe")
end

But it doesnt save the players, houses or stuff like that..
Anyone that can look into this script a bit and tell me if anything looks weird or is just plainly missing?
Thanks.
 
Back
Top