Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Network.maxConnections doesn't work

Discussion in 'Multiplayer' started by nafonso, Jan 15, 2009.

  1. nafonso

    nafonso

    Joined:
    Aug 10, 2006
    Posts:
    377
    I want to be able to create a server with 8 players and then when the game starts, close the server to new clients (i.e. no one should be allowed to enter in the middle of a game), so I set Network.maxConnections to prevent this.

    I've tried setting it to the amount of players already logged in, to 0 and to -1, and still new clients are able to connect.

    At the moment the only workaround I have is when a client connects while the game is running, the server will kick it, the problem is that not only it is an ugly way of doing it but also the client will see the buffered RPCs execute (e.g. level loading).

    Is this bug going to be corrected for the next update?

    Regards,
    Afonso
     
  2. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    A simple way is to disable connecting to a host where connected players == max players.
    In our case, we do a GUI.disabled on the Join button.
     
  3. nafonso

    nafonso

    Joined:
    Aug 10, 2006
    Posts:
    377
    Yeah, but that only works if the master server has the exact info from the server (it can have a out of date info).

    Also, we have a direct IP connection, which doesn't go through the master server :-\
     
  4. jg225106

    jg225106

    Joined:
    Nov 20, 2008
    Posts:
    8
    any luck with this? i'm having the same issue and am also using direct ip connect.

    thanks,
    jason
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Why not simply set your server correctly when you initialize it through
    Code (csharp):
    1. Network.InitializeServer (connections : int, listenPort : int)
    I don't see why you would want to alter the amount after the server is initialized because what is the server meant to do if more are connected then you want to set as max. Who is meant to be kicked?
    That just as a simple obvious problem such an attempt will bring up


    If you want to restrict it, you would instead send a specific RPC to the player in
    and inform the player that the server is full and kick him again