2015-03-03 22:37:30 +01:00
|
|
|
--[[
|
|
|
|
|
|
|
|
shutdown par turbogus, code sous licence gpl2 ou sup
|
|
|
|
déclaration du "timer" par Jat ( du mod annonce )
|
|
|
|
|
|
|
|
Affiche l'heure dans le chat toute les minutes et
|
|
|
|
arrête votre serveur "proprement" à une heure précise afin de créer
|
|
|
|
une sauvegarde
|
|
|
|
|
|
|
|
]]--
|
2015-07-30 14:55:08 +02:00
|
|
|
-- compatibility with soundset mod
|
|
|
|
local SOUNDVOLUME = 1
|
|
|
|
local get_volume
|
|
|
|
if (minetest.get_modpath("soundset")) ~= nil then
|
|
|
|
get_volume = soundset.get_gain
|
|
|
|
else
|
|
|
|
get_volume = function (player_name, sound_type) return SOUNDVOLUME end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function sound_play_all(sound)
|
|
|
|
for _, p in ipairs(minetest.get_connected_players()) do
|
|
|
|
local player_name = p:get_player_name()
|
|
|
|
if player_name then
|
|
|
|
minetest.sound_play(sound, {to_player=player_name, gain=get_volume(player_name, "other")})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-03-03 22:37:30 +01:00
|
|
|
|
|
|
|
local timer = 0
|
|
|
|
|
2016-06-16 21:38:50 +02:00
|
|
|
local function send(msg, col)
|
|
|
|
core.chat_send_all(core.colorize(col, msg))
|
|
|
|
end
|
|
|
|
|
2015-07-31 11:56:19 +02:00
|
|
|
local function tick()
|
2015-03-03 22:37:30 +01:00
|
|
|
local heure = os.date("%H")
|
|
|
|
local minute = os.date("%M")
|
2015-07-26 16:17:14 +02:00
|
|
|
-- Warn every days
|
2016-06-15 03:52:35 +02:00
|
|
|
if heure == "04" then
|
2015-07-30 14:55:08 +02:00
|
|
|
if minute == "00" then
|
2016-06-16 21:38:50 +02:00
|
|
|
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")
|
2015-07-30 14:55:08 +02:00
|
|
|
sound_play_all("shutdown_shutdown")
|
|
|
|
elseif minute == "15" then
|
2016-06-16 21:38:50 +02:00
|
|
|
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")
|
2015-07-30 14:55:08 +02:00
|
|
|
sound_play_all("shutdown_shutdown")
|
|
|
|
elseif minute == "25" then
|
2016-06-16 21:38:50 +02:00
|
|
|
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")
|
2015-07-30 14:55:08 +02:00
|
|
|
sound_play_all("shutdown_shutdown")
|
|
|
|
elseif minute == "29" then
|
2016-06-16 21:38:50 +02:00
|
|
|
send("=== ARRET DU SERVEUR - DE NOUVEAU EN LIGNE DANS 30 MIN ===", "#ff0000")
|
|
|
|
send("=== SERVER SHUTTING DOWN - ONLINE AGAIN IN 30 MIN ===", "#ff0000")
|
2015-07-30 14:55:08 +02:00
|
|
|
sound_play_all("shutdown_shutdown")
|
|
|
|
-- minetest.request_shutdown()
|
|
|
|
end
|
2015-03-03 22:37:30 +01:00
|
|
|
end
|
2016-06-16 21:38:50 +02:00
|
|
|
minetest.after(60, tick)
|
2015-07-31 11:56:19 +02:00
|
|
|
end
|
|
|
|
|
2016-06-16 21:38:50 +02:00
|
|
|
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)
|