Fixed player join/leave
Fixed both saving new recruits, and also the /teamleave function
This commit is contained in:
parent
6e6631e1fb
commit
f0f3f5c0b3
@ -125,6 +125,7 @@ function ctf.remove_player(name)
|
||||
team.players[name] = nil
|
||||
end
|
||||
ctf.players[name] = nil
|
||||
ctf.needs_save = true
|
||||
return true
|
||||
else
|
||||
return false
|
||||
@ -139,6 +140,16 @@ function ctf.register_on_join_team(func)
|
||||
table.insert(ctf.registered_on_join_team, func)
|
||||
end
|
||||
|
||||
-- Player joins team
|
||||
-- Called by /join, /team join or auto allocate.
|
||||
ctf.registered_on_join_team = {}
|
||||
function ctf.register_on_join_team(func)
|
||||
if ctf._mt_loaded then
|
||||
error("You can't register callbacks at game time!")
|
||||
end
|
||||
table.insert(ctf.registered_on_join_team, func)
|
||||
end
|
||||
|
||||
-- Player joins team
|
||||
-- Called by /join, /team join or auto allocate.
|
||||
function ctf.join(name, team, force, by)
|
||||
@ -194,9 +205,10 @@ function ctf.join(name, team, force, by)
|
||||
player.team = team
|
||||
team_data.players[player.name] = player
|
||||
|
||||
ctf.needs_save = true
|
||||
|
||||
minetest.log("action", name .. " joined team " .. team)
|
||||
minetest.chat_send_all(name.." has joined team "..team)
|
||||
minetest.get_player_privs(name).initial_team_join = false
|
||||
|
||||
for i = 1, #ctf.registered_on_join_team do
|
||||
ctf.registered_on_join_team[i](name, team)
|
||||
|
@ -185,8 +185,8 @@ minetest.register_chatcommand("teamleave", {
|
||||
description = "Leave your team",
|
||||
func = function(name, param)
|
||||
local team = ctf.player(name).team
|
||||
if ctf.player(param).team ~= nil then
|
||||
if ctf.remove_player(param) then
|
||||
if ctf.player(name).team ~= nil then
|
||||
if ctf.remove_player(name) then
|
||||
return true, "You have left " .. team .. "!"
|
||||
else
|
||||
return false, "Failed to leave " .. team.. "!"
|
||||
|
Loading…
x
Reference in New Issue
Block a user