Hi
I need help with getting ammo to display in the hud, so far i can get health to display but not ammo. The hud file is as follows:
[lua]function myhud()
local client = LocalPlayer()
if !client:Alive() then return end
if(client:GetActiveWeapon() == NULL or client:GetActiveWeapon() == "Camera") then return end
draw.RoundedBox(0, 5, 5, 200, 25, Color(100, 0, 0, 225))
draw.SimpleText(client:Health() .. "", "ScoreboardText", 95,10, Color(255, 255, 255, 255), 0, 0)
local mag_left = client:GetActiveWeapon():Clip1() // How much ammunition you have inside the current magazine
local mag_extra = client:GetAmmoCount(client:GetActiveWeapon():GetPrimaryAmmoType()) // How much ammunition you have outside the current magazine
local secondary_ammo = client:GetAmmoCount(client:GetActiveWeapon():GetSecondaryAmmoType())// How much ammunition you have for your secondary fire, such as the MP7's grenade launcher
end
hook.Add("HUDPaint", "myhud", myhud)
function hidehud(name)
for k, v in pairs{"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"} do
if name == v then return false end
end
end
hook.Add("HUDShouldDraw", "hidehud", hidehud)[/lua]
I haven't added a function for displaying ammo because i don't have a clue what it is, i tryed replacing [lua]draw.SimpleText(client:Health() .. "", "ScoreboardText", 95,10, Color(255, 255, 255, 255), 0, 0)[/lua]
with this [lua]draw.SimpleText(client:Ammo() .. "", "ScoreboardText", 95,10, Color(255, 255, 255, 255), 0, 0)[/lua] But i just received a nil value.
Any help appreciated.
ply:Ammo() Does not exist ;)
try that
[lua]
client:GetActiveWeapon():Clip1()
[/lua]
Should work
Worked like a charm, thanks very much.
You're Welcome.. And so on
Sorry, you need to Log In to post a reply to this thread.