util/Effect

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(We need an article on how to create custom Lua effects)
Line 1: Line 1:
 
{{Func
 
{{Func
|Description=Creates a effect with the specified data. You can find a list of effects [[Effects|here]].
+
|Description=Creates a effect with the specified data.
 +
 
 +
You can find a list of built-in engine effects [[Effects|here]]. You can create your own. Example effects can be found [https://github.com/garrynewman/garrysmod/tree/master/garrysmod/gamemodes/sandbox/entities/effects here] and [https://github.com/garrynewman/garrysmod/tree/master/garrysmod/gamemodes/base/entities/effects here].
  
 
{{Note|When dispatching an effect from the server, some values may be clamped for networking optimizations. Visit the Set accessors on {{Type|CEffectData}} to see which ones are affected.}}
 
{{Note|When dispatching an effect from the server, some values may be clamped for networking optimizations. Visit the Set accessors on {{Type|CEffectData}} to see which ones are affected.}}
 
 
{{Note|You will need to couple this function with {{GlobalFunction|IsFirstTimePredicted}} should you use this in a [[:Category:Predicted_Hooks|predicted hook]].}}
 
{{Note|You will need to couple this function with {{GlobalFunction|IsFirstTimePredicted}} should you use this in a [[:Category:Predicted_Hooks|predicted hook]].}}
 
 
{{Note|Lua effects with same name as one of the engine effects will override the engine effect unless you set the ''allowOverride'' parameter to false.}}
 
{{Note|Lua effects with same name as one of the engine effects will override the engine effect unless you set the ''allowOverride'' parameter to false.}}
 
|Realm=Shared
 
|Realm=Shared

Revision as of 17:30, 25 September 2016

 util.Effect( )

Contents

Description

Creates a effect with the specified data.

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

NOTE

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.

NOTE

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

NOTE

Lua effects with same name as one of the engine effects will override the engine effect unless you set the allowOverride parameter to false.

Arguments

string effectName

The name of the effect to create.

Arguments

CEffectData effectData

The effect data describing the effect.

Arguments

boolean allowOverride=true

If this is an engine-defined effect, this controls whether or not we can be overridden by Lua defined scripted effects with the same name.

Arguments

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.

Examples

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 )


Personal tools
Navigation