Hi,
If I poll the hostlist from the masterserver, then I can easily retrieve the information about all available servers and their name + connected players and max connections.
However.
Once I let my program BE the server, I would like to be able to see how many clients are currently connected to me.
Is there a way to ask unity how many clients are connected to me (as a server?).
I’d like to have a message showing “There are currently X players connected to you”
But I don’t really poll the hostlist for that. It is rather local.
Any idea somebody ?
Kind regards,
Bart
var numOfConnectedPlayers = Network.connections.Length;
-Jeremy
1 Like
Ah thanks,
Didn’t think of going to look there…
Network.connections.length doesn’t seem to work in C#, how would you get around it? At least I can’t seem to get it working in Leepos awesome networking tutorial.
Thank you!
It doesn’t work in C#? Unusual. Please post some code.
the length of an array is the value in Length in C# / .NET actually, js just has a deprecated alias (not sure its still there) for it and thus can use length.
GUILayout.Label("Connections: " + Network.connections.length);
or even a line like:
if (Network.connections.length >= 1)
error CS0117: UnityEngine.NetworkPlayer[ ]' does not contain a definition for
length’
The above line of code works fine in JS.
Thank you!
David
In C# it’s capital L length. Just one of those quirks.