Better help hints

master
rubenwardy 2015-11-22 01:40:28 +00:00
parent cd43aedca5
commit f8d56da0f0
3 changed files with 19 additions and 9 deletions

View File

@ -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

View File

@ -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)

View File

@ -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}
})