Skip to content

RPCs (Networked Events)

Dat Nardo edited this page Jan 10, 2024 · 1 revision

RPCs (Networked Events)

Sending Data

To send a modded RPC, use: SendModRPC(string sender, ModRPC rpc)

in your script:

  • Sender should be set to socketviewid, or the owner of another SocketView.
    • socketviewid is a variable that is able to be accessed when inheriting from CustomMod

ModRPC has the format of:

  • string modrpctype; //Unique RPC identifier
  • string parameters; //Custom data (recommended in JSON format)
  • string target; //Who will receives the RPC

Targets

"All": Sends to all SocketViews "Other": Sends to all SocketViews that is not the current owner "MasterClient": Only make the request be able to be received by the hosting player

Receiving data

Use:

  public void ReceiveModRPC(ModRPC RPC){
    /*
    Example usage:
            if (RPC.modrpctype == "syncmodpos" 
            && RPC.mod_rpc_sender == view.owner 
            && !hosting)
            {
                MoveParams moveParams =
                JsonUtility.FromJson<MoveParams>
                (RPC.parameters);

                NetworkPos = moveParams.pos;
                NetworkRot = moveParams.rot;
            }
    */ 
  }

To receive RPC data

Clone this wiki locally