Fix team spawn on new player
This commit is contained in:
parent
17e7a2b529
commit
9196eec940
@ -339,23 +339,25 @@ function ctf.get_spawn(team)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_respawnplayer(function(player)
|
function ctf.move_to_spawn(name)
|
||||||
if not player then
|
local player = minetest.get_player_by_name(name)
|
||||||
return false
|
local tplayer = ctf.player(name)
|
||||||
end
|
if ctf.team(tplayer.team) then
|
||||||
|
local spawn = ctf.get_spawn(tplayer.team)
|
||||||
local name = player:get_player_name()
|
|
||||||
local team = ctf.player(name).team
|
|
||||||
|
|
||||||
if ctf.team(team) then
|
|
||||||
local spawn = ctf.get_spawn(team)
|
|
||||||
if spawn then
|
if spawn then
|
||||||
player:moveto(spawn, false)
|
player:moveto(spawn, false)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_respawnplayer(function(player)
|
||||||
|
if not player then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return ctf.move_to_spawn(player:get_player_name())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function ctf.get_territory_owner(pos)
|
function ctf.get_territory_owner(pos)
|
||||||
@ -386,11 +388,7 @@ minetest.register_on_newplayer(function(player)
|
|||||||
if team then
|
if team then
|
||||||
ctf.log("autoalloc", name .. " was allocated to " .. team)
|
ctf.log("autoalloc", name .. " was allocated to " .. team)
|
||||||
ctf.join(name, team)
|
ctf.join(name, team)
|
||||||
|
ctf.move_to_spawn(player:get_player_name())
|
||||||
local spawn = ctf.get_spawn(team)
|
|
||||||
if spawn then
|
|
||||||
player:moveto(spawn, false)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -400,20 +398,20 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if ctf.team(ctf.player(name).team) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local alloc_mode = tonumber(ctf.setting("allocate_mode"))
|
local alloc_mode = tonumber(ctf.setting("allocate_mode"))
|
||||||
if alloc_mode == 0 then
|
if alloc_mode == 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local name = player:get_player_name()
|
|
||||||
local team = ctf.autoalloc(name, alloc_mode)
|
local team = ctf.autoalloc(name, alloc_mode)
|
||||||
if team then
|
if team then
|
||||||
ctf.log("autoalloc", name .. " was allocated to " .. team)
|
ctf.log("autoalloc", name .. " was allocated to " .. team)
|
||||||
ctf.join(name, team)
|
ctf.join(name, team)
|
||||||
|
ctf.move_to_spawn(player:get_player_name())
|
||||||
local spawn = ctf.get_spawn(team)
|
|
||||||
if spawn then
|
|
||||||
player:moveto(spawn, false)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -186,8 +186,9 @@ ctf_flag = {
|
|||||||
-- add flag
|
-- add flag
|
||||||
ctf_flag.add(team, pos)
|
ctf_flag.add(team, pos)
|
||||||
|
|
||||||
if ctf.teams[team].spawn and minetest.get_node(ctf.teams[team].spawn).name == "ctf_flag:flag" then
|
if ctf.teams[team].spawn and not ctf.setting("flag.allow_multiple") and
|
||||||
if not ctf.setting("flag.allow_multiple") then
|
minetest.get_node(ctf.teams[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(team.."'s flag has been moved")
|
||||||
minetest.set_node(ctf.team(team).spawn,{name="air"})
|
minetest.set_node(ctf.team(team).spawn,{name="air"})
|
||||||
@ -198,9 +199,6 @@ ctf_flag = {
|
|||||||
},{name="air"})
|
},{name="air"})
|
||||||
ctf.team(team).spawn = pos
|
ctf.team(team).spawn = pos
|
||||||
end
|
end
|
||||||
else
|
|
||||||
ctf.get_spawn(team)
|
|
||||||
end
|
|
||||||
|
|
||||||
ctf.needs_save = true
|
ctf.needs_save = true
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user