How do I make a Players Online count in a lobby?
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
How do I make a "Players Online" count in a lobby?
Seth01Master
2022-04-01 18:01:47
Hello!
I am currently using Photon PUN to make a multiplayer game in unity. However, while making the menu, I thought it would be really cool to have a counter showing how many players were online and using the app. I looked all over the internet and could not find anything. Can anyone help me with this?
I don't need any GUI scripts or anything, just a way to find how many people are using the app at a time using C#. Thanks!
Comments
int playersOnline = PhotonNetwork.PlayerList.Length;
Also get the players names. You would have to assign each player a NickName over the network though
foreach(Player player in PhotonNetwork.PlayerList)
{
Debug.Log(player.NickName);
}
Seth01Master
2022-04-03 17:47:45
would that count how many people are using the app or just how many people are in a room/lobby?
Better use PhotonNetwork.CountOfPlayer
.
The xml doc comment in the code tells you: "The count of players currently using this application (available on MasterServer in 5sec intervals)."
Back to top