Rooms with password

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

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).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

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

kk99
2021-03-01 07:43:57

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:

Tobias
2021-03-04 15:45:29

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.

Back to top