CreateEffect: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 6: Line 6:
{{Note|Not all effects support rotation (e.g. the "fire" - effect doesn't).}}
{{Note|Not all effects support rotation (e.g. the "fire" - effect doesn't).}}
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">effect createEffect ( string name, float x, float y, float z [, float rX, float rY, float rZ, float drawDistance = 0 ] )</syntaxhighlight>
<syntaxhighlight lang="lua">effect createEffect ( string name, float x, float y, float z [, float rX, float rY, float rZ, float drawDistance = 0, soundEnabled = false ] )</syntaxhighlight>
{{OOP||[[Effect]]}}
{{OOP||[[Effect]]}}


Line 23: Line 23:
*'''drawDistance:''' A floating point number between 1 and 8191 which represents the draw distance of the effect, or 0 to use the default draw distance.
*'''drawDistance:''' A floating point number between 1 and 8191 which represents the draw distance of the effect, or 0 to use the default draw distance.
|6892}}
|6892}}
{{New feature/item|3.0155|1.5.5||
*'''soundEnabled:''' to enable the sound of the effect.
}}


=== Returns ===
=== Returns ===

Revision as of 19:58, 7 October 2017

Creates an effect on specified position.

[[{{{image}}}|link=|]] Note: Not all effects support rotation (e.g. the "fire" - effect doesn't).

Syntax

effect createEffect ( string name, float x, float y, float z [, float rX, float rY, float rZ, float drawDistance = 0, soundEnabled = false ] )

OOP Syntax Help! I don't understand this!

Method: Effect(...)


Required Arguments

  • name: A string contains effect name.
  • x: A floating point number representing the X coordinate on the map.
  • y: A floating point number representing the Y coordinate on the map.
  • z: A floating point number representing the Z coordinate on the map.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • rX: A floating point number representing the rotation about the X axis in degrees.
  • rY: A floating point number representing the rotation about the Y axis in degrees.
  • rZ: A floating point number representing the rotation about the Z axis in degrees.
ADDED/UPDATED IN VERSION 1.4 r6892:
  • drawDistance: A floating point number between 1 and 8191 which represents the draw distance of the effect, or 0 to use the default draw distance.
  • soundEnabled: to enable the sound of the effect.

Returns

Returns the effect element if creation was successful, false otherwise.

Example


--There are 82 effects

local effectNames = {
"blood_heli","boat_prop","camflash","carwashspray","cement","cloudfast","coke_puff","coke_trail","cigarette_smoke",
"explosion_barrel","explosion_crate","explosion_door","exhale","explosion_fuel_car","explosion_large","explosion_medium",
"explosion_molotov","explosion_small","explosion_tiny","extinguisher","flame","fire","fire_med","fire_large","flamethrower",
"fire_bike","fire_car","gunflash","gunsmoke","insects","heli_dust","jetpack","jetthrust","nitro","molotov_flame",
"overheat_car","overheat_car_electric","prt_blood","prt_boatsplash","prt_bubble","prt_cardebris","prt_collisionsmoke",
"prt_glass","prt_gunshell","prt_sand","prt_sand2","prt_smokeII_3_expand","prt_smoke_huge","prt_spark","prt_spark_2",
"prt_splash","prt_wake","prt_watersplash","prt_wheeldirt","petrolcan","puke","riot_smoke","spraycan","smoke30lit","smoke30m",
"smoke50lit","shootlight","smoke_flare","tank_fire","teargas","teargasAD","tree_hit_fir","tree_hit_palm","vent","vent2",
"water_hydrant","water_ripples","water_speed","water_splash","water_splash_big","water_splsh_sml","water_swim","waterfall_end",
"water_fnt_tme","water_fountain","wallbust","WS_factorysmoke"
}

addCommandHandler("createEffect", function(_, effectIndex)
   effectIndex = tonumber(effectIndex)
   if effectIndex and type(effectIndex) == "number" then
      if effectIndex > 0 and effectIndex <= #effectNames then
         createEffect(effectNames[effectIndex], Vector3( getElementPosition( getLocalPlayer() ) ), 0, 0, 0)
      end
   end
end)

--Example Command: /createEffect 3

Changelog

Version Description
1.4.0-9.06892 Added drawDistance argument

See Also