Auto Restart Game

Hello !

Back-story:
I am running servers on a computer I built by myself in my basement and am in need of some sort of Garry’s Mod server restart thingy. I have everything setup so that if the server crashes or closes, it starts itself up again, but that’s not what I need. I really need a script of some sort or a plugin thingy that restarts the server completely at a certain time whether that be when a timer is up, at a time of day, or when no players are on the server for an amount of time (I would rather have when no players are online). I need the server to restart completely so that the addons have a chance to update, the map is set back to the default, and any stability problems are solved instantly.

What I need:
I need a script that restarts a Garry’s Mod server at a certain time, resetting the map back to default and letting the addons update.

Also:
If anybody knows of a fast and simple way to sync ulx bans and ulx group’s users between multiple, similar Garry’s Mod servers, please let me know. I am not very SQL Database literate. :-[

I did my research:
I can’t for the life of me find anything close to what I need anywhere on the internet and decided this was the place to post. Not even this forum has a topic similar to this that has an answer or is less than 2 years old.

I have this scripts : in lua>autorun>server


if os.date( "%I:%M %p" ) == "3:00 AM" then
     BroadcastLua("LocalPlayer():ConCommand(\"disconnect; snd_restart; retry\")")
 
     timer.Simple(0.5, function()
          game.ConsoleCommand("exit
")
          game.ConsoleCommand("shutdown
")
          game.ConsoleCommand("killserver
")
     end)
end

Anything helps,

  • C

This is what I use:

[lua]
local minimumTime = 12 * 60 * 60 – Minimum time needed before restart, 12 hours.
local thinkTimer = CurTime() + 60
local function timeFormat( time )
local tmp = time
local s = tmp % 60
tmp = math.floor( tmp / 60 )
local m = tmp % 60
tmp = math.floor( tmp / 60 )
local h = tmp % 24
tmp = math.floor( tmp / 24 )
local d = tmp % 7
local w = math.floor( tmp / 7 )

return string.format( "%02iw %id %02ih %02im %02is", w, d, h, m, s )

end

hook.Add(“InitPostEntity”, “CheckTimeForRestart”,function()
if !file.Exists(“restart.txt”,“DATA”) then
file.Write(“restart.txt”, os.time())
else
local lastStart = file.Read(“restart.txt”)
local timeRunning = os.time() - lastStart
ServerLog(“Server has been running for “… timeFormat(timeRunning)…”
“)
local canReboot = false
local hour = tonumber(os.date(”%H”))
if (hour > 0 && hour < 11) then canReboot = true end
if (timeRunning > minimumTime) && canReboot then
timer.Create(“RebootTimer”, 120, 0, function()
if #player.GetAll() == 0 then
ServerLog(“Auto Restarting Server!
“)
file.Write(“restart.txt”, os.time())
RunConsoleCommand(”_restart”)
end
end)
end
end
end)
[/lua]

It runs a check at the start of a map, if there’s no players after 120 seconds, it restarts.
The timer will work as long as a player has connected at some point.
This is currently set to reboot between 1am and 10am

Okay Thank man i do not but I reboot at 3 am ?

I can’t find the link to download at the moment, but I think you will find this program will work best for you. I use it for all my servers with no issues and you can set times to stop and restart the server.

http://www.dumbclan.co.uk/downloads/serverchecker/MainWindow.jpg

Hello, iam in debian not windows

Sorry, I didn’t see you say that.