CreateObject: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 1: Line 1:
{{Needs_Checking|Opt<nowiki>ional rotation is not working. I tried ion11 = createObject ( 4188, 1431.810303, 1612.815308, 12.316273, 0.785398, 0.0, 0.0 )</nowiki>}}
__NOTOC__  
__NOTOC__  
Creates an object in the GTA world.
Creates an object in the GTA world.
Line 18: Line 16:
*'''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.
===Returns===
Returns the [[object]] element if creation was successful, ''false'' otherwise.


==Example==  
==Example==  

Revision as of 15:36, 8 March 2007

Creates an object in the GTA world.

Syntax

object createObject ( id, x, y, z, [rx, ry, rz] )

Required Arguments

  • id: 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.

Returns

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

Example

This example creates an object when the map starts:

root = getRootElement ()
addEventHandler ( "onMapLoad", root, "mapLoad" )
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

See Also