Object::Object: Difference between revisions

From RAGE Multiplayer Wiki
mNo edit summary
No edit summary
Line 1: Line 1:
Creates new object in to the world.  
'''Function''': Creates a new Object. [http://objects.codeshock.hu/gallery.php Gallery of objects]
==Parameters==
*'''model''': {{RageType|Hash}} (use [[Globals::joaat|mp.joaat]])
*'''position''': {{RageType|Vector3}}
*'''rotation''': {{RageType|Vector3}}
*'''alpha''': {{RageType|Number}}
*'''dimension''': {{RageType|Number}}


[http://objects.codeshock.hu/gallery.php Gallery of objects]
==Syntax==
 
=Syntax=
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
mp.objects.new(model, Vector3 position, Vector3 rotation);
mp.objects.new(model, position,
{
    rotation: rotation,
    alpha: alpha,
    dimension: dimension
});
</syntaxhighlight>
</syntaxhighlight>
== '''Required Arguments:''' ==
*'''model hash''': <code>mp.joaat('<model_name>')</code> or object id
*'''position''': <b><font color='green'>Vector3</font></b>
*'''rotation''': <b><font color='green'>Vector3</font></b>


=Example=
=Example=


<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// OUTDATED EXAMPLE
let pos = player.position; // Returns Vector3 object
let pos = player.position; // Returns Vector3 object
pos.y += 1;
pos.y += 1;

Revision as of 08:27, 28 December 2017

Function: Creates a new Object. Gallery of objects

Parameters

  • model: Hash (use mp.joaat)
  • position: Vector3
  • rotation: Vector3
  • alpha: Number
  • dimension: Number

Syntax

mp.objects.new(model, position,
{
    rotation: rotation,
    alpha: alpha,
    dimension: dimension
});

Example

// OUTDATED 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