Get Room properties and Player properties
Options
It is impressive that I could not find any single direct example of how to get a room property from a hashtable.
By simply using "customProperties[myHashKeyName]" does not work. All examples from here: https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/pun-basics-tutorial/intro
does not have a single simple "get property this way" example... =/
By example, I mean:
And then when I try to get it via "PhotonNetwork.CurrentRoom.CustomProperties[ROOM_KEY_MapSeed]" it returns null. (and yes, I did it after joining a room, with everything fine running, etc).
I could not find any single example of how to do that, without going to random posts here asking some other room related stuff.
I also tried to use "PhotonNetwork.CurrentRoom.SetCustomProperties(roomData);", but it never returns something on "OnRoomPropertiesUpdate"...
How to do it? Can anyone point me to any direction please?
Thanks.
By simply using "customProperties[myHashKeyName]" does not work. All examples from here: https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/pun-basics-tutorial/intro
does not have a single simple "get property this way" example... =/
By example, I mean:
var roomOptions = new RoomOptions(); roomOptions.CustomRoomProperties.Add(ROOM_KEY_MapSeed, "seedwhatever"); roomOptions.CustomRoomProperties.Add(ROOM_KEY_GameTimer, 300); PhotonNetwork.CreateRoom(null, roomOptions, null);
And then when I try to get it via "PhotonNetwork.CurrentRoom.CustomProperties[ROOM_KEY_MapSeed]" it returns null. (and yes, I did it after joining a room, with everything fine running, etc).
I could not find any single example of how to do that, without going to random posts here asking some other room related stuff.
I also tried to use "PhotonNetwork.CurrentRoom.SetCustomProperties(roomData);", but it never returns something on "OnRoomPropertiesUpdate"...
How to do it? Can anyone point me to any direction please?
Thanks.
0
Comments
-
I found an answer here: https://youtu.be/aVUNiJ3MVSg?t=213
ExitGames team, you should provide some more tutorials and direct answers to important and often called methods that, at first, looks simple, but it can be confusing. I was doing in a different way, it was not returning any errors, only "null" at some point and no clear direction. ANd when I go to your documentation, it says nothing but theory, not direct examples.
Also, many examples here, does not work: https://doc.photonengine.com/en-us/pun/v2/lobby-and-matchmaking/matchmaking-and-lobby (maybe outdated from API, etc).1 -
Hi @AlexUnity,
Thank you for choosing Photon!Also, many examples here, does not work: https://doc.photonengine.com/en-us/pun/v2/lobby-and-matchmaking/matchmaking-and-lobby (maybe outdated from API, etc).1 -
Hi @AlexUnity,
Thank you for choosing Photon!Also, many examples here, does not work: https://doc.photonengine.com/en-us/pun/v2/lobby-and-matchmaking/matchmaking-and-lobby (maybe outdated from API, etc).
Pretty much the Lobby examples. Some I could fix it while I wanted to test (for example, the Lobby custom property can be changed in a different way, I think it is now array based, can't remember).0 -
I found an answer here: https://youtu.be/aVUNiJ3MVSg?t=213
ExitGames team, you should provide some more tutorials and direct answers to important and often called methods that, at first, looks simple, but it can be confusing. I was doing in a different way, it was not returning any errors, only "null" at some point and no clear direction. ANd when I go to your documentation, it says nothing but theory, not direct examples.
Also, many examples here, does not work: https://doc.photonengine.com/en-us/pun/v2/lobby-and-matchmaking/matchmaking-and-lobby (maybe outdated from API, etc).
thank you so much i thought i was just doing something stupid, goign to watch this now
0 -
here is my code for anyone else stuch maybe it will help a n00b
private void CreateRoom() { RoomOptions roomOptions = new RoomOptions() { IsVisible = true, IsOpen = true, MaxPlayers = desiredMaxplayers, }; Hashtable RoomCustomProps = new Hashtable(); RoomCustomProps.Add(MAP_PROP_KEY, desiredCourse); RoomCustomProps.Add(GAME_MODE_PROP_KEY, desiredGamemode); roomOptions.CustomRoomProperties = RoomCustomProps; string[] customPropsForLobby = {MAP_PROP_KEY, GAME_MODE_PROP_KEY }; roomOptions.CustomRoomPropertiesForLobby = customPropsForLobby; PhotonNetwork.CreateRoom(null, roomOptions); }
0