Disconnect all players when initial masterclient disconnects / crashes
Hello everyone!
I am currently trying to discconect all players from a room when the initial masterclient (creator of the room) leaves the room/ has crashed or disconnect due other reasons. I tried using a rpc to disconnect players when the masterclient leaves but that sadly does not work for some reason. I have also looked into the onmasterclientswitch for this issue but can not get that working either sadly.
If anyone could help me out with this issue would be really appreciated.
Kind regards,
Pablo Discobar
I am currently trying to discconect all players from a room when the initial masterclient (creator of the room) leaves the room/ has crashed or disconnect due other reasons. I tried using a rpc to disconnect players when the masterclient leaves but that sadly does not work for some reason. I have also looked into the onmasterclientswitch for this issue but can not get that working either sadly.
If anyone could help me out with this issue would be really appreciated.
Kind regards,
Pablo Discobar
0
Comments
-
Yo
What do you think about that ://called when there is void IInRoomCallbacks.OnMasterClientSwitched(Player newMasterClient) // a host migration { if(PhotonNetwork.isMasterClient) { photonView.RPC("LeaveRoom", RpcTarget.All); } } public void OnLeftRoom() // called when someone leaves the room { PhotonNetwork.Disconnect(); PhotonNetwork.LoadLevel("MainMenu"); } [PunRPC] public void LeaveRoom() { PhotonNetwork.LeaveRoom(); }
I think it should works, make sure you that your scene is synced to the host scenePhotonNetwork.AutomaticallySyncScene = true
0 -
You also could just call LeaveRoom in the OnMastetClientSwitched callback, there is no need for an additional RPC.
2 -
You right, I'm actually dumb ^^0