Перейти к содержанию

Events::callRemoteProc

Материал из RAGE MP Wiki Archive

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


Client-Side Function

Ошибка создания миниатюры: Не удаётся сохранить эскиз по месту назначения C# Ошибка создания миниатюры: Не удаётся сохранить эскиз по месту назначения JavaScript




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
    };
});


See Also