• CustomAmmoDisplay not showing secondary ammo
    6 replies, posted
I'm trying to make a SWEP that shows progress in the secondary ammo, but the secondary ammo isn't showing unless I set it to 0. [code]function SWEP:CustomAmmoDisplay() self.AmmoDisplay = self.AmmoDisplay or {} self.AmmoDisplay.Draw = true self.AmmoDisplay.PrimaryClip = self.Weapon:Clip1() self.AmmoDisplay.PrimaryAmmo = self.Weapon:Clip2() self.AmmoDisplay.SecondaryClip = self.Weapon:Clip2() self.AmmoDisplay.SecondaryAmmo = self.Weapon:Clip2() return self.AmmoDisplay end[/code] I'm setting everything but the primary clip to Clip2() to make sure the progress is shown, though I've also tried only using one of each, as well as removing them all (since it should show Clip2() by default anyway), but it only shows 0. What am I doing wrong?
To do mine, i've set a variable for SWEP, and defined client [lua]local SWEP = client:GetActiveWeapon() local client = LocalPlayer()[/lua] Then: [lua]client:GetAmmoCount(SWEP:GetSecondaryAmmoType())[/lua] For that ( above ) you can just local it so you can call it later instead of typing that out again. [lua]local SecondaryAmmo = client:GetAmmoCount(SWEP:GetSecondaryAmmoType()) [/lua]
It's not actual ammo I'm trying to show though, but a custom "progress" indicator. I'm just setting the progress by using self.Weapon:SetClip2(<progress>), I'm not using any kind of actual ammo since that would be very impractical. The problem I have is that the AmmoDisplay.(SecondaryClip/SecondaryAmmo/PrimaryAmmo) isn't showing up on the HUD unless it's 0.
Because I don't think Clip2 is valid.
Wouldn't that return an error about the Clip2() function being null, though? Or returning a null value?
No, I just don't think Clip2 works, use my method instead [lua]client:GetAmmoCount(SWEP:GetSecondaryAmmoType())[/lua] If that doesn't work, then something else is wrong, because that works for me. But if you do use that peice of code, remember to define client and SWEP, as shown in my first reply.
Clip2() works, I know that since I use it to measure the progress and the SWEP reacts when the progress is done. The secondary ammo just isn't showing up. Another reason I can't use your piece of code is because GetAmmoCount() returns the amount of a certain type of ammo the player has, but as I said earlier, I'm not using ammo to measure the progress, I'm using the custom number I put in the secondary clip using SetClip2(<number>). The problem here isn't about what's put into AmmoDisplay.SecondaryClip, it is that the CustomAmmoDisplay isn't showing the secondary clip unless it's 0.
Sorry, you need to Log In to post a reply to this thread.