WEAPON:SecondaryAttack

From Garry's Mod
Jump to: navigation, search
 WEAPON:SecondaryAttack( )

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 IsFirstTimePredicted.

NOTE This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.

Examples

Example

This is how it is defined in weapon_base

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.Owner:ViewPunch( Angle( -10, 0, 0 ) )

end


Personal tools
Navigation