master
TMcSquared 2018-05-04 07:45:54 -05:00
parent 4cde724b8f
commit 6bb021d2dc
2 changed files with 37 additions and 0 deletions

View File

@ -12,6 +12,7 @@ server_announce = true
server_name = Legends Of Survival
server_description = A server dedicated to survival and building via teamwork, this server is a continuation of the legacy of MM-Survival
static_spawnpoint = -444 29 -869
ts.duration = 86360
#--------------------------------------------------
#Game
#--------------------------------------------------

36
mods/ts/init.lua Normal file
View File

@ -0,0 +1,36 @@
--[[
timed server shutdown mod for minetest
by shivajiva101@hotmail.com
Useage: you can set a value in minetest.conf, the default length is ~24 hours
minus 30 seconds.
e.g. ts.duration = 86360
should be used in conjunction with a shell script that restarts the server
]]
local duration = minetest.setting_get("ts.duration") or 86370 -- 23h 59m 30s
local function chatsend(txt)
minetest.chat_send_all(txt)
end
local function notify()
minetest.after(0, chatsend, "Daily restart in 30 seconds\nThe server will take ~30s to reload")
minetest.after(10, chatsend, "restarting in 20 seconds")
minetest.after(20, chatsend, "restarting in 10 seconds")
minetest.after(25, chatsend, "restarting in 5 seconds")
-- kick all player with a message
minetest.after(29, function()
chatsend("kicking players...")
for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
-- player potentially attached to an entity
player:set_detach()
minetest.kick_player(name, name.." please rejoin in 30 seconds")
end
minetest.request_shutdown()
end)
end
minetest.after(duration, notify)