WEAPON:FireAnimationEvent

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

Contents

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

Vector pos

Position of the effect

Arguments

Angle ang

Angle of the effect

Arguments

number event

The event ID of happened even. See this page.

Arguments

string name

Name of the event

Returns

boolean

Return true to disable the effect

Examples

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


Examples

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.Owner: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


Personal tools
Navigation