From GMod Wiki
Event Hook
|
Hook Name | ShootBullet
|
Syntax | SWEP:ShootBullet( Integer Damage, Integer Number of Shots, Float Aim Cone )
|
Description | Fires a bullet
|
Returns | Nil
|
Lua State |
|
BBCode | [b][url=wiki.garrysmod.com/?title=SWEP.ShootBullet]SWEP.ShootBullet [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
|
Examples
Description | Because it is a convenience function, it is defined by the game.(Source Code) |
Used on | |
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.TracerName = "Tracer" // what Tracer Effect should be used
bullet.Force = 1 // Amount of force to give to phys objects
bullet.Damage = damage
bullet.AmmoType = "Pistol"
self.Owner:FireBullets( bullet )
self:ShootEffects()
end |
Output | N/A |
Additional Notes
- You can override it to specify your bullet.
- To use it as such simply call self:ShootBullet()
- Some usable tracer effects:
AR2Tracer - Self-descripting. Visible from all directions except under it
AirboatGunHeavyTracer - Makes a bigger version of the Pulse-rifle Tracer.
AirboatGunTracer - Similar to the Pulse-rifle Tracer, only visible from above.
Tracer - 9mm pistol tracer
StriderTracer - Similar to AR2 tracer
HelicopterTracer - Similar to GunshipTracer effect
GunshipTracer - 2x the size of the pulse-rifle tracer
LaserTracer - The tool tracer effect from the Tool Gun
See Also