Search Unity

Network communication from client to server back to client

Discussion in 'Multiplayer' started by ArtLove, Oct 18, 2014.

  1. ArtLove

    ArtLove

    Joined:
    Oct 16, 2012
    Posts:
    49
    Good evening!

    I have a function name Server_JoinTeam. The client calls this function by doing the following:
    networkView.RPC("Server_JoinTeam", RPCMode.Server, Network.player);

    Server_JoinTeam(NetworkPlayer id)
    {
    if(maxplayers > 0)
    ......
    }

    My problem is that within Server_JoinTeam(), it uses the maxplayers variable from the client who called the RPC. What I would like is to, within Server_JoinTeam(), have the server check it's own maxplayer variable within the script and then alert the world by networkView.RPC("Function", RPCMode.All); whatever it needs to. Of course, that doesn't work since Server_JoinTeam() is the client's rpc. So what would I do to accomplish what I want?
     
  2. Christian-Tucker

    Christian-Tucker

    Joined:
    Aug 18, 2013
    Posts:
    376
    Code (csharp):
    1. if(Network.isServer) {
    2.  
    3. }