OnPlayerPropertiesUpdate not being called

Options

Hello hello

I have a button that sets the players country to null, but this never fires the callback. However, whenever I use SetCustomProperties it fires properly.

Why is it so that my commented line triggers the callback but not the second ? Isn't it updating the player's properties ?

Because I would like to do this as well for updating the kill / death count of every player as well, I don't want to have to create a new hash table every time I want to simply add +1 to the player's score

Best Answer

  • JohnTube
    JohnTube ✭✭✭✭✭
    Answer ✓
    Options

    SetCustomProperties always accepts Hashtable.

    The Hashtable can contain new properties OR properties to update OR properties to delete.

    New properties have new properties keys.

    Properties to update use existing old properties keys.

    Properties to delete use existing old properties keys with value set to null.

    You don't need to set all old properties that will keep their value, those will be kept on server and client.

    Only set what needs to be changed and synchronized across the network.

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options

    Hi @valentin56610,

    Thank you for choosing Photon!

    Please never set properties directly using Hashtable CustomProperties. Use that as readonly.

    Instead to set properties and sync them on all clients joined to the same room through the server use SetCustomProperties method and wait for OnPlayerPropertiesUpdate callback to know it has been set on local and remote clients joined to the same room.

    Same for the room properties, use SetCustomProperties method and wait for OnRoomPropertiesUpdate callback.

  • Got it !

    So I access the property by doing CustomProperty[myProperty]

    And I always set a value using SetProperty

    But I must use a hastable the first time I set one, right ? I can’t just set a value for something that doesn’t exist yet in the properties

  • JohnTube
    JohnTube ✭✭✭✭✭
    Answer ✓
    Options

    SetCustomProperties always accepts Hashtable.

    The Hashtable can contain new properties OR properties to update OR properties to delete.

    New properties have new properties keys.

    Properties to update use existing old properties keys.

    Properties to delete use existing old properties keys with value set to null.

    You don't need to set all old properties that will keep their value, those will be kept on server and client.

    Only set what needs to be changed and synchronized across the network.