Events::callRemoteProc
This function calls a previously registered event on the server using mp.events.addProc(String eventName [, ...args]).
Эта функция вызывает ранее зарегистрированное событие на сервере с помощью mp.events.addProc(String eventName [, ...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.
В данном примере мы отправим RPC запрос с клиента на сервер в котором передадим число 1. Дождёмся ответа и обработаем его. На сервере, если number равен 1 вернём true, в остальных случаях false. P.S. Обратите внимание, что использовать await можно лишь в async функции.
const number = 1;
const response = await mp.events.callRemoteProc("testEvent", number);
if (response.result === true) mp.console.logInfo("Result is true", true, true);
//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
- Functions
- Properties