Globals::invoke: Difference between revisions
No edit summary |
|||
| Line 13: | Line 13: | ||
{{ClientsideCode| | {{ClientsideCode| | ||
<pre> | <pre> | ||
mp.game.invoke(' | // 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); | |||
</pre> | </pre> | ||
}} | }} | ||
Revision as of 08:25, 6 November 2019
Invokes specified native function
Parameters
- hash: String
- args: Any
Syntax
mp.game.invoke(hash, [, ...args])
Example
Client-Side
// 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);