Rooms with password
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Rooms with password
Vazkuz
2021-03-01 07:11:34
Random question!
(please forgive me if you encounter grammar mistakes, since English is not my native language)
Is there a way to create rooms with paswords? I have done that using custom room options, but the solution is quite difficult to implement and also not that efficient. I have googled for a built-in solution but it seems there is none, if this is the case, what is the reason for Photon developpers not to implement such a feature?
Greetings from Perú :)
Comments
you can save a String in the Custom Property Hastable of the room.
before a player actually joins a Modal will show and ask to verfiy the password
When creating a room
ExitGames.Client.Photon.Hashtable table = new ExitGames.Client.Photon.Hashtable();
table.Add("secret", "pw1234");
RoomOptions roomOptions = new RoomOptions();
roomOptions.CustomRoomProperties = table;
roomOptions.CustomRoomPropertiesForLobby = return new string[] { "secret" };
when showing rooms
RoomInfo[] roomInfos = PhotonNetwork.GetRoomList();
foreach (RoomInfo roomInfo in myListObjects) {
string password = (string)room.CustomProperties["secret"];
}
BTW Room password is a nice idea :smile:
There is no built-in mechanism for password protecting a room. Properties are a workaround.
Alternatively you can hide rooms from the room listing lobbies (with IsVisible = false) and then knowing the room name is like knowing the password for the room.