add global status announcement

add global status announcement and change flag string format to being used directly in the status messages
master
shivajiva101 2017-07-06 00:30:14 +01:00 committed by GitHub
parent a4a1bfabf5
commit cf9fa4e6ad
1 changed files with 13 additions and 8 deletions

View File

@ -5,28 +5,33 @@ with persistence of the last state across server restarts
]]
local mod_data = minetest.get_mod_storage()
local border = "false"
local border = "OPEN"
-- initialise
if mod_data:get_string("status") == "" then
mod_data:set_string("status", "true")
mod_data:set_string("status", "CLOSED")
end
--set
border = mod_data:get_string("status")
-- announce status
minetest.after(5, function()
minetest.chat_send_all("[border:info] border is "..border)
end)
-- toggle new players
minetest.register_chatcommand("border", {
params = "",
description = "Toggles if new players are allowed",
privs = {server = true},
func = function (name, param)
if border == "true" then
border = "false"
minetest.chat_send_player(name, "Server allowing new players.")
if border == "CLOSED" then
border = "OPEN"
minetest.chat_send_player(name, "[border:info] allowing new players.")
else
border = "true"
minetest.chat_send_player(name, "Server refusing new players.")
border = "CLOSED"
minetest.chat_send_player(name, "[border:info] refusing new players.")
end
mod_data:set_string("flag", border) -- save
end
@ -39,7 +44,7 @@ minetest.register_on_prejoinplayer(function(name, ip)
return
end
-- stop NEW players from joining
if border == "true" and not core.auth_table[name] then
if border == "CLOSED" and not core.auth_table[name] then
return ("\nSorry, no new players being admitted at this time!")
end
end