CreateObject: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">object createObject ( int modelid, float x, float y, float z, [float rx, float ry, float rz] )</syntaxhighlight>  
<syntaxhighlight lang="lua">object createObject ( int modelid, float x, float y, float z, [ float rx, float ry, float rz, bool isLowLOD ] )</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
Line 17: Line 17:
*'''ry:''' A floating point number representing the rotation about the Y 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.
*'''rz:''' A floating point number representing the rotation about the Z axis in degrees.
 
{{New items|3.0120|1.2|
*'''isLowLOD:''' A bool value specifying if the object will be using a low LOD model.
}}
===Returns===
===Returns===
Returns the [[object]] element if creation was successful, ''false'' otherwise.
Returns the [[object]] element if creation was successful, ''false'' otherwise.

Revision as of 03:49, 4 December 2011

Creates an object in the GTA world.

Syntax

object createObject ( int modelid, float x, float y, float z, [ float rx, float ry, float rz, bool isLowLOD ] )

Required Arguments

  • modelid: A whole integer specifying the GTASA object model ID.
  • 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.
  • isLowLOD: A bool value specifying if the object will be using a low LOD model.

Returns

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

Example

Click to collapse [-]
Server

This example creates an object when the resource starts:

function mapLoad ( name )
   -- create an object at a specified position with a specified rotation
   createObject ( 1337, 5540.6654, 1020.55122, 1240.545, 90, 0, 0 )
end
addEventHandler ( "onResourceStart", getRootElement(), mapLoad )

See Also