Player::callProc

From RAGE Multiplayer Wiki
Revision as of 05:21, 23 June 2020 by Graber (talk | contribs) (Add async proc example)

Server-Side
Function

 JavaScript



This function calls the specified player's clientside Remote prodecure call (RPC) event and expects a callback.

JavaScript Syntax

Syntax

player.callProc('eventProcName', [...args]);

Required Arguments

  • *eventProcName: String
  • args: Any

Example

Server-Side
(async () => {
  try {
     let res = await player.callProc('test_proc', ['ok']);
     console.log('succ', res);
  } catch(e) {
    console.error('Error: ' + e);
  }
}();


Client-Side
mp.events.addProc('test_proc', (player, text) => {
  return 'hey beast: ' + text;
});

// also supports async functions
mp.events.addProc('test_proc', async (text) => {
  await doAsyncJob();
  return 'hey beast: ' + text;
});


See Also