Manlok Wong Manlok Wong - 10 months ago 87
C# Question

Unity Photon can check current player count?

Now I test my demo game is used the free version that is only 20 ccu. I would like to ask how can I check how many players connect my photon server now. I want to do some waiting function if photon server has 20 players connected.
How can I check? Thanks.

Answer Source

You can get the count of currently online users connected to the lobby with the OnLobbyStatisticsUpdate() callback. Your class must derive from Photon.PunBehaviour.

public override void OnLobbyStatisticsUpdate()
        string countPlayersOnline;
        countPlayersOnline = PhotonNetwork.countOfPlayers.ToString() + " Players Online";

Notice that this update comes with a correct value every 10 seconds (more or less depending on server load).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download