Add ctf_map.get_team_relative_z() and ctf_map.can_cross()

This commit is contained in:
rubenwardy 2019-03-17 03:32:15 +00:00
parent d9f8042640
commit e3a8f95f59
2 changed files with 15 additions and 10 deletions

View file

@ -246,16 +246,10 @@ if minetest.get_modpath("ctf") then
end end
for _, player in pairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name() if ctf_map.get_team_relative_z(player) < 0 and not ctf_map.can_cross(player) then
local tname = ctf.player(name).team local name = player:get_player_name()
local pos = player:get_pos() minetest.chat_send_player(name, "Match hasn't started yet!")
local privs = minetest.get_player_privs(name) ctf.move_to_spawn(name)
if tname and not privs.fly and privs.interact then
if (tname == "blue" and pos.z >= 0) or
(tname == "red" and pos.z <= 0) then
minetest.chat_send_player(name, "Match hasn't started yet!")
ctf.move_to_spawn(name)
end
end end
end end

View file

@ -1,5 +1,16 @@
ctf_map = {} ctf_map = {}
function ctf_map.get_team_relative_z(player)
local name = player:get_player_name()
local tname = ctf.player(name).team
return (tname == "red" and 1 or -1) * player:get_pos().z
end
-- Overridden by server mods
function ctf_map.can_cross(player)
return false
end
dofile(minetest.get_modpath("ctf_map") .. "/nodes.lua") dofile(minetest.get_modpath("ctf_map") .. "/nodes.lua")
dofile(minetest.get_modpath("ctf_map") .. "/emerge.lua") dofile(minetest.get_modpath("ctf_map") .. "/emerge.lua")
dofile(minetest.get_modpath("ctf_map") .. "/barrier.lua") dofile(minetest.get_modpath("ctf_map") .. "/barrier.lua")