How to request server variables and set them (old RPC?)

I understand that this was probably done with the old Legacy networking via RPC’s, however I do not understand how to do it with the new networking system.

On my server, I have a NetworkIdentity object called PlayerList. PlayerList holds a List of all active team GameObjects and the player objects within the team objects. I also have a custom NetworkManager that has the methods AddPlayerToTeamListing(/various parameters/), GetOtherActiveTeams(/various parameters/), and GetAllActiveTeams(/various parameters/).

So, I have a player object. What I want to do is, for example, call the NetworkManager.AddPlayerToTeamListing() method and pass in its parameters, and send a request to the server to access the PlayerList object that is on the server.

So, to recap: Player calls method on its own NetworkManager, that method sends a request to the server while passing in variables, and the server takes those variables and does stuff with it in the PlayerList (which is only active on the server).

Ah, nevermind. The way I was doing it was working, I just forgot to reexport my build when testing it. I’ll just leave a solution for this anyone happens upon this in the future. I hate it when I see a user say that they solved their problem but never post how they did it. Of course, this does not have to be used for setting team colors and such. This is an example of having the server

First, my playerListObject is a NetworkIdentity (which makes it a server object, and disabled by default), so I will spawn it.

NetworkServer.SpawnObjects();

Next what I did was have the player call a method with a command attribute:

[Command]
void CmdAddPlayerToList(myTeamColor);

Let’s define CmdAddPlayerToList (The method must have Cmd at the beginning):

void CmdAddPlayerToList(myTeamColor){
     if(!isServer){ return; }

     if(myNetworkManager == null){
          //Add your code here that finds the network manager, such as finding it by name or if you added
          //a tag to your network manager, find it by the tag
     }

     myNetworkManager.AddPlayer(myTeamColor);
}

What this will do is call the CmdAddPlayerToList method, and this will run on the server. The server will find its network manager, and call the method AddPlayer while passing in the myTeamColor parameter. Now on to the network manager.

First, create a GameObject called playerListObject and instantiate it within the inspector.

Now, on to the AddPlayer method:

public void AddPlayer(Color color){
     playerListObject.AddPlayerToATeam(color);
}

And that’s a basically it. The client has requested a method called on the server and has passed on the color variable. Now the server can do whatever it has to do with the color to add it to a team. I’m not the best at solutions, but I hope that someone in the distant future might find this useful (unless 5.4 renders a lot of this useless).