How can I show the score

Options
When creating the room in the 1st scene, I want to set a value such as the score, and when this score goes to the 2nd stage, I want to show the score. I know some about photon, can you help me?

Best Answer

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited September 2020 Answer ✓
    Options
    Hi @wolf1212,

    Thank you for choosing Photon!

    According to the stacktrace you are calling this in Update, so it's not clear what is the client state.
    But from the error message the client is not joined to a room and is even on the NameServer which should not happen when leaving the room, unless you disconnect and reconnect.

    SetCustomProperties works only when joined to a room.

Answers

  • chvetsov
    Options
    hi, @wolf1212

    this is not really about photon. this is really about client development.
    If you need to keep you scores in the room you could add it as property for the room. Please use numbers to identify such properties.

    best,
    ilya
  • wolf1212
    Options
    if (PhotonNetwork.IsMasterClient)
            {
                Hashtable setRoomProperties = new Hashtable();
                setRoomProperties.Add("GameMode", "GameMode");
                setRoomProperties.Add("AnotherProperty", "AnotherProperty");
                PhotonNetwork.CurrentRoom.SetCustomProperties(setRoomProperties);
            }
    

    When I add this code it gives an error when leaving the room

    Operation SetProperties (252) not allowed on current server (NameServer)
    UnityEngine.Debug:LogError(Object)
    Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2382)
    Photon.Realtime.LoadBalancingClient:CheckIfOpCanBeSent(Byte, ServerConnection, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2305)
    Photon.Realtime.LoadBalancingClient:OpSetPropertiesOfRoom(Hashtable, Hashtable, WebFlags) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1985)
    Photon.Realtime.Room:SetCustomProperties(Hashtable, Hashtable, WebFlags) (at Assets/Photon/PhotonRealtime/Code/Room.cs:397)
    menuManager:Update() (at Assets/Scripts/menuManager.cs:48)

    menuManager:Update() (at Assets/Scripts/menuManager.cs:48)
    PhotonNetwork.CurrentRoom.SetCustomProperties(setRoomProperties);
    
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited September 2020 Answer ✓
    Options
    Hi @wolf1212,

    Thank you for choosing Photon!

    According to the stacktrace you are calling this in Update, so it's not clear what is the client state.
    But from the error message the client is not joined to a room and is even on the NameServer which should not happen when leaving the room, unless you disconnect and reconnect.

    SetCustomProperties works only when joined to a room.
  • wolf1212
    wolf1212
    edited September 2020
    Options
    thank you for your answers