Object::ObjectWeak: Difference between revisions

From RAGE Multiplayer Wiki
(Created page with "{{SharedFunctionJS}} Creates an instance of a multiplayer object from a game object handle {{JSContainer| ==Syntax== {{SharedCode| <pre> mp.objects.newWeak(handle); </pre>...")
 
No edit summary
 
Line 1: Line 1:
{{SharedFunctionJS}}
{{ClientsideJsFunction}}
{{JSContainer|
Converts a static game object into RAGEMP's objects api.


Creates an instance of a multiplayer object from a game object handle
==Required Params==
*'''handle:''' {{RageType|number}}


==Return Value==
*''' {{RageType|ObjectMp}} '''


{{JSContainer|
==Syntax==
==Syntax==
{{SharedCode|
<pre>
<pre>
mp.objects.newWeak(handle);
mp.objects.newWeak(handle);
</pre>
==Example==
{{ClientsideCode|
<pre>
let convertedObject = null;
const {x, y, z} = mp.players.local.position;
const gameobjectHandle = mp.game.object.getClosestObjectOfType(x, y, z, 10.0, mp.game.joaat("apa_heist_apart2_door"), false, false, false);
if (gameobjectHandle) {
    convertedObject = mp.objects.newWeak(gameobjectHandle);
    //now you can use RAGEMP's object api methods to control the newly converted object.
}
</pre>
</pre>
}}
}}
==Required Arguments==
*'''handle''': {{RageType|Hash}}


}}
}}
[[Category:Object API]]
==See also==
[[Category:Shared Function]]
{{Object_definition_c}}
[[Category:TODO: Example]]
[[Category:Clientside API]]

Latest revision as of 10:00, 19 August 2024

Client-Side
Function

 JavaScript



JavaScript Syntax

Converts a static game object into RAGEMP's objects api.

Required Params

  • handle: number

Return Value

  • ObjectMp

Syntax

mp.objects.newWeak(handle);

Example

Client-Side
let convertedObject = null;
const {x, y, z} = mp.players.local.position;
const gameobjectHandle = mp.game.object.getClosestObjectOfType(x, y, z, 10.0, mp.game.joaat("apa_heist_apart2_door"), false, false, false);

if (gameobjectHandle) {
    convertedObject = mp.objects.newWeak(gameobjectHandle);
    //now you can use RAGEMP's object api methods to control the newly converted object.
}



See also