Skip to main content
added 518 characters in body
Source Link
Zibelas
  • 4.6k
  • 2
  • 14
  • 22

If you want to keep track of the order when users joined the room (which should actually not matter much) you just need to keep track of them when they join the room. Photon is providing the player with OnPhotonPlayerConnected(PhotonPlayer newPlayer). You can set the time when they joined the room in the custom room property if needed with a time stamp. Let the masterclient handle it or let each client write it when they arrive. If you want to get a whole list of them at once, you can access them via PhotonNetwork.playerList.

PhotonNetwork persists between scenes and there are a few example tutorials provided directly by Photon. It's worth checking out both Pun and Pun2, since the examples they have are slightly different (Pun has for example a simple Rock-Paper-Scissor game which is missing in Pun2) but the code is almost the same.

And if you want to use something for displaying as scores, you should not use the userId but instead PhotonNetwork.player.NickName. The userId is unique, the Nickname is usually what the player is itself choosing and does not need to be unique.

I assume your game is round based (looks like auto chess or similar). Each player could just report his own stats after each round with PhotonNetwork.RaiseEvent(TOKEN_UPDATE_SCORE, payload, true, new RaiseEventOptions() { CachingOption = EventCaching.AddToRoomCache });. You need to subscribe to PhotonNetwork.OnEventCall += OnEvent; where public void OnEvent(byte eventCode, object content, int senderId). All clients are getting that way an update of the score after each round (or whenever you call it)

If you want to keep track of the order when users joined the room (which should actually not matter much) you just need to keep track of them when they join the room. Photon is providing the player with OnPhotonPlayerConnected(PhotonPlayer newPlayer). You can set the time when they joined the room in the custom room property if needed with a time stamp. Let the masterclient handle it or let each client write it when they arrive. If you want to get a whole list of them at once, you can access them via PhotonNetwork.playerList.

PhotonNetwork persists between scenes and there are a few example tutorials provided directly by Photon. It's worth checking out both Pun and Pun2, since the examples they have are slightly different (Pun has for example a simple Rock-Paper-Scissor game which is missing in Pun2) but the code is almost the same.

And if you want to use something for displaying as scores, you should not use the userId but instead PhotonNetwork.player.NickName. The userId is unique, the Nickname is usually what the player is itself choosing and does not need to be unique.

If you want to keep track of the order when users joined the room (which should actually not matter much) you just need to keep track of them when they join the room. Photon is providing the player with OnPhotonPlayerConnected(PhotonPlayer newPlayer). You can set the time when they joined the room in the custom room property if needed with a time stamp. Let the masterclient handle it or let each client write it when they arrive. If you want to get a whole list of them at once, you can access them via PhotonNetwork.playerList.

PhotonNetwork persists between scenes and there are a few example tutorials provided directly by Photon. It's worth checking out both Pun and Pun2, since the examples they have are slightly different (Pun has for example a simple Rock-Paper-Scissor game which is missing in Pun2) but the code is almost the same.

And if you want to use something for displaying as scores, you should not use the userId but instead PhotonNetwork.player.NickName. The userId is unique, the Nickname is usually what the player is itself choosing and does not need to be unique.

I assume your game is round based (looks like auto chess or similar). Each player could just report his own stats after each round with PhotonNetwork.RaiseEvent(TOKEN_UPDATE_SCORE, payload, true, new RaiseEventOptions() { CachingOption = EventCaching.AddToRoomCache });. You need to subscribe to PhotonNetwork.OnEventCall += OnEvent; where public void OnEvent(byte eventCode, object content, int senderId). All clients are getting that way an update of the score after each round (or whenever you call it)

added 250 characters in body
Source Link
Zibelas
  • 4.6k
  • 2
  • 14
  • 22

If you want to keep track of the order when users joined the room (which should actually not matter much) you just need to keep track of them when they join the room. Photon is providing the player with OnPhotonPlayerConnected(PhotonPlayer newPlayer). You can set the time when they joined the room in the custom room property if needed with a time stamp. Let the masterclient handle it or let each client write it when they arrive. If you want to get a whole list of them at once, you can access them via PhotonNetwork.playerList.

PhotonNetwork persists between scenes and there are a few example tutorials provided directly by Photon. It's worth checking out both Pun and Pun2, since the examples they have are slightly different (Pun has for example a simple Rock-Paper-Scissor game which is missing in Pun2) but the code is almost the same.

And if you want to use something for displaying as scores, you should not use the userId but instead PhotonNetwork.player.NickName. The userId is unique, the Nickname is usually what the player is itself choosing and does not need to be unique.

If you want to keep track of the order when users joined the room (which should actually not matter much) you just need to keep track of them when they join the room. Photon is providing the player with OnPhotonPlayerConnected(PhotonPlayer newPlayer). You can set the time when they joined the room in the custom room property if needed with a time stamp. Let the masterclient handle it or let each client write it when they arrive. If you want to get a whole list of them at once, you can access them via PhotonNetwork.playerList.

PhotonNetwork persists between scenes and there are a few example tutorials provided directly by Photon. It's worth checking out both Pun and Pun2, since the examples they have are slightly different (Pun has for example a simple Rock-Paper-Scissor game which is missing in Pun2) but the code is almost the same.

If you want to keep track of the order when users joined the room (which should actually not matter much) you just need to keep track of them when they join the room. Photon is providing the player with OnPhotonPlayerConnected(PhotonPlayer newPlayer). You can set the time when they joined the room in the custom room property if needed with a time stamp. Let the masterclient handle it or let each client write it when they arrive. If you want to get a whole list of them at once, you can access them via PhotonNetwork.playerList.

PhotonNetwork persists between scenes and there are a few example tutorials provided directly by Photon. It's worth checking out both Pun and Pun2, since the examples they have are slightly different (Pun has for example a simple Rock-Paper-Scissor game which is missing in Pun2) but the code is almost the same.

And if you want to use something for displaying as scores, you should not use the userId but instead PhotonNetwork.player.NickName. The userId is unique, the Nickname is usually what the player is itself choosing and does not need to be unique.

Source Link
Zibelas
  • 4.6k
  • 2
  • 14
  • 22

If you want to keep track of the order when users joined the room (which should actually not matter much) you just need to keep track of them when they join the room. Photon is providing the player with OnPhotonPlayerConnected(PhotonPlayer newPlayer). You can set the time when they joined the room in the custom room property if needed with a time stamp. Let the masterclient handle it or let each client write it when they arrive. If you want to get a whole list of them at once, you can access them via PhotonNetwork.playerList.

PhotonNetwork persists between scenes and there are a few example tutorials provided directly by Photon. It's worth checking out both Pun and Pun2, since the examples they have are slightly different (Pun has for example a simple Rock-Paper-Scissor game which is missing in Pun2) but the code is almost the same.