Hey this sounds pretty simple but I'm no good at lua so it may or may not be.
What I'm requesting is if there are no players in the server for two hours then the server will automatically restart itself.
This is to prevent something happening that causes players not to be able to join (getting stuck at 'retrieving server info' which people have been reporting).
Thanks!
Something like this. You can't actually force a server to restart via Lua, since the exit commands are blocked.
[lua]
local timenoplayers = 0
hook.Add("Think" , "Restarter" , function()
if #player.GetAll() < 1 and not (timenoplayers + 2 > CurTime()) then
if CurTime() > timenoplayers + 7200 then
game.ConsoleCommand("changelevel gm_flatgrass\n")
end
elseif #player.GetAll() < 1 then
timenoplayers = CurTime()
end
end )[/lua]
[QUOTE=|FlapJack|;21633836]Something like this. You can't actually force a server to restart via Lua, since the exit commands are blocked.
[lua]
local timenoplayers = 0
hook.Add("Think" , "Restarter" , function()
if #player.GetAll() < 1 and not (timenoplayers + 2 > CurTime()) then
if CurTime() > timenoplayers + 7200 then
game.ConsoleCommand("changelevel gm_flatgrass\n")
end
end
end )[/lua][/QUOTE]
With the help of a module you can run commands like exit and stuff, up to you if you want something like that though.
Link: [url]http://www.facepunch.com/showthread.php?t=697445[/url]
I know that, but installing a module for running a command which isn't even needed is a bit pointless.
_restart would work too. But change map is just fine! Thanks
Guys, to let you know, you could add this to server.cfg:
[code]
alias fucking_incredible quit
[/code]
Then
[lua]
RunConsoleCommand("fucking_incredible")
[/lua]
No modules required.
Also, hMaintenance can auto clean and restart the map, it also has a good countdown too:
[url]http://www.facepunch.com/showthread.php?t=736509[/url]
Sorry, you need to Log In to post a reply to this thread.