Fix nil team in ctf:settings callback

master
rubenwardy 2016-03-29 23:57:59 +01:00
parent cddcf97274
commit 8c073e1b0d
1 changed files with 20 additions and 12 deletions

View File

@ -28,20 +28,28 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- Settings page
if fields.save then
ctf.gui.show(name, "settings")
if ctf.flag_colors[fields.color] then
team.data.color = fields.color
ctf.needs_save = true
else
local colors = ""
for color, code in pairs(ctf.flag_colors) do
if colors ~= "" then
colors = colors .. ", "
local pdata = ctf.player(name)
local team = ctf.team(pdata.team)
if team and ctf.can_mod(name, pdata.team) then
if ctf.flag_colors[fields.color] then
team.data.color = fields.color
ctf.needs_save = true
else
local colors = ""
for color, code in pairs(ctf.flag_colors) do
if colors ~= "" then
colors = colors .. ", "
end
colors = colors .. color
end
colors = colors .. color
minetest.chat_send_player(name, "Color " .. fields.color ..
" does not exist! Available: " .. colors)
end
minetest.chat_send_player(name, "Color " .. fields.color ..
" does not exist! Available: " .. colors)
elseif team then
minetest.chat_send_player(name, "You don't have the rights to change settings.")
else
minetest.chat_send_player(name, "You don't appear to be in a team")
end
return true