Garry's Mod Wiki

Garry's Mod Wiki

  boolean WEAPON:FireAnimationEvent( Vector pos, Angle ang, number event, string options, Entity source )

Description

Called before firing animation events, such as muzzle flashes or shell ejections.

This will only be called serverside for 3000-range events, and clientside for 5000-range and other events.

Arguments

1 Vector pos
Position of the effect.
2 Angle ang
Angle of the effect.
3 number event
The event ID of happened even. See this page.
4 string options
Name or options of the event.
5 Entity source
The source entity. This will be a viewmodel on the client and the weapon itself on the server

Returns

1 boolean
Return true to disable the effect.

Example

Disables muzzle flashes. Taken from tool gun source code.

function SWEP:FireAnimationEvent( pos, ang, event, options ) -- Disables animation based muzzle event if ( event == 21 ) then return true end -- Disable thirdperson muzzle flash if ( event == 5003 ) then return true end end

Example

Counter-Strike: Source like muzzle flashes.

function SWEP:FireAnimationEvent( pos, ang, event, options ) if ( !self.CSMuzzleFlashes ) then return end -- CS Muzzle flashes if ( event == 5001 or event == 5011 or event == 5021 or event == 5031 ) then local data = EffectData() data:SetFlags( 0 ) data:SetEntity( self:GetOwner():GetViewModel() ) data:SetAttachment( math.floor( ( event - 4991 ) / 10 ) ) data:SetScale( 1 ) -- Change me if ( self.CSMuzzleX ) then util.Effect( "CS_MuzzleFlash_X", data ) else util.Effect( "CS_MuzzleFlash", data ) end return true end end

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...