Garry's Mod Wiki

util.Effect

  util.Effect( string effectName, CEffectData effectData, boolean allowOverride = true, any ignorePredictionOrRecipientFilter = nil )

Description

Creates an effect with the specified data.

For Orange Box .pcf particles, see ParticleEffect, ParticleEffectAttach and CreateParticleSystem.

When dispatching an effect from the server, some values may be clamped for networking optimizations. Visit the Set accessors on CEffectData to see which ones are affected.

You will need to couple this function with IsFirstTimePredicted if you want to use it in a predicted hook.

Arguments

1 string effectName
The name of the effect to create.

You can find a list of built-in engine effects here. You can create your own, example effects can be found here and here.

2 CEffectData effectData
The effect data describing the effect.
3 boolean allowOverride = true
Whether Lua-defined effects should override engine-defined effects with the same name for this/single function call.
4 any ignorePredictionOrRecipientFilter = nil
Can either be a boolean to ignore the prediction filter or a CRecipientFilter.

Set this to true if you wish to call this function in multiplayer from server.

Example

Creates a HelicopterMegaBomb effect at the origin of the map. ( 0, 0, 0 )

local vPoint = Vector( 0, 0, 0 ) local effectdata = EffectData() effectdata:SetOrigin( vPoint ) util.Effect( "HelicopterMegaBomb", effectdata )