More team commands
This commit is contained in:
parent
9dbdf72c21
commit
56d19a90e1
@ -3,10 +3,22 @@ minetest.register_privilege("team",{
|
||||
description = "Team manager",
|
||||
})
|
||||
|
||||
local function team_console_help(name)
|
||||
minetest.chat_send_player(name,"Try:",false)
|
||||
minetest.chat_send_player(name,"/team - show team panel",false)
|
||||
minetest.chat_send_player(name,"/team all - list all teams",false)
|
||||
minetest.chat_send_player(name,"/team name - show details about team 'name'",false)
|
||||
minetest.chat_send_player(name,"/team player name - get which team 'player' is in",false)
|
||||
minetest.chat_send_player(name,"/team add name - add a team called name (admin only)",false)
|
||||
minetest.chat_send_player(name,"/team join player team - add 'player' to team 'team' (admin only)",false)
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("team", {
|
||||
description = "Open the team console",
|
||||
description = "Open the team console, or run team command (see /team help)",
|
||||
func = function(name, param)
|
||||
local test = string.match(param,"player (.-)")
|
||||
local test = string.match(param,"^player ([%a%d_]+)")
|
||||
local create = string.match(param,"^add ([%a%d_]+)")
|
||||
local tplayer,tteam = string.match(param,"^join ([%a%d_]+) ([%a%d_]+)")
|
||||
if test then
|
||||
print("is a player request "..test)
|
||||
|
||||
@ -20,6 +32,39 @@ minetest.register_chatcommand("team", {
|
||||
else
|
||||
minetest.chat_send_player(name,test.." is not in a team",false)
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(name,"Player '"..test.."' could not be found",false)
|
||||
end
|
||||
elseif create then
|
||||
local privs = minetest.get_player_privs(name)
|
||||
if privs and privs.team == true then
|
||||
if (
|
||||
string.match(create,"([%a%b_]-)")
|
||||
and cf.team({name=create,add_team=true})
|
||||
and create ~= ""
|
||||
and create ~= nil
|
||||
) then
|
||||
minetest.chat_send_player(name, "Added team '"..create.."'",false)
|
||||
else
|
||||
minetest.chat_send_player(name, "Error adding team '"..create.."'",false)
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(name, "You can not do this!",false)
|
||||
end
|
||||
elseif param == "all" then
|
||||
minetest.chat_send_player(name, "Teams:",false)
|
||||
for k,v in pairs(cf.teams) do
|
||||
if v and v.players then
|
||||
local numItems = 0
|
||||
for k,v in pairs(v.players) do
|
||||
numItems = numItems + 1
|
||||
end
|
||||
local numItems2 = 0
|
||||
for k,v in pairs(v.flags) do
|
||||
numItems2 = numItems2 + 1
|
||||
end
|
||||
minetest.chat_send_player(name, ">> "..k.." ("..numItems2.." flags, "..numItems.." players)",false)
|
||||
end
|
||||
end
|
||||
elseif cf.team(param) then
|
||||
minetest.chat_send_player(name,"Team "..param..":",false)
|
||||
@ -32,13 +77,36 @@ minetest.register_chatcommand("team", {
|
||||
minetest.chat_send_player(name,count..">> "..value.name,false)
|
||||
end
|
||||
end
|
||||
elseif
|
||||
elseif tplayer and tteam then
|
||||
minetest.chat_send_player(name,"joining '"..tplayer.."' to team '"..tteam.."'",false)
|
||||
local privs = minetest.get_player_privs(name)
|
||||
if privs and privs.team == true then
|
||||
local player = cf.player(name)
|
||||
|
||||
if not player then
|
||||
player = {name=name}
|
||||
end
|
||||
|
||||
if cf.add_user(param,player) == true then
|
||||
minetest.chat_send_all(name.." has joined team "..param)
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(name, "You can not do this!")
|
||||
end
|
||||
elseif param=="help" then
|
||||
team_console_help(name)
|
||||
else
|
||||
if param~="" and param~= nil then
|
||||
minetest.chat_send_player(name,"'"..param.."' is an invalid parameter to /team",false)
|
||||
team_console_help(name)
|
||||
end
|
||||
if (
|
||||
cf and
|
||||
cf.players and
|
||||
cf.players[name] and
|
||||
cf.players[name].team and
|
||||
cf.setting("gui")
|
||||
then
|
||||
) then
|
||||
if cf.setting("team_gui_initial") == "news" and cf.setting("news_gui") then
|
||||
cf.gui.team_board(name,cf.players[name].team)
|
||||
elseif cf.setting("team_gui_initial") == "flags" and cf.setting("flag_teleport_gui") then
|
||||
@ -51,6 +119,7 @@ minetest.register_chatcommand("team", {
|
||||
cf.gui.team_board(name,cf.players[name].team)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
@ -64,6 +133,10 @@ minetest.register_chatcommand("join", {
|
||||
player = {name=name}
|
||||
end
|
||||
|
||||
if not cf.setting("players_can_change_team") and (not player.team or player.team=="") then
|
||||
minetest.chat_send_player(name,"You are not allowed to switch teams, traitor!",false)
|
||||
end
|
||||
|
||||
if cf.add_user(param,player) == true then
|
||||
minetest.chat_send_all(name.." has joined team "..param)
|
||||
end
|
||||
@ -71,8 +144,9 @@ minetest.register_chatcommand("join", {
|
||||
})
|
||||
minetest.register_chatcommand("list_teams", {
|
||||
params = "",
|
||||
description = "List all avaliable teams",
|
||||
description = "List all available teams",
|
||||
func = function(name, param)
|
||||
minetest.chat_send_player(name, "This command will be made obsolete! Use '/team all' instead!",false)
|
||||
minetest.chat_send_player(name, "Teams:")
|
||||
for k,v in pairs(cf.teams) do
|
||||
if v and v.players then
|
||||
@ -84,7 +158,7 @@ minetest.register_chatcommand("list_teams", {
|
||||
for k,v in pairs(v.flags) do
|
||||
numItems2 = numItems2 + 1
|
||||
end
|
||||
minetest.chat_send_player(name, ">> "..k.." ("..numItems2.." flags, "..numItems.." players)")
|
||||
minetest.chat_send_player(name, ">> "..k.." ("..numItems2.." flags, "..numItems.." players)",false)
|
||||
end
|
||||
end
|
||||
end,
|
||||
@ -95,10 +169,11 @@ minetest.register_chatcommand("ateam", {
|
||||
description = "Create a team",
|
||||
privs = {team=true},
|
||||
func = function(name, param)
|
||||
if string.match(param,"([%a%b_]-)") and cf.team({name=param,add_team=true}) then
|
||||
minetest.chat_send_player(name, "Added team "..param)
|
||||
minetest.chat_send_player(name, "This command will be made obsolete! Use '/team add name' instead!",false)
|
||||
if string.match(param,"([%a%b_]-)") and cf.team({name=param,add_team=true}) and param ~= "" and param~= nil then
|
||||
minetest.chat_send_player(name, "Added team "..param,false)
|
||||
else
|
||||
minetest.chat_send_player(name, "Error adding team "..param)
|
||||
minetest.chat_send_player(name, "Error adding team "..param,false)
|
||||
end
|
||||
end,
|
||||
})
|
||||
@ -123,20 +198,20 @@ minetest.register_chatcommand("reload_ctf", {
|
||||
|
||||
minetest.register_chatcommand("team_owner", {
|
||||
params = "player name",
|
||||
description = "Create a team",
|
||||
description = "Make player team owner",
|
||||
privs = {team=true},
|
||||
func = function(name, param)
|
||||
if cf and cf.players and cf.player(param) and cf.player(param).team and cf.team(cf.player(param).team) then
|
||||
if cf.player(param).auth == true then
|
||||
cf.player(param).auth = false
|
||||
minetest.chat_send_player(name, param.." was downgraded from team admin status")
|
||||
minetest.chat_send_player(name, param.." was downgraded from team admin status",false)
|
||||
else
|
||||
cf.player(param).auth = true
|
||||
minetest.chat_send_player(name, param.." was upgraded to an admin of "..cf.player(name).team)
|
||||
minetest.chat_send_player(name, param.." was upgraded to an admin of "..cf.player(name).team,false)
|
||||
end
|
||||
cf.save()
|
||||
else
|
||||
minetest.chat_send_player(name, "Player "..param.." does not exist")
|
||||
minetest.chat_send_player(name, "Player "..param.." does not exist",false)
|
||||
end
|
||||
end,
|
||||
})
|
||||
@ -146,7 +221,7 @@ minetest.register_chatcommand("all", {
|
||||
description = "Send a message on the global channel",
|
||||
func = function(name, param)
|
||||
if not cf.setting("global_channel") then
|
||||
minetest.chat_send_player(name,"The global channel is disabled")
|
||||
minetest.chat_send_player(name,"The global channel is disabled",false)
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -25,6 +25,7 @@ function cf.init()
|
||||
cf._set("flag_names",true) -- can flags be named
|
||||
cf._set("team_channel",true) -- do teams have their own chat channel
|
||||
cf._set("global_channel",true) -- Can players chat with other teams on /all. If team_channel is false, this does nothing.
|
||||
cf._set("players_can_change_team",true)
|
||||
|
||||
-- Settings: Teams
|
||||
--cf._set("allocate_mode",0) -- (COMING SOON):how are players allocated to teams?
|
||||
|
Loading…
x
Reference in New Issue
Block a user