i cant get room list
Options
- getroomlist ~ code
if (PhotonNetwork.insideLobby)
{
int count = 0;
var rooms = PhotonNetwork.GetRoomList();
Debug.Log(rooms.Length.ToString() + " room count");
foreach (var room in rooms)
{
if ((int)(room.CustomProperties["C0"]) == modType)
{
count += room.PlayerCount;
}
}
}
- create room code
RoomOptions roomOptions = new RoomOptions();
roomOptions.MaxPlayers = 2;
roomOptions.IsVisible = true;
roomOptions.IsOpen = true;
// in this example, C0 might be 0 or 1 for the two (fictional) game modes
roomOptions.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "C0", nowModType } };
roomOptions.CustomRoomPropertiesForLobby = new string[] { "C0" }; // this makes "C0" available in the lobby
// let's create this room in SqlLobby "myLobby" explicitly
TypedLobby sqlLobby = new TypedLobby("myLobby", LobbyType.SqlLobby);
PhotonNetwork.CreateRoom(null, roomOptions , sqlLobby);
i cant get room list
rooms.Length.ToString() have 0
i activated auto join lobby
many people play games,
but i cant get room list
help me !!
if (PhotonNetwork.insideLobby)
{
int count = 0;
var rooms = PhotonNetwork.GetRoomList();
Debug.Log(rooms.Length.ToString() + " room count");
foreach (var room in rooms)
{
if ((int)(room.CustomProperties["C0"]) == modType)
{
count += room.PlayerCount;
}
}
}
- create room code
RoomOptions roomOptions = new RoomOptions();
roomOptions.MaxPlayers = 2;
roomOptions.IsVisible = true;
roomOptions.IsOpen = true;
// in this example, C0 might be 0 or 1 for the two (fictional) game modes
roomOptions.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "C0", nowModType } };
roomOptions.CustomRoomPropertiesForLobby = new string[] { "C0" }; // this makes "C0" available in the lobby
// let's create this room in SqlLobby "myLobby" explicitly
TypedLobby sqlLobby = new TypedLobby("myLobby", LobbyType.SqlLobby);
PhotonNetwork.CreateRoom(null, roomOptions , sqlLobby);
i cant get room list
rooms.Length.ToString() have 0
i activated auto join lobby
many people play games,
but i cant get room list
help me !!
0
Comments
-
Hi @SungJinKang,
there is a callback telling you that the client received a room list update. You can try implementingvoid OnReceivedRoomListUpdate() { ... }
to see if you have received the current room list. To do so you can callPhotonNetwork.GetRoomList();
from inside that function. Please let me know if you are still not receiving the room list afterwards.0 -
0
-
I guess the client is in the wrong lobby. When you create the room you are doing this in the SqlLobby. When the client connects to Photon and you have enabled autoJoinLobby, the client joins the default lobby and get no rooms from other lobbies. If you explicitly want to use the SqlLobby as you have done in your code, you can disable the autoJoinLobby option. Instead you can use the
void OnConnectedToMaster() { ... }
callback. When this function gets called the client is connected to the Master Server and can join the lobby. Therefore you can usePhotonNetwork.JoinLobby(new TypedLobby("LobbyName", LobbyType.SqlLobby));
from that function. Make sure that you use the same lobby name all the time. If you don't want to use the SqlLobby at all, you can remove all of the SQL related parts and can continue joining the default lobby.0 -
0