SWEP.CustomAmmoDisplay

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NameCustomAmmoDisplay
SyntaxSWEP:CustomAmmoDisplay( )
DescriptionThis function enables and disables parts of the ammo display.
ReturnsTable
Lua StateNewerClient.png
BBCode[b][url=wiki.garrysmod.com/?title=SWEP.CustomAmmoDisplay]SWEP.CustomAmmoDisplay [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]

Examples

DescriptionThis is a really simple way to draw the users ammo.
Used onNewerClient.png
Code
function SWEP:CustomAmmoDisplay()
	self.AmmoDisplay = self.AmmoDisplay or {} 
        //ineherit already created table or create a new one
 
	self.AmmoDisplay.Draw = true //draw the display?
 
	if self.Primary.ClipSize > 0 then
		self.AmmoDisplay.PrimaryClip = self:Clip1() //amount in clip
		self.AmmoDisplay.PrimaryAmmo = self:Ammo1() //amount in reserve
	end
	if self.Secondary.ClipSize > 0 then
		self.AmmoDisplay.SecondaryClip = self:Clip2()
		self.AmmoDisplay.SecondaryAmmo = self:Ammo2()
	end
 
	return self.AmmoDisplay //return the table
end
OutputN/A


Additional Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox