Object::Object: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
(Added object gallery and direct object id usage)
Line 1: Line 1:
Creates new object in to the world.
Creates new object in to the world.  
 
[http://objects.codeshock.hu/gallery.php Gallery of objects]


=Syntax=
=Syntax=
Line 8: Line 10:
== '''Required Arguments:''' ==
== '''Required Arguments:''' ==


*'''model hash''': <code>mp.joaat('<model_name>')</code>
*'''model hash''': <code>mp.joaat('<model_name>')</code> or object id
*'''position''': <b><font color='green'>Vector3</font></b>
*'''position''': <b><font color='green'>Vector3</font></b>
*'''rotation''': <b><font color='green'>Vector3</font></b>
*'''rotation''': <b><font color='green'>Vector3</font></b>
Line 16: Line 18:
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
let pos = player.position; // Returns Vector3 object
let pos = player.position; // Returns Vector3 object
    pos.y += 1
pos.y += 1
    pos.z -= 1
pos.z -= 1
    let object = mp.objects.new(mp.joaat('p_stinger_03'), pos , [0, 0, 0]); //Creates a stinger beside the player
let object = mp.objects.new(mp.joaat('p_stinger_03'), pos , [0, 0, 0]); // Creates a stinger beside the player
let object = mp.objects.new(795100068, pos , [0, 0, 0]); // Alternative, mp.joaat(...) resolves the model name into this object id
</syntaxhighlight>
</syntaxhighlight>

Revision as of 20:59, 6 December 2017

Creates new object in to the world.

Gallery of objects

Syntax

mp.objects.new(model, Vector3 position, Vector3 rotation);

Required Arguments:

  • model hash: mp.joaat('<model_name>') or object id
  • position: Vector3
  • rotation: Vector3

Example

let pos = player.position; // Returns Vector3 object
pos.y += 1
pos.z -= 1
let object = mp.objects.new(mp.joaat('p_stinger_03'), pos , [0, 0, 0]); // Creates a stinger beside the player
let object = mp.objects.new(795100068, pos , [0, 0, 0]); // Alternative, mp.joaat(...) resolves the model name into this object id