Skip to content

Instantly share code, notes, and snippets.

@gabyfle
Created April 21, 2019 14:26
Show Gist options
  • Save gabyfle/519161a9dc1eec5653e89059fc7411bf to your computer and use it in GitHub Desktop.
Save gabyfle/519161a9dc1eec5653e89059fc7411bf to your computer and use it in GitHub Desktop.
Gmod Lua server restart prevent
local config = {
['commandName'] = 'reboot_prevent',
['timer'] = 10,
['iterations'] = 5
}
if SERVER then
local timerIteration = 1
function launchReboot(time)
timer.Simple(time, function ()
PrintMessage(4, 'Server is restarting')
RunConsoleCommand('_restart')
end)
timer.Create('rebootTimer', config['iterations'], (time / config['iterations']) - 1, function ()
local remaining = time - (timerIteration * config['iterations'])
PrintMessage(4, 'Server will restart in ' .. remaining .. ' seconds.')
timerIteration = timerIteration + 1
end)
end
end
-- SHARED CODE --
concommand.Add(config['commandName'], function(ply, cmd, args)
if not (ply:IsAdmin()) then return false end
if SERVER then launchReboot(config['timer']) end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment