diff --git a/ctf/hud.lua b/ctf/hud.lua index ee1e59d..09c17fb 100644 --- a/ctf/hud.lua +++ b/ctf/hud.lua @@ -13,7 +13,7 @@ function ctf.hud.update(player) return end - local name = player:get_player_name() + local name = player:get_player_name() local tplayer = ctf.player(name) if not tplayer or not tplayer.team or not ctf.team(tplayer.team) then diff --git a/ctf_colors/init.lua b/ctf_colors/init.lua index 3917430..bd5c359 100644 --- a/ctf_colors/init.lua +++ b/ctf_colors/init.lua @@ -41,13 +41,13 @@ ctf.hud.register_part(function(player, name, tplayer) hud_elem_type = "text", position = {x = 1, y = 0}, scale = {x = 100, y = 100}, - text = tplayer.team, + text = "Team " .. tplayer.team, number = color, offset = {x = -20, y = 20}, alignment = {x = -1, y = 0} }) else - ctf.hud:change(player, "ctf:hud_team", "text", tplayer.team) + ctf.hud:change(player, "ctf:hud_team", "text", "Team " .. tplayer.team) ctf.hud:change(player, "ctf:hud_team", "number", color) end end) diff --git a/ctf_flag/init.lua b/ctf_flag/init.lua index 45af971..a57f9a8 100644 --- a/ctf_flag/init.lua +++ b/ctf_flag/init.lua @@ -80,25 +80,35 @@ ctf.hud.register_part(function(player, name, tplayer) end) ctf.hud.register_part(function(player, name, tplayer) - local alert = nil - local team = ctf.team(tplayer.team) - for _, flag in pairs(team.flags) do - if flag.claimed then + -- Check all flags + local alert = "Punch the enemy flag! Protect your flag!" + local color = "0xFFFFFF" + local claimed = ctf_flag.collect_claimed() + for _, flag in pairs(claimed) do + if flag.claimed.player == name then + alert = "You've got the flag! Run back and punch your flag!" + color = "0xFF0000" + elseif flag.team == tplayer.team then alert = "Kill " .. flag.claimed.player .. ", they have your flag!" - break + color = "0xFF0000" + else + alert = "Protect " .. flag.claimed.player .. ", he's got the enemy flag!" + color = "0xFF0000" end end + -- Display alert if alert then if ctf.hud:exists(player, "ctf:hud_team_alert") then ctf.hud:change(player, "ctf:hud_team_alert", "text", alert) + ctf.hud:change(player, "ctf:hud_team_alert", "number", color) else ctf.hud:add(player, "ctf:hud_team_alert", { hud_elem_type = "text", position = {x = 1, y = 0}, scale = {x = 100, y = 100}, text = alert, - number = "0xFF0000", + number = color, offset = {x = -10, y = 50}, alignment = {x = -1, y = 0} })