SetCustomPropesties Queue
Options
querwilly
✭✭
Hello
Only one user can be custom properties color blue?
SetCustomProperties => it takes a little time to be active in all users
To prevent simultaneous operation
Can you give an example or solution
Problem Example. How can you be in a queue?
Alex and Vika Joined Room.
Alex and Vika at the same time Button Click
public void ButtonClick(){
ChangeColor();
}
-----------
public void ChangeColor(){
if(ColorAvailable){
Hashtable HC = new Hashtable ();
HC.Add ("color", "blue");
PhotonNetwork.player.SetCustomProperties (HC);
}
}
---------------
public bool ColorAvailable(){
foreach (PhotonPlayer player in PhotonNetwork.playerList) {
string c = (string)player.customProperties ["color"];
if (c == "blue") {
return false;
}
}
return true;
}
---------------------------------
Help
Only one user can be custom properties color blue?
SetCustomProperties => it takes a little time to be active in all users
To prevent simultaneous operation
Can you give an example or solution
Problem Example. How can you be in a queue?
Alex and Vika Joined Room.
Alex and Vika at the same time Button Click
public void ButtonClick(){
ChangeColor();
}
-----------
public void ChangeColor(){
if(ColorAvailable){
Hashtable HC = new Hashtable ();
HC.Add ("color", "blue");
PhotonNetwork.player.SetCustomProperties (HC);
}
}
---------------
public bool ColorAvailable(){
foreach (PhotonPlayer player in PhotonNetwork.playerList) {
string c = (string)player.customProperties ["color"];
if (c == "blue") {
return false;
}
}
return true;
}
---------------------------------
Help
0
Comments
-
I guess you could have the players request a color from the MasterClient, who in turn has a list with all available colors. When he receives a request, he checks if the color is available and responds accordingly.0
-
Hi,
You can store player per color values in custom room properties. In this case you are always sure that color assigned only once since last player which chose this color overrides previous. To prevent such overrides when 2 players set color simultaneously, use 'expectedValues'' parameters of PhotonNetwork.room.SetCustomProperties.0