4220niller
XHTML / CSS Coder
well i saw that thread Helveg made, and i decided to make a restarter of my own, so here it is:
Update, i added a timer event so you can now make it broadcast a message before restart, default is 5 minutes, you can also just say /restart "now to restart it instantly
Update, i added a log too, so now you can see who restarted at wich time in data/logs/restarts.txt, also added a stopper so if you started a timed restart you can now say /restart "stop to stop it
This script is only for The Forgotten Server atm
data/talkactions/scripts/restarter.lua
The minimum group id to use this command
The time that will pass before the server restarts
The message that will be broadcasted before the server restarts
The message that will be broadcasted if the restart process is stopped
if you use /restart "now then it will restart instantly, otherwise the restartTime has to pass before restart
data/talkactions/talkactions.xml
You cannot use an auto restarter if you want this to work
download the file in my attachments and put it in your otserver directory
Update, i added a timer event so you can now make it broadcast a message before restart, default is 5 minutes, you can also just say /restart "now to restart it instantly
Update, i added a log too, so now you can see who restarted at wich time in data/logs/restarts.txt, also added a stopper so if you started a timed restart you can now say /restart "stop to stop it
This script is only for The Forgotten Server atm
data/talkactions/scripts/restarter.lua
Code:
function onSay(cid, words, param)
[COLOR="Red"]local minid = 3[/COLOR]
[COLOR="Green"]local restartTime = 1000*60*5[/COLOR]
[COLOR="Blue"]local message = "Server will restart in 5 minutes, data will be saved"[/COLOR]
[COLOR="Magenta"]local messageStop = "Restart process has been stopped"[/COLOR]
if getPlayerGroupId(cid) >= minid then
if param == "now" then
saveAndRestart(cid)
elseif param == "stop" then
broadcastMessage(messageStop)
stopEvent(saverestart)
else
broadcastMessage(message)
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()
savePlayers()
io.popen("LuaRestarter.exe")
end
The minimum group id to use this command
The time that will pass before the server restarts
The message that will be broadcasted before the server restarts
The message that will be broadcasted if the restart process is stopped
if you use /restart "now then it will restart instantly, otherwise the restartTime has to pass before restart
data/talkactions/talkactions.xml
Code:
<talkaction words="/restart" script="restarter.lua" />
You cannot use an auto restarter if you want this to work
download the file in my attachments and put it in your otserver directory
Attachments
-
TFSLuaRestarter.rar4 KB · Views: 783 · VirusTotal
Last edited: