WEAPON:ShootBullet

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

Contents

Description

A convenience function to shoot bullets.

Arguments

number damage

The damage of the bullet

Arguments

number num_bullets

Amount of bullets to shoot

Arguments

number aimcone

Spread of bullets

Examples

Example

As defined in weapon_base

function SWEP:ShootBullet( damage, num_bullets, aimcone )
	
	local bullet = {}
	bullet.Num 	= num_bullets
	bullet.Src 	= self.Owner:GetShootPos() -- Source
	bullet.Dir 	= self.Owner:GetAimVector() -- Dir of bullet
	bullet.Spread 	= Vector( aimcone, aimcone, 0 )	 -- Aim Cone
	bullet.Tracer	= 5 -- Show a tracer on every x bullets 
	bullet.Force	= 1 -- Amount of force to give to phys objects
	bullet.Damage	= damage
	bullet.AmmoType = "Pistol"
	
	self.Owner:FireBullets( bullet )
	
	self:ShootEffects()
	
end


Personal tools
Navigation