Skip to main content

Events::callRemoteProc

This function calls a previously registered event on the server using Events::addProc.

Client-side function

C#​

Task<object> RAGE.Events.CallRemote(string procName, params object[] args);

Syntax​

mp.events.callRemoteProc(String eventName [, ...args])

Example​

In this example, we will send an RPC request from the client to the server in which we will transmit the number 1. We will wait for the response and process it. On the server, if number is 1, return true, otherwise false. P.S. Note that await can only be used in an async function.

Client-Side

const number = 1;
const response = await mp.events.callRemoteProc("testEvent", number);
if (response.result === true) mp.console.logInfo("Result is true", true, true);

Server-Side

//player object is always the first param and it's the player who requested this RPC
mp.events.addProc("testEvent", (player, number) => {
return {
result: number === 1 ? true : false
};
});