Respond on failed /team requests

master
rubenwardy 2016-03-31 18:52:48 +01:00
parent 5731eba276
commit 1cfb4ae8ef
1 changed files with 27 additions and 21 deletions

View File

@ -29,14 +29,14 @@ end
minetest.register_chatcommand("team", { minetest.register_chatcommand("team", {
description = "Open the team console, or run team command (see /team help)", description = "Open the team console, or run team command (see /team help)",
func = function(name, param) func = function(name, param)
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 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 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
@ -66,9 +66,9 @@ minetest.register_chatcommand("team", {
elseif ctf.team(param) then elseif ctf.team(param) then
minetest.chat_send_player(name, "Team "..param..":") minetest.chat_send_player(name, "Team "..param..":")
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
@ -115,21 +115,27 @@ minetest.register_chatcommand("team", {
elseif param=="help" then elseif param=="help" then
team_console_help(name) team_console_help(name)
else else
if param~="" and param~= nil then if param ~= "" and param ~= nil then
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", {