mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-24 17:50:37 +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 function send(msg, col)
|
||||
core.chat_send_all(core.colorize(col, msg))
|
||||
end
|
||||
|
||||
local function tick()
|
||||
local heure = os.date("%H")
|
||||
local minute = os.date("%M")
|
||||
-- Warn every days
|
||||
if heure == "04" then
|
||||
if minute == "00" then
|
||||
minetest.chat_send_all("Rappel : Redémarrage journalier du serveur dans 30 minutes. (Dure 30 minutes)")
|
||||
minetest.chat_send_all("Reminder : Daily reboot of the server in 30 minutes. (Lasts 30 minutes)")
|
||||
send("Rappel : Redémarrage journalier du serveur dans 30 minutes. (Dure 30 minutes)", "#ffff00")
|
||||
send("Reminder : Daily reboot of the server in 30 minutes. (Lasts 30 minutes)", "#ffff00")
|
||||
sound_play_all("shutdown_shutdown")
|
||||
elseif minute == "15" then
|
||||
minetest.chat_send_all("Rappel : Redémarrage journalier du serveur dans 15 minutes. (Dure 30 minutes)")
|
||||
minetest.chat_send_all("Reminder : Daily reboot of the server in 15 minutes. (Lasts 30 minutes)")
|
||||
send("Rappel : Redémarrage journalier du serveur dans 15 minutes. (Dure 30 minutes)", "#FF6600")
|
||||
send("Reminder : Daily reboot of the server in 15 minutes. (Lasts 30 minutes)", "#FF6600")
|
||||
sound_play_all("shutdown_shutdown")
|
||||
elseif minute == "25" then
|
||||
minetest.chat_send_all("Rappel : Redémarrage journalier du serveur dans 5 minutes - Pensez à vous deconnecter !")
|
||||
minetest.chat_send_all("Reminder : Daily reboot of the server in 5 minutes - Think about logout!")
|
||||
send("Rappel : Redémarrage journalier du serveur dans 5 minutes - Pensez à vous deconnecter !", "#ff0000")
|
||||
send("Reminder : Daily reboot of the server in 5 minutes - Prepare to log out!", "#ff0000")
|
||||
sound_play_all("shutdown_shutdown")
|
||||
elseif minute == "29" then
|
||||
minetest.chat_send_all("=== ARRET DU SERVEUR - DE NOUVEAU EN LIGNE DANS 30 MIN ===")
|
||||
minetest.chat_send_all("=== SERVER SHUTTING DOWN - ONLINE AGAIN IN 30 MIN ===")
|
||||
send("=== ARRET DU SERVEUR - DE NOUVEAU EN LIGNE DANS 30 MIN ===", "#ff0000")
|
||||
send("=== SERVER SHUTTING DOWN - ONLINE AGAIN IN 30 MIN ===", "#ff0000")
|
||||
sound_play_all("shutdown_shutdown")
|
||||
-- minetest.request_shutdown()
|
||||
end
|
||||
end
|
||||
minetest.after(20, tick)
|
||||
minetest.after(60, tick)
|
||||
end
|
||||
|
||||
tick()
|
||||
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()
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user