Prevent players from switching teams
This commit is contained in:
parent
e2a59cef6e
commit
aa12c0d2f7
@ -158,6 +158,7 @@ end
|
|||||||
function ctf.reset()
|
function ctf.reset()
|
||||||
ctf.log("io", "Deleting CTF save data...")
|
ctf.log("io", "Deleting CTF save data...")
|
||||||
os.remove(minetest.get_worldpath().."/ctf.txt")
|
os.remove(minetest.get_worldpath().."/ctf.txt")
|
||||||
|
ctf.player_last_team = {}
|
||||||
ctf.init()
|
ctf.init()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -142,6 +142,8 @@ function ctf.register_on_join_team(func)
|
|||||||
table.insert(ctf.registered_on_join_team, func)
|
table.insert(ctf.registered_on_join_team, func)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ctf.player_last_team = {}
|
||||||
|
|
||||||
-- Player joins team
|
-- Player joins team
|
||||||
-- Called by /join, /team join or auto allocate.
|
-- Called by /join, /team join or auto allocate.
|
||||||
function ctf.join(name, team, force, by)
|
function ctf.join(name, team, force, by)
|
||||||
@ -196,6 +198,7 @@ function ctf.join(name, team, force, by)
|
|||||||
|
|
||||||
player.team = team
|
player.team = team
|
||||||
team_data.players[player.name] = player
|
team_data.players[player.name] = player
|
||||||
|
ctf.player_last_team[name] = team
|
||||||
|
|
||||||
ctf.needs_save = true
|
ctf.needs_save = true
|
||||||
|
|
||||||
@ -265,6 +268,11 @@ function ctf.autoalloc(name, alloc_mode)
|
|||||||
if alloc_mode == 0 then
|
if alloc_mode == 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local last_team = ctf.player_last_team[name]
|
||||||
|
if last_team then
|
||||||
|
return last_team
|
||||||
|
end
|
||||||
|
|
||||||
local max_players = ctf.setting("maximum_in_team")
|
local max_players = ctf.setting("maximum_in_team")
|
||||||
|
|
||||||
local mtot = false -- more than one team
|
local mtot = false -- more than one team
|
||||||
|
Loading…
x
Reference in New Issue
Block a user