Browser::callProc

From RAGE Multiplayer Wiki

Client-Side
Function

 JavaScript




JavaScript Syntax


This function calls registered Remote Prodecure Call (RPC) from browser to client-side and expects a callback.

Syntax

mp.events.callProc('eventProcName', args);

Required Arguments

  • *eventProcName: String
  • args: Any


Examples

JavaScript Syntax

// calls 'test_proc' from client-side
mp.events.callProc('test_proc', 'test');


Client-Side
mp.events.addProc('test_proc', (text) => {
  mp.gui.chat.push('data: ' + text);
});

Example calling an object:

// calls 'test' from client-side
const data = await mp.events.callProc('test');
if (data) {
   const {testOne, testTwo} = JSON.parse(data);
}
Client-Side
mp.events.addProc("test", async () => {
  return JSON.stringify({
    testOne: "whatever",
    testTwo: "two",
  });
});


See also