Hello,
I have an UI-text at the lobby which displays the current connected playercount of the masterserver.
The text gets set when the user is joining the lobby.
void OnJoinedLobby(){
text_onlinePlayers.text = "Online: "+ PhotonNetwork.countOfPlayersOnMaster.ToString();
}
This way the first connected client will have “Online: 1”.
I start now a second instance of the game, connecting to the masterserver and its text will have “Online: 2” written, but when we look back to the first client, its text will have still “Online: 1”, because it is not updating for all clients.
Therefore I call PunRPC to update the text on every client everytime when someone connects or disconnects to the masterserver.
void OnJoinedLobby(){
RefreshOnlineCount();
}
void OnDisconnectedFromPhoton(){
RefreshOnlineCount();
}
void RefreshOnlineCount(){
pv.RPC("RefreshOnlineCount_RPC", PhotonTargets.All, null);
}
[PunRPC]
void RefreshOnlineCount_RPC(){
text_onlinePlayers.text = "Online: " + PhotonNetwork.countOfPlayersOnMaster.ToString();
}
This is somehow not working: Error at
pv.RPC("RefreshOnlineCount_RPC", PhotonTargets.All, null);