WEAPON/ShootBullet

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(get rid of the example, this is what the "View source" button is for)
 
Line 1: Line 1:
 
{{Hook
 
{{Hook
 
|Description=A convenience function to shoot bullets.
 
|Description=A convenience function to shoot bullets.
 
{{Bug|Pull=1502|Fixed=|This does not take SWEP.Primary/Secondary.Ammo into account.}}
 
 
|Realm=Shared
 
|Realm=Shared
 
|Predicted=No
 
|Predicted=No
Line 40: Line 38:
 
|desc=Show a tracer on every x bullets
 
|desc=Show a tracer on every x bullets
 
|default=5
 
|default=5
}}
 
{{Example
 
|Description=As defined in weapon_base
 
|Code=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
 
 
}}
 
}}

Latest revision as of 16:57, 12 November 2019

 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

Arguments

string ammo_type=self.Primary.Ammo

Ammo type of the bullets

Arguments

number force=1

Force of the bullets

Arguments

number tracer=5

Show a tracer on every x bullets
Personal tools
Navigation