Revision Difference
WEAPON:SecondaryAttack#565033
<function name="SecondaryAttack" parent="WEAPON" type="hook">
	<description>
Called when secondary attack button ( +attack2 ) is pressed.
For issues with this hook being called rapidly on the client side, see the global function <page>Global.IsFirstTimePredicted</page>.
	</description>
	<realm>Shared</realm>
	<file line="66-L84">gamemodes/base/entities/weapons/weapon_base/shared.lua</file>⤶
	<predicted>Yes</predicted>
</function>⤶
⤶
<example>⤶
	<description>This is how it is defined in weapon_base</description>⤶
	<code>⤶
function SWEP:SecondaryAttack()⤶
⤶
	-- Make sure we can shoot first⤶
	if ( !self:CanSecondaryAttack() ) then return end⤶
⤶
	-- Play shoot sound⤶
	self.Weapon:EmitSound("Weapon_Shotgun.Single")⤶
	⤶
	-- Shoot 9 bullets, 150 damage, 0.75 aimcone⤶
	self:ShootBullet( 150, 9, 0.2 )⤶
	⤶
	-- Remove 1 bullet from our clip⤶
	self:TakeSecondaryAmmo( 1 )⤶
	⤶
	-- Punch the player's view⤶
	self:GetOwner():ViewPunch( Angle( -10, 0, 0 ) )⤶
⤶
end⤶
	</code>⤶
⤶
</example></function>
			Garry's Mod 
		
			Rust 
		
			Steamworks 
		
			Wiki Help