axinite/shutdown.lua

24 lines
930 B
Lua

core.register_chatcommand("shutdown", {
description = "Shutdown server",
params = "[delay_in_seconds (non-negative number, or -1 to cancel)] [reconnect] [message]",
privs = {reboot=true},
func = function(name, param)
local delay, reconnect, message = param:match("([^ ][-]?[0-9]+)([^ ]+)(.*)")
message = message or ""
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,
})
minetest.register_privilege("reboot", {
description = "Can shutdown server",
give_to_singleplayer = false
})