Created
April 21, 2019 14:26
-
-
Save gabyfle/519161a9dc1eec5653e89059fc7411bf to your computer and use it in GitHub Desktop.
Gmod Lua server restart prevent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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