Search Unity

Third Party Photon how to get custom properties from RoomInfo?

Discussion in 'Multiplayer' started by Barry100, Mar 25, 2015.

  1. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    Hi All. I am setting custom properties which I see fine in the lobby when using

    foreach (RoomInfo game in PhotonNetwork.GetRoomList())

    as it shows me the details from all rooms plus I can get all custom properties from this for all rooms eg room name, etc.. the problem I am having is that I want to get the custom properties I have set when I get to the room that I have joined from the lobby list. what I want to do is this.

    when I make a room and have joined the room, I will use a float to set a timestamp from the server. when another player joins the server, they will get this timestamp and set it as a float that they will then use as a start point for a countdown. This is so everyone has the same countdown timer. I have it working using an RPC but the issue I am facing is that when the masterclient leaves the game, he will take the time stamp with him and so if anyone else joins later the timesztamp will be wrong so I think it would be better to set it as a custom property for the room its self as this will then be constant! i am kinda working it out in my head and it all works fine, but I just dont know how to retrieve the custom value I have set!

    How do I get a single custom property from the room i am in??

    any help would be great! Its driving me MAD! again..
     
  2. Neoshiftr

    Neoshiftr

    Joined:
    Dec 5, 2012
    Posts:
    67
    Look at Assets\Photon Unity Networking\UtilityScripts\InRoomRoundTimer.cs in your project folder (if you imported PUN), it shows an example on how to do it.
     
    tobiass likes this.
  3. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    hi - i was using it but it causes more trouble than it solves. I have written my own script that kinda does the same thing but better.. the only thing is when the masterclient leaves the game there is no RPC being buffered to new people coming on the game with the original timestamp
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    You should use a Custom Property for the start timestamp, much like InRoomRoundTimer does.
    There is no benefit in using an RPC. It just makes things more complex because they get cleaned up when the sending player leaves.
     
  5. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    yea i have been trying to use the custom properties but I dont know how to retrieve them. I can set them no bother and retrieve them when in the lobby but i dont know how to do it in game??
     
  6. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070