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 posPosition of the effect.
2 Angle angAngle of the effect.
4 string optionsName or options of the event.
5 Entity sourceThe 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 )
if ( event == 21 ) then return true end
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
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 )
if ( self.CSMuzzleX )
then
util.
Effect(
"CS_MuzzleFlash_X", data )
else
util.
Effect(
"CS_MuzzleFlash", data )
end
return true
end
end