border/init.lua

47 lines
1.2 KiB
Lua
Raw Normal View History

2017-07-05 14:31:20 -07:00
--[[
original code provided by tenplus1
This mod instigates an effective border for new players joining a server
with persistence of the last state across server restarts
]]
local mod_data = minetest.get_mod_storage()
local border = "false"
-- initialise
if mod_data:get_string("status") == "" then
mod_data:set_string("status", "true")
end
--set
border = mod_data:get_string("status")
-- 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.")
else
border = "true"
minetest.chat_send_player(name, "Server refusing new players.")
end
mod_data:set_string("flag", border) -- save
end
})
-- register hook
minetest.register_on_prejoinplayer(function(name, ip)
2017-07-05 16:20:51 -07:00
-- owner exception
if minetest.setting_get("name") == name then
return
end
2017-07-05 14:31:20 -07:00
-- stop NEW players from joining
if border == "true" and not core.auth_table[name] then
return ("\nSorry, no new players being admitted at this time!")
end
end
)