SWEP.CanPrimaryAttack

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NameCanPrimaryAttack
SyntaxSWEP:CanPrimaryAttack( )
DescriptionChecks whether the clip is empty(or the owner's ammo if it is a clip-less weapon) and ticks if not.
ReturnsBoolean
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=SWEP.CanPrimaryAttack]SWEP.CanPrimaryAttack [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]

Definition of the function

Because it is a convenience function, it is defined by the game. (Source Code)

function SWEP:CanPrimaryAttack()
 
	if ( self:Clip1() <= 0 ) then
 
		self:EmitSound( "Weapon_Pistol.Empty" )
		self:SetNextPrimaryFire( CurTime() + 0.2 )
		self:Reload()
		return false
 
	end
 
	return true
 
end

Examples

DescriptionN/A
Used onNewerMissing.png
Code
LuaIco3.pngThis page needs an example to demonstrate the item detailed on this page. See how to make one here.
See more articles that need examples here.
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox