1

I set the timer of the existence of the room as the properties of the room. As soon as the master player leaves the room, an exception is triggered: Operation setProperties (252) not called because client is not connected or not ready yet, client state: Leaving. This error does not affect the operation, there is no such error when another player exits. How can I handle this exception? It just bothers the eyes.

private void Update()
{
    _currentPlayersCountText.text = PhotonNetwork.PlayerList.Length.ToString();

    if (PhotonNetwork.IsMasterClient)
    {
        if (PhotonNetwork.PlayerList.Length >= 5)
        {
            _startGameButton.GetComponent<Button>().enabled = true;
        }
        else
        {
            _startGameButton.GetComponent<Button>().enabled = false;
        }

        Hashtable ht = PhotonNetwork.CurrentRoom.CustomProperties;
        ht.Remove("timer");
        ht.Add("timer", _roomTimer.timeRemaining);
        PhotonNetwork.CurrentRoom.SetCustomProperties(ht);
    }

    if (_roomTimer.timeRemaining <= 110)
    {
        LeaveRoom();
    }
}

Here is the code that most likely causes this error.

1 Answers1

0

You could try

public void LeaveRoom()
{
    PhotonNetwork.LeaveRoom();        
}

public override void OnLeftRoom()
{
    StartCoroutine(WaitToLeave());
}

IEnumerator WaitToLeave()
{
    while(PhotonNetwork.InRoom)
    yield return null;      
    SceneManager.LoadScene(0);
}