- Home /
Getting a list of players connected?
I'm trying to make a TAB menu, seeing players lined down along with their player ID, which is first guy connected0, then next 1 and it goes on and on. How would I approach this? I cant find any 'simple' way to do this anywhere, any help is greatly appreciated. Thanks in advance.
The easiest way to do this would be to have all the players with a common tag, then you can check for that tag and use it to get the information from that object? :) If you need scripting help I can only really use C# but I'm happy to help if you need it :)
I can only do Javascript, and not that much of it aswell. I can easily get the tag, but I have no idea how to get any information.
Well if you where to have a script, well what infomation do you need from each player? like a player name?
if so, then if each player has a script containing their information such as a name, you can use "GetComponent" to find that script and use its info!
Hmm yeah, but how would I get their player ID, so I can make a command to disconnect them via player ID? And how exactly would I make the player list? With arrays I guess, but I dont really know how to put stuff like that into an array automaticly.
I'm afraid I can only give you concepts as my skills with JavaScript is very low as I've always used C#. But everything in a game if stored in a script somewhere, so on each player there must be a script containing there network status including there network ID, and using GetComponent you should be able to find use it.
This is why i used photon, it comes with build in commands such as "PhotonNetwork.PlayerList".
As far as adding them to an array, if you have a script set to check for a "player" tag, then using that array.add function you can add all the players to that array.
http://docs.unity3d.com/Documentation/ScriptReference/Array.Add.html