Need Local variables for primary and secondary ammo.

Okay, I’ve been working on this District 9-themed HUD and unfortunately I’ve gotten stuck on the code because I can’t find the variable for LocalPlayer that represents the primary and secondary ammo. Can someone tell me what it is?

Here is the code I have so far:

[lua]function HideHudBits( name )
if ( name == “CHudHealth” or name == “CHudBattery” or name == “CHudAmmo” or name == “CHudScondaryAmmo” or name == “CHudPoisonDamageIndicator”) then
return false
end
end

hook.Add( “HUDShouldDraw”, “HideHudBits”, HideHudBits )
surface.CreateFont( “D9 non-humans”, 100, 400, false, false, “D9NonHumans” )
hook.Add ( “HUDPaint”, “D9HudPaint”, function()

	local hudPlayer = LocalPlayer()
    local hudHealth = hudPlayer:Health()
    local hudArmor = hudPlayer:Armor()
	local hudammo = hudPlayer: --First part I'm stuck on
	local hud2ammo = hudPlayer: --Second part I'm stuck on

	surface.SetTextColor( 255, 0, 0, 255 )
    surface.SetTextPos( 9, (ScrH()/2) + (ScrH()/4) )
    surface.SetFont("D9NonHumans")
	surface.DrawText( hudHealth )

    surface.SetTextColor(221, 111, 0, 255)
    surface.SetTextPos( 9, (ScrH()/2) + (ScrH()/6) )
    surface.SetFont("D9NonHumans")
	surface.DrawText( hudArmor )

	surface.SetTextColor(0, 0, 255, 255)
	surface.SetTextPos( 9, (ScrH()/2) + (ScrH()/8) )
	surface.SetFont("D9NonHumans")
	surface.DrawText( hudAmmo )

	surface.SetTextColor(0, 255, 0, 255)
	surface.SetTextPos (9, (ScrH()/2) + (ScrH()/10) )
	surface.SetFont("D9NonHumans")
	surface.DrawText( hud2ammo )

	draw.RoundedBox(0, 5, ScrH() -160 -20, hudHealth, 15, Color(255,0,0,255))
	draw.RoundedBox(0, 5, ScrH() -240 -20, hudArmor, 15, Color(221,111,0,255))
	draw.RoundedBox(0, 5, ScRH() -320 -20, hudAmmo, 15, Color(0, 0, 255, 255))
	draw.RoundedBox(0, 5, ScRH() -400 -20, hud2ammo, 15, Color(0, 255, 0, 255))

end)
[/lua]

I believe this is what you want.

**[Weapon.GetPrimaryAmmoType

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Weapon.GetPrimaryAmmoType)**

**[Weapon.GetSecondaryAmmoType

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Weapon.GetSecondaryAmmoType)**

Edit:
Also, don’t forget this.

**[Player.GetActiveWeapon

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.GetActiveWeapon)**

And this

**[Player.GetAmmoCount

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.GetAmmoCount)**

If I use these how do I add them into my code. I’m still a bit of a newbie. -_-’

[lua]if (LocalPlayer():GetActiveWeapon():IsValid()) then
local Ammo1 = LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType())
local Ammo2 = LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetSecondaryAmmoType())
local Current_Ammo = LocalPlayer():GetActiveWeapon():Clip1()
end[/lua]

Just an example. There’s some examples on the links I sent you, too.

Thanks for the help I finally got it working!

No problem. If you need anything else, feel free to ask.