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 ] )</syntaxhighlight>  
<syntaxhighlight lang="lua">effect createEffect ( string name, float x, float y, float z [, float rX, float rY, float rZ, float drawDistance = 0 ] )</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
Line 20: Line 20:
*'''rZ:''' A floating point number representing the rotation about the Z axis in degrees.
*'''rZ:''' A floating point number representing the rotation about the Z axis in degrees.
{{New items|3.06892|1.4 r6892|
{{New items|3.06892|1.4 r6892|
*'''drawDistance:''' A floating point number representing the draw distance of the effect.
*'''drawDistance:''' A floating point number between 1 and 255 which represents the draw distance of the effect, or 0 to use the default draw distance.
}}
}}


Line 52: Line 52:
)
)
</syntaxhighlight>
</syntaxhighlight>
==Changelog==
{{ChangelogHeader}}
{{ChangelogItem|1.4.0-9.06892|Added drawDistance argument}}


== See Also ==
== See Also ==
{{Client_Effects_functions}}
{{Client_Effects_functions}}
[[ru:CreateEffect]]
[[ru:CreateEffect]]

Revision as of 23:02, 25 October 2014

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 ] )

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 255 which represents the draw distance of the effect, or 0 to use the default draw distance.

Returns

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

Example

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.")
		end
	end
)


This example synchronize cam flash effect (without this only local player can see this).

addEventHandler("onClientPlayerWeaponFire", root,
	function(weapon)
		if weapon == 43 and source ~= localPlayer then
			local x, y, z = getPedWeaponMuzzlePosition(source)
			createEffect("camflash", x, y, z)
		end
	end
)

Changelog

Version Description
1.4.0-9.06892 Added drawDistance argument

See Also