Garry's Mod Wiki

Revision Difference

WEAPON:CustomAmmoDisplay#517941

<function name="CustomAmmoDisplay" parent="WEAPON" type="hook"> <ishook>yes</ishook> <description> Allows you to use any numbers you want for the ammo display on the HUD. Can be useful for weapons that don't use standard ammo. </description> <realm>Client</realm> <predicted>No</predicted> <rets> <ret name="" type="table">The new ammo display settings. A table with 4 possible keys: * <page>boolean</page> Draw - Whether to draw the ammo display or not * <page>number</page> PrimaryClip - Amount of primary ammo in the clip * <page>number</page> PrimaryAmmo - Amount of primary ammo in the reserves * <page>number</page> SecondaryAmmo - Amount of secondary ammo. It is shown like alt-fire for SMG1 and AR2 are shown. There is **no** SecondaryClip!</ret> </rets> </function> <example> <description>How it would look with standard information</description> <code> function SWEP:CustomAmmoDisplay() self.AmmoDisplay = self.AmmoDisplay or {} self.AmmoDisplay.Draw = true //draw the display? if self.Primary.ClipSize &amp;gt; 0 then if self.Primary.ClipSize &gt; 0 then self.AmmoDisplay.PrimaryClip = self:Clip1() //amount in clip self.AmmoDisplay.PrimaryAmmo = self:Ammo1() //amount in reserve end if self.Secondary.ClipSize &amp;gt; 0 then if self.Secondary.ClipSize &gt; 0 then self.AmmoDisplay.SecondaryAmmo = self:Ammo2() // amount of secondary ammo end return self.AmmoDisplay //return the table end </code> </example>