Add team locking
This commit is contained in:
parent
5769d446ab
commit
254d147bb2
@ -281,7 +281,8 @@ function ctf.autoalloc(name, alloc_mode)
|
|||||||
local index = {}
|
local index = {}
|
||||||
|
|
||||||
for key, team in pairs(ctf.teams) do
|
for key, team in pairs(ctf.teams) do
|
||||||
if max_players == -1 or ctf.count_players_in_team(key) < max_players then
|
if team.data.allow_joins ~= false and (max_players == -1 or
|
||||||
|
ctf.count_players_in_team(key) < max_players) then
|
||||||
table.insert(index, key)
|
table.insert(index, key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -298,7 +299,8 @@ function ctf.autoalloc(name, alloc_mode)
|
|||||||
local two_count = -1
|
local two_count = -1
|
||||||
for key, team in pairs(ctf.teams) do
|
for key, team in pairs(ctf.teams) do
|
||||||
local count = ctf.count_players_in_team(key)
|
local count = ctf.count_players_in_team(key)
|
||||||
if (max_players == -1 or count < max_players) then
|
if team.data.allow_joins ~= false and
|
||||||
|
(max_players == -1 or count < max_players) then
|
||||||
if count > one_count then
|
if count > one_count then
|
||||||
two = one
|
two = one
|
||||||
two_count = one_count
|
two_count = one_count
|
||||||
@ -333,7 +335,8 @@ function ctf.autoalloc(name, alloc_mode)
|
|||||||
local smallest_count = 1000
|
local smallest_count = 1000
|
||||||
for key, team in pairs(ctf.teams) do
|
for key, team in pairs(ctf.teams) do
|
||||||
local count = ctf.count_players_in_team(key)
|
local count = ctf.count_players_in_team(key)
|
||||||
if not smallest or count < smallest_count then
|
if team.data.allow_joins ~= false and
|
||||||
|
(not smallest or count < smallest_count) then
|
||||||
smallest = key
|
smallest = key
|
||||||
smallest_count = count
|
smallest_count = count
|
||||||
end
|
end
|
||||||
|
@ -25,6 +25,9 @@ local function team_console_help(name)
|
|||||||
minetest.chat_send_player(name, "/team remove <team> - add a team called name (ctf_admin only)")
|
minetest.chat_send_player(name, "/team remove <team> - add a team called name (ctf_admin only)")
|
||||||
end
|
end
|
||||||
if privs and privs.ctf_team_mgr == true then
|
if privs and privs.ctf_team_mgr == true then
|
||||||
|
minetest.chat_send_player(name, "/team lock <team> - closes a team to new players (ctf_team_mgr only)")
|
||||||
|
minetest.chat_send_player(name, "/team unlock <team> - opens a team to new players (ctf_team_mgr only)")
|
||||||
|
minetest.chat_send_player(name, "/team bjoin <team> <commands> - Command is * for all players, playername for one, !playername to remove (ctf_team_mgr only)")
|
||||||
minetest.chat_send_player(name, "/team join <name> <team> - add 'player' to team 'team' (ctf_team_mgr only)")
|
minetest.chat_send_player(name, "/team join <name> <team> - add 'player' to team 'team' (ctf_team_mgr only)")
|
||||||
minetest.chat_send_player(name, "/team removeply <name> - add 'player' to team 'team' (ctf_team_mgr only)")
|
minetest.chat_send_player(name, "/team removeply <name> - add 'player' to team 'team' (ctf_team_mgr only)")
|
||||||
end
|
end
|
||||||
@ -36,6 +39,8 @@ minetest.register_chatcommand("team", {
|
|||||||
local test = string.match(param, "^player ([%a%d_-]+)")
|
local test = string.match(param, "^player ([%a%d_-]+)")
|
||||||
local create = string.match(param, "^add ([%a%d_-]+)")
|
local create = string.match(param, "^add ([%a%d_-]+)")
|
||||||
local remove = string.match(param, "^remove ([%a%d_-]+)")
|
local remove = string.match(param, "^remove ([%a%d_-]+)")
|
||||||
|
local lock = string.match(param, "^lock ([%a%d_-]+)")
|
||||||
|
local lock = string.match(param, "^unlock ([%a%d_-]+)")
|
||||||
local j_name, j_tname = string.match(param, "^join ([%a%d_-]+) ([%a%d_]+)")
|
local j_name, j_tname = string.match(param, "^join ([%a%d_-]+) ([%a%d_]+)")
|
||||||
local b_tname, b_pattern = string.match(param, "^bjoin ([%a%d_-]+) ([%a%d_-%*%! ]+)")
|
local b_tname, b_pattern = string.match(param, "^bjoin ([%a%d_-]+) ([%a%d_-%*%! ]+)")
|
||||||
local l_name = string.match(param, "^removeplr ([%a%d_-]+)")
|
local l_name = string.match(param, "^removeplr ([%a%d_-]+)")
|
||||||
@ -66,6 +71,32 @@ minetest.register_chatcommand("team", {
|
|||||||
else
|
else
|
||||||
return false, "You are not a ctf_admin!"
|
return false, "You are not a ctf_admin!"
|
||||||
end
|
end
|
||||||
|
elseif lock then
|
||||||
|
local privs = minetest.get_player_privs(name)
|
||||||
|
if privs and privs.ctf_team_mgr then
|
||||||
|
local team = ctf.team(lock)
|
||||||
|
if team then
|
||||||
|
team.data.allow_joins = false
|
||||||
|
return true, "Locked team to new members"
|
||||||
|
else
|
||||||
|
return false, "Unable to find that team!"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return false, "You are not a ctf_team_mgr!"
|
||||||
|
end
|
||||||
|
elseif unlock then
|
||||||
|
local privs = minetest.get_player_privs(name)
|
||||||
|
if privs and privs.ctf_team_mgr then
|
||||||
|
local team = ctf.team(unlock)
|
||||||
|
if team then
|
||||||
|
team.data.allow_joins = true
|
||||||
|
return true, "Unlocked team to new members"
|
||||||
|
else
|
||||||
|
return false, "Unable to find that team!"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return false, "You are not a ctf_team_mgr!"
|
||||||
|
end
|
||||||
elseif param == "all" then
|
elseif param == "all" then
|
||||||
ctf.list_teams(name)
|
ctf.list_teams(name)
|
||||||
elseif ctf.team(param) then
|
elseif ctf.team(param) then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user