- Home /
locking/hiding a server
I have a 2 player game. After the second player connects, I want the server to 'disappear' so that nobody else can connect. How can I do that? I need 1 player to still remain the host, and the other needs to be the client.
I was thinking about using for(int i = 0; i < hostData.Length; i++){} but im not sure what to check for. Maybe try changing the name of the server to a unique name? What command could I use for that?
No matter what happpens, the server needs to be kicked out of the array so that it cant be seen by another player(if there are 2 players already in it)
In Photon you can set custom properties to the rooms. Like visiblity, maximum player count etc. So when the 2nd player connects I can set the room unvisile in lobby. It must have been something like this in Unity Networking.
Can I check the number of players without joining the server?
In Photon netwrking: yes. It's room based information. when you callect the roomlist, try checking room.playerCount or some propoerty like this. if it's 2, then you shouldn't draw a button for it. But again: this is Photon networking. I hope there's something like this. Try something like this: hostList[i].playerCount (when you start writing, it should make suggestions)
Not a solution but Unity Networking is getting an update soon(ish). Sorry it doesn't help you just yet, but its good to know: https://docs.google.com/document/d/1YkTcYqSi3eLEH54VRx3kZy_pHXaih2cIw5EscDdAomQ/edit
Your answer
![](https://koobas.hobune.stream/wayback/20220613193352im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Remote database for leaderboard 2 Answers
UNET cannot connect android devices. 1 Answer
Netcode [Command] Issues .. no errors, just not working. 1 Answer
Server List 0 Answers