Add privilege for placing flag. Fix bug in after_place_node
This commit is contained in:
parent
cbb838eb40
commit
f024f83e85
@ -1,2 +1,3 @@
|
|||||||
ctf
|
ctf
|
||||||
ctf_colors
|
ctf_colors
|
||||||
|
chatplus?
|
||||||
|
@ -181,37 +181,49 @@ ctf_flag = {
|
|||||||
meta:set_string("infotext", "Unowned flag")
|
meta:set_string("infotext", "Unowned flag")
|
||||||
end,
|
end,
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local name = name
|
local name = placer:get_player_name()
|
||||||
|
|
||||||
if not pos or not name then
|
if not pos or not name then
|
||||||
|
minetest.set_node(pos, {name="air"})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
if not meta then
|
if not meta then
|
||||||
|
minetest.set_node(pos, {name="air"})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if ctf.players and ctf.players[name] and ctf.players[name].team then
|
local tplayer = ctf.player_or_nil(name)
|
||||||
local team = ctf.players[name].team
|
if tplayer and ctf.team(tplayer.team) then
|
||||||
meta:set_string("infotext", team.."'s flag")
|
if not minetest.check_player_privs(name, {ctf_place_flag=true}) then
|
||||||
|
minetest.chat_send_player(name, "You're not allowed to place flags! Reported to admin for investigation.")
|
||||||
|
minetest.set_node(pos, {name="air"})
|
||||||
|
if minetest.global_exists("chatplus") then
|
||||||
|
chatplus.send_mail("*SERVER*", minetest.setting_get("name"),
|
||||||
|
"player " .. name .. " attempted to place flag!")
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local tname = tplayer.team
|
||||||
|
local team = ctf.team(tplayer.team)
|
||||||
|
meta:set_string("infotext", tname.."'s flag")
|
||||||
|
|
||||||
-- add flag
|
-- add flag
|
||||||
ctf_flag.add(team, pos)
|
ctf_flag.add(tname, pos)
|
||||||
|
|
||||||
if ctf.teams[team].spawn and not ctf.setting("flag.allow_multiple") and
|
-- TODO: fix this hackiness
|
||||||
minetest.get_node(ctf.teams[team].spawn).name ==
|
if team.spawn and not ctf.setting("flag.allow_multiple") and
|
||||||
"ctf_flag:flag" then
|
minetest.get_node(team.spawn).name == "ctf_flag:flag" then
|
||||||
-- send message
|
-- send message
|
||||||
minetest.chat_send_all(team.."'s flag has been moved")
|
minetest.chat_send_all(tname .. "'s flag has been moved")
|
||||||
minetest.set_node(ctf.team(team).spawn,{name="air"})
|
minetest.set_node(team.spawn, {name="air"})
|
||||||
minetest.set_node({
|
minetest.set_node({
|
||||||
x=ctf.team(team).spawn.x,
|
x = team.spawn.x,
|
||||||
y=ctf.team(team).spawn.y+1,
|
y = team.spawn.y+1,
|
||||||
z=ctf.team(team).spawn.z
|
z = team.spawn.z
|
||||||
}, {name="air"})
|
}, {name="air"})
|
||||||
ctf.team(team).spawn = pos
|
team.spawn = pos
|
||||||
end
|
end
|
||||||
|
|
||||||
ctf.needs_save = true
|
ctf.needs_save = true
|
||||||
@ -222,16 +234,16 @@ ctf_flag = {
|
|||||||
z = pos.z
|
z = pos.z
|
||||||
}
|
}
|
||||||
|
|
||||||
if not ctf.team(team).data.color then
|
if not team.data.color then
|
||||||
ctf.team(team).data.color = "red"
|
team.data.color = "red"
|
||||||
ctf.needs_save = true
|
ctf.needs_save = true
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.set_node(pos2, {name="ctf_flag:flag_top_"..ctf.team(team).data.color})
|
minetest.set_node(pos2, {name="ctf_flag:flag_top_"..team.data.color})
|
||||||
|
|
||||||
local meta2 = minetest.get_meta(pos2)
|
local meta2 = minetest.get_meta(pos2)
|
||||||
|
|
||||||
meta2:set_string("infotext", team.."'s flag")
|
meta2:set_string("infotext", tname.."'s flag")
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, "You are not part of a team!")
|
minetest.chat_send_player(name, "You are not part of a team!")
|
||||||
minetest.set_node(pos, {name="air"})
|
minetest.set_node(pos, {name="air"})
|
||||||
|
@ -12,9 +12,12 @@ ctf.register_on_init(function()
|
|||||||
ctf._set("flag.drop_warn_time", 60)
|
ctf._set("flag.drop_warn_time", 60)
|
||||||
ctf._set("gui.team.teleport_to_flag", true)
|
ctf._set("gui.team.teleport_to_flag", true)
|
||||||
ctf._set("gui.team.teleport_to_spawn", false)
|
ctf._set("gui.team.teleport_to_spawn", false)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
minetest.register_privilege("ctf_place_flag", {
|
||||||
|
description = "can place flag"
|
||||||
|
})
|
||||||
|
|
||||||
dofile(minetest.get_modpath("ctf_flag") .. "/hud.lua")
|
dofile(minetest.get_modpath("ctf_flag") .. "/hud.lua")
|
||||||
dofile(minetest.get_modpath("ctf_flag") .. "/gui.lua")
|
dofile(minetest.get_modpath("ctf_flag") .. "/gui.lua")
|
||||||
dofile(minetest.get_modpath("ctf_flag") .. "/flag_func.lua")
|
dofile(minetest.get_modpath("ctf_flag") .. "/flag_func.lua")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user