CreateEffect: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} {{New items|4.0132|1.4| Creates an effect on specified position. }} {{Note|Not all effects support rotation (e.g. the "fire" - ...")
 
(added example)
Line 25: Line 25:


== Example ==  
== Example ==  
Example needed.
 
<section name="Example" class="client" show="true">
This example creates an object when the resource starts:
<syntaxhighlight lang="lua">
addCommandHandler("effect",
function(cmd, name)
local x, y, z = getElementPosition(localPlayer)
if createEffect(name, x, y, z) then
outputChatBox("Effect created!")
else
outputChatBox("Bad effect name or limit reached (is there a limit?).")
end
end
)
</syntaxhighlight>
</section>


== See Also ==
== See Also ==

Revision as of 13:43, 18 March 2014

ADDED/UPDATED IN VERSION 1.4 :

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, floaty, float z, [ float rX, float rY, float rZ ] )

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.

Returns

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

Example

Click to collapse [-]
Example

This example creates an object when the resource starts:

addCommandHandler("effect", 
	function(cmd, name)
		local x, y, z = getElementPosition(localPlayer)
		if createEffect(name, x, y, z) then
			outputChatBox("Effect created!")
		else
			outputChatBox("Bad effect name or limit reached (is there a limit?).")
		end
	end
)

See Also