Skip to main content
Branch: Release Candidate

emitRpc

Callable

  • emitRpc<K>(rpcName: K, ...args: Parameters<ICustomClientServerRpc[K]>): Promise<ReturnType<shared.ICustomClientServerRpc[K]>>
  • emitRpc<K>(rpcName: Exclude<K, never>, ...args: any[]): Promise<any>

  • Calls a server sided RPC with the specified arguments.

    Example

    alt.on("consoleCommand", async (cmd) => {
    if (cmd !== "rpc") return;

    try {
    const result = await alt.emitRpc("testRpc");

    alt.log("Rpc result:", ...result);
    }
    catch (err) {
    alt.logError(`Failed to call rpc: ${err}`);
    }
    });

    Remarks

    Exceptions will be thrown when there was an error on server-side.


    Type parameters

    • K: never