local ServerAutoRestart = {} -- DO NOT TOUCH
local ServerAutoRestart_Enable = true
local ServerAutoRestart_EnableCommand = true
local ServerAutoRestart_Time = "04:20"
local advertMessages = {
{enabled = true, time = "04:05", message = "[~] Через 15 минут будет рестарт."},
{enabled = true, time = "04:10", message = "[~] Через 10 минут будет рестарт."},
{enabled = true, time = "04:15", message = "[~] Через 5 минут будет рестарт."},
{enabled = false, time = "04:17", message = "[~] Через 3 минуты будет рестарт."},
{enabled = false, time = "04:18", message = "[~] Через 2 минуты будет рестарт."}
}
local ServerAutoRestart_LangMin = "[~] Через 1 минуту будет рестарт !"
local ServerAutoRestart_LangSecs = "[~] Рестарт через %s секунд !"
local ServerAutoRestart_LangSec = "[~] bb"
local ServerAutoRestart_LangRes = "[~] :)"
function ServerAutoRestartFunc()
if ServerAutoRestart_Enable then
for _, advert in ipairs(advertMessages) do
if advert.enabled and os.date("%H:%M") == advert.time then
PrintMessage(HUD_PRINTTALK, advert.message)
end
end
if os.date("%H:%M") == ServerAutoRestart_Time then
PrintMessage(HUD_PRINTTALK, ServerAutoRestart_LangMin)
local countdown = {30, 15, 10, 9, 8, 7, 6, 5, 4, 3, 2}
for _, seconds in ipairs(countdown) do
PrintMessage(HUD_PRINTTALK, string.format(ServerAutoRestart_LangSecs, seconds))
timer.Simple(1, function() end)
end
PrintMessage(HUD_PRINTTALK, ServerAutoRestart_LangSec)
timer.Simple(1, function() end)
PrintMessage(HUD_PRINTTALK, ServerAutoRestart_LangRes)
timer.Simple(0.5, function() RunConsoleCommand("changelevel", game.GetMap()) end)
end
end
end
timer.Create("ServerAutoRestartTimer", 60, 0, ServerAutoRestartFunc)
if ServerAutoRestart_EnableCommand then
concommand.Add("restartserver", function(ply, cmd, args)
if ply:IsSuperAdmin() then
PrintMessage(HUD_PRINTTALK, ServerAutoRestart_LangRes)
timer.Simple(0.5, function() RunConsoleCommand("changelevel", game.GetMap()) end)
end
end)
end