Getting problem with get and set custom properties of room ?

Hi
I am trying to set custom properties of room from reference :
https://doc.photonengine.com/en/realtime/current/reference/matchmaking-and-lobby

the copied code in unity editor :
RoomOptions roomOptions = new RoomOptions();
roomOptions.CustomRoomPropertiesForLobby = { "map", "ai" };	roomOptions.CustomRoomProperties = new Hashtable() { { "map", 1 } };
roomOptions.MaxPlayers = expectedMaxPlayers;
lbClient.OpCreateRoom(roomName, roomOptions, typedLobby);
It gives me error : Unexpected symbol `{'.

I am using unity4.6.1 pro unity version and photon realtime sdk v1.64.2
what is "lbClient.OpCreateRoom". I did not find such a method in sdk or in API.


Want to setup room access(joining) based on player ranking like :
1.Room#1 - Accessible for user who has greater than rank say 100.
2Room#2 - Accessible for user who has grater than rank say 200 .

Thank you.

Answers

  • vadim
    vadim mod
    edited May 2016
    Hi.

    - "photon realtime sdk v1.64.2" - what is this? Currently available are Unity 3D SDK and .NET SDK, both of v4.1.0.4
    - "Unexpected symbol `{'" is compiler error. Make sure that your c# code is syntactically correct.
    - lbClient is LoadBalancing client instance previously created with "new LoadBalancingClient(...)" call.
  • hi thanks for the answer.


    I want to make room like
    On clicking join Button :

    1# if one room of 2 maximum players gets full,it should be created maximum 2 player room while hitting join room. This process should be continue.

    So my game scenario is such a like :

    3 brown tables:

    1 brown table for in total 2 players
    1 brown table for in total 4 players
    1 brown table for in total 6 players

    3 yellow tables:

    1 yellow table for in total 2 players
    1 yellow table for in total 4 players
    1 yellow table for in total 6 players

    How it can be possible ? i used custom properties but did not suceed

    please help.
  • Mir
    Mir
    edited September 2016
    //your code need something like this
    using Hashtable = ExitGames.Client.Photon.Hashtable;//dont forget this line. or you cant use hashtable of PhotonNetwork

    function OnPhotonPlayerDisconnected( other : PhotonPlayer )
    {
    if(PhotonNetwork.isMasterClient==true && PhotonNetwork.player list.count%2==0)
    {
    Hastable hashTable=new HashTable;
    switch(PhotonNetwork.room.name)
    {
    case "brown":
    string data="any data you want";
    HashTable.add("brownTable",data);
    PhotonNetwork.room.SetCustomProperties(hashTable);
    break;
    case "yellow":
    string data="any data you want";
    HashTable.add("yellowTable",data);
    PhotonNetwork.room.SetCustomProperties(hashTable);
    break;
    }
    }
    }

    //and you need set room max player 6
    //if there're no room, create room name "brown", if there're "brown" room, create room name "yellow"
  • hello Friends.
    plz help me my problem is
    PhotonNetwork.player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable(1) {{"MyViewID", NetworkManager.Inst.myViewID }, {"Name", playerName }, { "Score", score } });

    hashtable to value add completed next how to remove add index i am not a idea plz help me
  • Hi @chintankansagara,

    you don't need to store the player name in the Player Properties separately, you can use PhotonNetwork.player.NickName = "Player Name"; for example to set the name. This way it is also synchronized and readable for each other client. For scores PUN comes with an included extension. It also uses the Player Properties but is easier to use. You can use PhotonNetwork.player.SetScore(1); to set the player's score to a certain value and PhotonNetwork.player.GetScore(); to get the player's current score.

    To remove an existing property use a new Hashtable which contains a KeyValuePair whereat the key is the same as the index you want to remove and the value is null, like this: Hashtable ht = new Hashtable() { { "Name", null } };. The apply this Hashtable for the Player Properties.