Skip to content

MessHallAPI Custom RPCs (Remote Procedure Call)

Jolyne edited this page May 5, 2026 · 1 revision

What is an RPC?

A Remote Procedure Call (RPC) is a way to send data to other players in the same room.

RPCs are used to sync values, positions, and other data, or to tell other clients to run actions.
In simple terms, an RPC lets you make other players’ games do something.

How do I make an RPC?

Making a custom RPC with MessHallAPI is simple.

Create a method and add the MessHallRPC attribute above it.
When creating an RPC, you need to define:

  • Who can call it (RPCCaller)
  • Who receives it (RPCTarget)

RPCCaller

  • RPCCaller.Anyone -> any player can call it
  • RPCCaller.HostOnly -> only the host can call it

RPCTarget

  • All -> sent to everyone except the sender
  • AllInclusive -> sent to everyone including the sender
  • Host -> only the host receives it

Example

[MessHallRPC(RPCTarget.AllInclusive, RPCCaller.Anyone)]
public static void RPC_Message(string msg)
{
    MelonLogger.Msg($"Message Received! {msg}");
}

This RPC sends a message to everyone in the game, including the sender.

How do I send an RPC?

To send an RPC, use:

MessHallAPI.Networking.NetworkManager.InvokeRPC("YourModName", "RPC_MethodName", args);

Example

MessHallAPI.Networking.NetworkManager.InvokeRPC("TestMod", "RPC_Message", "hello");

This will make every client log "hello".

Make sure the first argument is your mod’s file name (without .dll).

How do I send an RPC to one specific player?

You can target a specific player using [RPCTarget].

Add it to a parameter in your method:

[MessHallRPC(RPCTarget.All, RPCCaller.Anyone)]
public static void RPC_Message([MessHallAPI.Networking.RPCTarget] int target, string msg)
{
    MelonLogger.Msg($"Message Received! {msg}");
}

How to call

MessHallAPI.Networking.NetworkManager.InvokeRPC("YourModName", "RPC_Message", 1, "hello");

This will only run on the player with ID 1.

How do I get the sender of an RPC?

Use [RPCInfo] in your method parameters.

MessHallAPI fills this automatically, so you do not pass it when calling the RPC.

[MessHallRPC(RPCTarget.All, RPCCaller.Anyone)]
public static void RPC_Message([MessHallAPI.Networking.RPCInfo] MessHallAPI.Networking.MessHallRpcInfo info, string msg)
{
    MelonLogger.Msg($"Message from {info.Sender}: {msg}");
}

How to call

MessHallAPI.Networking.NetworkManager.InvokeRPC("YourModName", "RPC_Message", "hello");

Can I use both RPCInfo and RPCTarget?

Yes. You can use both in the same RPC.
Just remember you do not pass a value for RPCInfo when calling it.

What parameter types can I use?

MessHallAPI supports:

byte, short, ushort, int, uint, long, ulong, float, double, bool, string

Using any other type will not work.