Detect who's player is disconnected
Options
Here's my code first
This code is working but not the way i want because i am currently making a 1 v 1 multiplayer game using PUN and what my problem is like this
for example :
1st player connects then "kingdom player 1" is displayed on the screen
then 2nd player connects then "kingdom player 2"
is also displayed now both master and client side can see "kingdom player1"
and "kingdom player 2" but then I disconnect player 1 which is the host
then "kingdom player 1" should be deleted but the "kingdom player 2" is always
the one that gets deleted.
Could someone please help
private void Start() { PlayersName(); } public override void OnPlayerEnteredRoom(Player newPlayer) { PlayersName(); } public void PlayersName() { if(PhotonNetwork.CurrentRoom.PlayerCount == 1) { if (PhotonNetwork.IsMasterClient) { playerNames[0].text = "Kingdom Player 1"; playerNames[1].text = ""; } } else { playerNames[0].text = "Kingdom Player 1"; playerNames[1].text = "Kingdom Player 2"; } } //Callback when someone is disconnected public override void OnDisconnected(DisconnectCause cause) { Debug.Log("Someone Disconnected " + PhotonNetwork.NickName); } public override void OnPlayerLeftRoom(Player otherPlayer) { PlayersName(); }
This code is working but not the way i want because i am currently making a 1 v 1 multiplayer game using PUN and what my problem is like this
for example :
1st player connects then "kingdom player 1" is displayed on the screen
then 2nd player connects then "kingdom player 2"
is also displayed now both master and client side can see "kingdom player1"
and "kingdom player 2" but then I disconnect player 1 which is the host
then "kingdom player 1" should be deleted but the "kingdom player 2" is always
the one that gets deleted.
Could someone please help
0
Comments
-
help please0