1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-12 16:15:20 +02:00

Implement delayed server shutdown with cancelation (#4664)

This commit is contained in:
Loïc Blot
2017-04-15 23:19:18 +02:00
committed by GitHub
parent 0f955bf7fa
commit 34d32ce55a
8 changed files with 124 additions and 14 deletions

View File

@@ -763,14 +763,20 @@ core.register_chatcommand("days", {
core.register_chatcommand("shutdown", {
description = "Shutdown server",
params = "[reconnect] [message]",
params = "[delay_in_seconds(0..inf) or -1 for cancel] [reconnect] [message]",
privs = {server=true},
func = function(name, param)
core.log("action", name .. " shuts down server")
core.chat_send_all("*** Server shutting down (operator request).")
local reconnect, message = param:match("([^ ]+)(.*)")
local delay, reconnect, message = param:match("([^ ][-]?[0-9]+)([^ ]+)(.*)")
message = message or ""
core.request_shutdown(message:trim(), core.is_yes(reconnect))
if delay ~= "" then
delay = tonumber(param) or 0
else
delay = 0
core.log("action", name .. " shuts down server")
core.chat_send_all("*** Server shutting down (operator request).")
end
core.request_shutdown(message:trim(), core.is_yes(reconnect), delay)
end,
})