mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-12 11:00:25 +01:00
[shutdown] Update with colours and complex tick mechanism
- Messages now come with colour - The tick function is launched at the first second of a new minute which is determined at startup
This commit is contained in:
parent
1f813060ac
commit
b43620565d
@ -28,31 +28,40 @@ end
|
|||||||
|
|
||||||
local timer = 0
|
local timer = 0
|
||||||
|
|
||||||
|
local function send(msg, col)
|
||||||
|
core.chat_send_all(core.colorize(col, msg))
|
||||||
|
end
|
||||||
|
|
||||||
local function tick()
|
local function tick()
|
||||||
local heure = os.date("%H")
|
local heure = os.date("%H")
|
||||||
local minute = os.date("%M")
|
local minute = os.date("%M")
|
||||||
-- Warn every days
|
-- Warn every days
|
||||||
if heure == "04" then
|
if heure == "04" then
|
||||||
if minute == "00" then
|
if minute == "00" then
|
||||||
minetest.chat_send_all("Rappel : Redémarrage journalier du serveur dans 30 minutes. (Dure 30 minutes)")
|
send("Rappel : Redémarrage journalier du serveur dans 30 minutes. (Dure 30 minutes)", "#ffff00")
|
||||||
minetest.chat_send_all("Reminder : Daily reboot of the server in 30 minutes. (Lasts 30 minutes)")
|
send("Reminder : Daily reboot of the server in 30 minutes. (Lasts 30 minutes)", "#ffff00")
|
||||||
sound_play_all("shutdown_shutdown")
|
sound_play_all("shutdown_shutdown")
|
||||||
elseif minute == "15" then
|
elseif minute == "15" then
|
||||||
minetest.chat_send_all("Rappel : Redémarrage journalier du serveur dans 15 minutes. (Dure 30 minutes)")
|
send("Rappel : Redémarrage journalier du serveur dans 15 minutes. (Dure 30 minutes)", "#FF6600")
|
||||||
minetest.chat_send_all("Reminder : Daily reboot of the server in 15 minutes. (Lasts 30 minutes)")
|
send("Reminder : Daily reboot of the server in 15 minutes. (Lasts 30 minutes)", "#FF6600")
|
||||||
sound_play_all("shutdown_shutdown")
|
sound_play_all("shutdown_shutdown")
|
||||||
elseif minute == "25" then
|
elseif minute == "25" then
|
||||||
minetest.chat_send_all("Rappel : Redémarrage journalier du serveur dans 5 minutes - Pensez à vous deconnecter !")
|
send("Rappel : Redémarrage journalier du serveur dans 5 minutes - Pensez à vous deconnecter !", "#ff0000")
|
||||||
minetest.chat_send_all("Reminder : Daily reboot of the server in 5 minutes - Think about logout!")
|
send("Reminder : Daily reboot of the server in 5 minutes - Prepare to log out!", "#ff0000")
|
||||||
sound_play_all("shutdown_shutdown")
|
sound_play_all("shutdown_shutdown")
|
||||||
elseif minute == "29" then
|
elseif minute == "29" then
|
||||||
minetest.chat_send_all("=== ARRET DU SERVEUR - DE NOUVEAU EN LIGNE DANS 30 MIN ===")
|
send("=== ARRET DU SERVEUR - DE NOUVEAU EN LIGNE DANS 30 MIN ===", "#ff0000")
|
||||||
minetest.chat_send_all("=== SERVER SHUTTING DOWN - ONLINE AGAIN IN 30 MIN ===")
|
send("=== SERVER SHUTTING DOWN - ONLINE AGAIN IN 30 MIN ===", "#ff0000")
|
||||||
sound_play_all("shutdown_shutdown")
|
sound_play_all("shutdown_shutdown")
|
||||||
-- minetest.request_shutdown()
|
-- minetest.request_shutdown()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.after(20, tick)
|
minetest.after(60, tick)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.after(0, function() -- When server has just started
|
||||||
|
-- Calculate time until next minute to start laps (+1 sec to be sure)
|
||||||
|
minetest.after(61 - tonumber(os.date("%S")), function()
|
||||||
tick()
|
tick()
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user