Search Unity

Third Party OnPhotonCustomRoomPropertiesChanged is never executed.

Discussion in 'Multiplayer' started by coldfire 1993, Jul 26, 2015.

  1. coldfire 1993

    coldfire 1993

    Joined:
    Oct 28, 2014
    Posts:
    9
    Hello friend. I am making a multiplayergame using photon. I need that one array of elements to b as custom property as it uses random sorting. but the function OnPhotonCustomRoomPropertiesChanged is never executed. I am afraid that Setting custon is the problem
    Code (CSharp):
    1. for(int i=0; i<cardsid.Length; i++){
    2.        
    3.         ExitGames.Client.Photon.Hashtable  hashid = new ExitGames.Client.Photon.Hashtable();  // only use ExitGames.Client.Photon.Hashtable for Photon
    4.  
    5.  
    6.             string  keyid;
    7.             keyid=leter+i.ToString();
    8.             hashid[keyid]=cardsid[i];
    9.             PhotonNetwork.room.SetCustomProperties(hashid);
    10.             Debug.Log ("EFGGGEEEEEEEEEE");
    11.         }
    and
    Code (CSharp):
    1. public void OnPhotonCustomRoomPropertiesChanged(ExitGames.Client.Photon.Hashtable propertiesThatChanged)
    2.     {
    3.         for(int i=0; i<cardsid.Length; i++){
    4.             string  keyid;
    5.             keyid=leter+i.ToString();
    6.             if(propertiesThatChanged.ContainsKey(keyid)){
    7.                 cardsid[i]=(int)propertiesThatChanged[keyid];
    8.  
    9.             }}
    10.     }
     
  2. coldfire 1993

    coldfire 1993

    Joined:
    Oct 28, 2014
    Posts:
    9
    Any help please
     
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    Which version of PUN are you using?
    Your spelling looks correct, the callback should exist.
    Did you have a debug log in OnPhotonCustomRoomPropertiesChanged?
    Any error in the console?
     
  4. coldfire 1993

    coldfire 1993

    Joined:
    Oct 28, 2014
    Posts:
    9
    I don't have any error in console.but this if statement dont work It just doesn't executes. I have put a debug log before it and it works but inside the if condition it doesn't work
    Please take a look at the function that sets properties. is it correct?
    each card has it key id in the hashtable. Where is the problem?
     
    Last edited: Jul 27, 2015
  5. coldfire 1993

    coldfire 1993

    Joined:
    Oct 28, 2014
    Posts:
    9
    I have just fixed the problem deleting return inside the first if statement.in
    Code (CSharp):
    1.  
    2. if (id==1&&playerThatShufflesTheCards==0)
    3.         {  playerThatShufflesTheCards++;
    4.             shuffle ();
    5.             Debug.Log ("setup");
    6.          return;
    7.  
    8.         }
    It was my mistake
     
    Last edited: Jul 27, 2015
  6. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    Good you found it. And thanks for updating us. :)