Difference between revisions of "Globals::invoke"

From RAGE Multiplayer Wiki
Jump to navigation Jump to search
 
Line 29: Line 29:
 
let outDataBuffer = [new ArrayBuffer(256)];
 
let outDataBuffer = [new ArrayBuffer(256)];
 
mp.game.invoke('0x79923CD21BECE14E', 0, outDataBuffer);
 
mp.game.invoke('0x79923CD21BECE14E', 0, outDataBuffer);
 +
 +
// If you are dealing with hashes, you might have some problems since JavaScript might try to convert it to float in some cases.
 +
// To avoid that, always append >> 0 to the hash
 +
mp.game.invoke('0x015A522136D7F951', mp.players.local.handle, mp.game.joaat('weapon_specialcarbine') >> 0) // GET_AMMO_IN_PED_WEAPON
 +
// This example would not work otherwise
 
</pre>
 
</pre>
 
}}
 
}}

Latest revision as of 17:42, 15 January 2020

Invokes specified native function

Parameters

  • hash: String
  • args: Any

Syntax

mp.game.invoke(hash, [, ...args])

Example

Client-Side
// Normal invoke void
mp.game.invoke('0x428CA6DBD1094446', mp.players.local.handle, true); // FREEZE_ENTITY_POSITION

// You should use arrays with one element of required type to pass variable as a reference
let posixTime = { year: [0], month: [0], day: [0], hour: [0], minute: [0], second: [0] };
mp.game.invoke('0xDA488F299A5B164E', posixTime.year, posixTime.month, posixTime.hour, posixHour.minute, posixHour.second);

mp.gui.chat.push(`Year: ${posixTime.year[0]}`);

// that works for all types
let matrix = { r: [[0, 0, 0]], f: [[0, 0, 0]], u: [[0, 0, 0]], p: [[0, 0, 0]] };
mp.game.invoke('0xECB2FC7235A7D137', handle, matrix.r, matrix.f, matrix.u, matrix.p);

// ArrayBuffers could be used too
let outDataBuffer = [new ArrayBuffer(256)];
mp.game.invoke('0x79923CD21BECE14E', 0, outDataBuffer);

// If you are dealing with hashes, you might have some problems since JavaScript might try to convert it to float in some cases.
// To avoid that, always append >> 0 to the hash
mp.game.invoke('0x015A522136D7F951', mp.players.local.handle, mp.game.joaat('weapon_specialcarbine') >> 0) // GET_AMMO_IN_PED_WEAPON
// This example would not work otherwise

See Also