Object::Object: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
Line 1: Line 1:
'''Function''': Creates a new Object. [https://cdn.rage.mp/public/odb/index.html Gallery of objects]
{{SharedFunctionJS}}
 
Creates a new Object.
*'''[https://cdn.rage.mp/public/odb/index.html Objects gallery]'''
==Parameters==
==Parameters==
*'''model''': {{RageType|Hash}} (use [[Globals::joaat|mp.joaat]])
*'''model''': {{RageType|Hash}} (use [[Globals::joaat|mp.joaat]])
Line 8: Line 12:


==Syntax==
==Syntax==
{{Shared}}
 
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
mp.objects.new(model, position,
mp.objects.new(model, position,

Revision as of 14:10, 27 November 2018

Shared
Function

 JavaScript


Creates a new Object.

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