Bugfix: scoreboard wasn't properly updated for the ones who joined an ongoing match

This commit is contained in:
Zughy 2020-11-09 00:42:57 +01:00
parent 65e40d98fe
commit d2245e4fce
6 changed files with 28 additions and 32 deletions

View File

@ -36,27 +36,31 @@ end
function block_league.scoreboard_update_score(arena, p_name, teamID)
function block_league.scoreboard_update_score(arena)
local panel = panel_lib.get_panel(p_name, "bl_scoreboard")
local score = 0
for pl_name, stats in pairs(arena.players) do
if arena.mod == 1 then
score = arena.teams[teamID].TDs
else
score = arena.teams[teamID].kills
end
local panel = panel_lib.get_panel(pl_name, "bl_scoreboard")
local score_red = 0
local score_blue = 0
if arena.mod == 1 then
score_red = arena.teams[1].TDs
score_blue = arena.teams[2].TDs
else
score_red = arena.teams[1].kills
score_blue = arena.teams[2].kills
end
panel:update(nil, {
team_red_score = {
text = score_red
},
team_blue_score = {
text = score_blue
}
})
if teamID == 1 then
panel:update(nil,
{team_red_score = {
text = score
}})
else
panel:update(nil,
{team_blue_score = {
text = score
}})
end
end

View File

@ -18,7 +18,7 @@ arena_lib.on_load("block_league", function(arena)
minetest.sound_play("bl_voice_countdown", {to_player = pl_name})
end
minetest.after(0.01, function()
minetest.after(0.1, function()
block_league.info_panel_update(arena)
end)
@ -42,9 +42,9 @@ arena_lib.on_join("block_league", function(p_name, arena)
minetest.sound_play("bl_voice_fight", {to_player = p_name})
minetest.after(0.01, function()
minetest.after(0.1, function()
block_league.info_panel_update(arena)
block_league.scoreboard_update_score(arena, p_name, arena.players[p_name].teamID)
block_league.scoreboard_update_score(arena)
end)
end)

View File

@ -314,10 +314,7 @@ function add_point(teamID, arena)
end
arena.teams[teamID].TDs = arena.teams[teamID].TDs + 1
for pl_name, stats in pairs(arena.players) do
block_league.scoreboard_update_score(arena, pl_name, teamID)
end
block_league.scoreboard_update_score(arena)
end

View File

@ -13,7 +13,6 @@ function block_league.round_start(arena)
block_league.refill_weapons(arena, p_name)
player:get_meta():set_int("bl_reloading", 0)
player:get_meta():set_int("bl_death_delay", 0)
player:set_physics_override({
speed = block_league.SPEED,

View File

@ -520,9 +520,6 @@ function kill(arena, p_name, target)
-- aggiorno HUD
block_league.info_panel_update(arena)
for pl_name, stats in pairs(arena.players) do
block_league.scoreboard_update_score(arena, pl_name, p_stats.teamID)
end
-- se è DM e il cap è raggiunto, finisce match
if arena.mod == 2 then

View File

@ -31,14 +31,13 @@ end)
minetest.register_on_dieplayer(function(player)
local p_name = player:get_player_name()
local arena = arena_lib.get_arena_by_player(p_name)
if not arena_lib.is_player_in_arena(p_name, "block_league") then return end
if not arena then return end
player:get_meta():set_int("bl_death_delay", 1)
block_league.immunity(player)
local arena = arena_lib.get_arena_by_player(p_name)
minetest.after(6, function()
if not arena_lib.is_player_in_arena(p_name, "block_league") or arena.weapons_disabled then return end
player:get_meta():set_int("bl_death_delay", 0)