Respond on failed /team requests

This commit is contained in:
rubenwardy 2016-03-31 18:52:48 +01:00
parent 5731eba276
commit 1cfb4ae8ef

View File

@ -36,7 +36,7 @@ minetest.register_chatcommand("team", {
local l_name = string.match(param, "^removeplr ([%a%d_-]+)") local l_name = string.match(param, "^removeplr ([%a%d_-]+)")
if create then if create then
local privs = minetest.get_player_privs(name) local privs = minetest.get_player_privs(name)
if privs and privs.ctf_admin == true then if privs and privs.ctf_admin then
if ( if (
string.match(create, "([%a%b_]-)") string.match(create, "([%a%b_]-)")
and create ~= "" and create ~= ""
@ -52,7 +52,7 @@ minetest.register_chatcommand("team", {
end end
elseif remove then elseif remove then
local privs = minetest.get_player_privs(name) local privs = minetest.get_player_privs(name)
if privs and privs.ctf_admin == true then if privs and privs.ctf_admin then
if ctf.remove_team(remove) then if ctf.remove_team(remove) then
return true, "Removed team '" .. remove .. "'" return true, "Removed team '" .. remove .. "'"
else else
@ -68,7 +68,7 @@ minetest.register_chatcommand("team", {
local count = 0 local count = 0
for _, value in pairs(ctf.team(param).players) do for _, value in pairs(ctf.team(param).players) do
count = count + 1 count = count + 1
if value.auth == true then if value.auth then
minetest.chat_send_player(name, count .. ">> " .. value.name minetest.chat_send_player(name, count .. ">> " .. value.name
.. " (team owner)") .. " (team owner)")
else else
@ -92,7 +92,7 @@ minetest.register_chatcommand("team", {
end end
elseif j_name and j_tname then elseif j_name and j_tname then
local privs = minetest.get_player_privs(name) local privs = minetest.get_player_privs(name)
if privs and privs.ctf_team_mgr == true then if privs and privs.ctf_team_mgr then
if ctf.join(j_name, j_tname, true, name) then if ctf.join(j_name, j_tname, true, name) then
return true, "Successfully added " .. j_name .. " to " .. j_tname return true, "Successfully added " .. j_name .. " to " .. j_tname
else else
@ -103,7 +103,7 @@ minetest.register_chatcommand("team", {
end end
elseif l_name then elseif l_name then
local privs = minetest.get_player_privs(name) local privs = minetest.get_player_privs(name)
if privs and privs.ctf_team_mgr == true then if privs and privs.ctf_team_mgr then
if ctf.remove_player(l_name) then if ctf.remove_player(l_name) then
return true, "Removed player " .. l_name return true, "Removed player " .. l_name
else else
@ -119,17 +119,23 @@ minetest.register_chatcommand("team", {
minetest.chat_send_player(name, "'"..param.."' is an invalid parameter to /team") minetest.chat_send_player(name, "'"..param.."' is an invalid parameter to /team")
team_console_help(name) team_console_help(name)
end end
if ( if ctf.setting("gui") then
ctf and if (ctf and
ctf.players and ctf.players and
ctf.players[name] and ctf.players[name] and
ctf.players[name].team and ctf.players[name].team) then
ctf.setting("gui") print("showing")
) then
ctf.gui.show(name) ctf.gui.show(name)
return true, "Showing the team window"
else
return false, "You're not part of a team!"
end
else
return false, "GUI is disabled!"
end end
end end
end, return false, "Nothing could be done"
end
}) })
minetest.register_chatcommand("join", { minetest.register_chatcommand("join", {