Use an array or list as CUSTOM RROOM PROPERTIES.
Options
Hello. I wan to set an array as customroomproperties.
firstly using foreach I added elements of array in photon hashtable
ExitGames.Client.Photon.Hashtable sh = new ExitGames.Client.Photon.Hashtable(); // only use ExitGames.Client.Photon.Hashtable for Photon
foreach (int i in cardsid){
sh.Add(shufflekey,i);
}
PhotonNetwork.room.SetCustomProperties(sh);
I think that it isnt correct Please help me
firstly using foreach I added elements of array in photon hashtable
ExitGames.Client.Photon.Hashtable sh = new ExitGames.Client.Photon.Hashtable(); // only use ExitGames.Client.Photon.Hashtable for Photon
foreach (int i in cardsid){
sh.Add(shufflekey,i);
}
PhotonNetwork.room.SetCustomProperties(sh);
I think that it isnt correct Please help me
0
Comments
-
I have find a way
for(int i=0; i<cardsid.Length; i++){
string hashid=new string();
hashid=string.Format(hashid,i)
ExitGames.Client.Photon.Hashtable hashid = new ExitGames.Client.Photon.Hashtable();
string keyid=new string();
keyid=leter+i.ToString();
hashid[keyid]=cardsid[i];
PhotonNetwork.room.SetCustomProperties(hashid);
Debug.Log ("EFGGGEEEEEEEEEE");
}
But it gives error at ExitGames.Client.Photon.Hashtable hashid = new ExitGames.Client.Photon.Hashtable();
I think that the problem is variable string hash
what can i da?0 -
A local variable named `hashid' is already defined in this scope
what can i do?0 -
Here is the latest mechanism OnPhotonCustomRoomPropertiesChanged is never execute so nothing is updated. I can not go forward without your help.
for(int i=0; i<cardsid.Length; i++){
ExitGames.Client.Photon.Hashtable hashid = new ExitGames.Client.Photon.Hashtable(); // only use ExitGames.Client.Photon.Hashtable for Photon
string keyid;
keyid=leter+i.ToString();
hashid[keyid]=cardsid[i];
PhotonNetwork.room.SetCustomProperties(hashid);
Debug.Log ("EFGGGEEEEEEEEEE");
}
public void OnPhotonCustomRoomPropertiesChanged(ExitGames.Client.Photon.Hashtable propertiesThatChanged)
{
for(int i=0; i<cardsid.Length; i++){
string keyid;
keyid=leter+i.ToString();
if(propertiesThatChanged.ContainsKey(keyid)){
cardsid[i]=(int)propertiesThatChanged[keyid];
}}
}
0 -
Hi @Eduard
Please use proper code formatting next time it helps others read your posts.
Regarding your question, I think it's not related to the data structure used by Photon to contain Custom Room Properties. The issue is that you should do more programming with C#.
Here's what I suggest from what I could understand :ExitGames.Client.Photon.Hashtable hashid = new ExitGames.Client.Photon.Hashtable(); // out of the loop string keyid; for(int i=0; i<cardsid.Length; i++){ keyid=leter+i.ToString(); hashid[keyid]=cardsid[i]; Debug.Log ("EFGGGEEEEEEEEEE"); } PhotonNetwork.room.SetCustomProperties(hashid); // out of the loop
0 -
I found this topic somewhere today and forgot if I answered.
Please add links to the places where you posted this, too.0 -
Yes sir you answered in this topic forum.unity3d.com/threads/onphotoncustomroompropertieschanged-is-never-executed.343748/#post-2223566
The problem is the hashtable which is not setup correctly. I used the code below from johnTube but doesn't work If statement in OnPhotonCustomRoomPropertiesChanged(ExitGames.Client.Photon.Hashtable propertiesThatChanged) never is true.0 -
To find out what's wrong, you should log the content of the props that changed:
Debug.Log("propertiesThatChanged"+propertiesThatChanged.ToStringFull())
With that, you get a look at what actually arrives and if that's what you think it is.0