No Other Players In Room & Checking a RoomInfo List?

Hi there,
another day of gaining inches, not miles as a newb multi player dev, with photon.

here are some questions that have come up today. If you can, please answer what you can.

a) using autoJoinLobby = true, at OnJoinedLobby(), I initiate a check on to see if anyone else is in the room (PhotonNetwork.otherPlayers.Length). If this number hits 1, then I know someone else has entered the room, and thus, can proceed to load a common level.

However, when running the standalone and the editor, no “other player”, ever enters the room. They are internally separate. ???

b) Trying a slightly different approach, I decided to create a room, instead of the lobby, however this is even worse in its results. Using the return OnConnectedToMaster(), I create a room. I realize in its current form not checking if isMasterClient is an issue. But for now, I left it out since my check if(isMasterClient), never returned true after connecting.

So, 1) how is isMasterClient set? I thought it was the first player to arrive on the scene. No?

  1. back to the next issue, OnConnectedToMaster(), for testing purposes, I decided to create a room with a few custom, RoomOptions, isOpen, isVisible and maxPlayers. I create the room…
    print(":::connectedtomaster");
print(":::isMasterClient=" + PhotonNetwork.isMasterClient);
print(":::themasterclientis" + PhotonNetwork.masterClient);
RoomOptions roomOptions = new RoomOptions();
roomOptions.CleanupCacheOnLeave = true;
roomOptions.isOpen = true;
roomOptions.isVisible = true;
roomOptions.maxPlayers = 2;
PhotonNetwork.CreateRoom ("lobby25", roomOptions, TypedLobby.Default);
print("ROOMCREATED::");
checkRoomCreated();

Now, again for testing I want to check the room. I am thinking that this process can be used by non masterClient players, to see if it fits their criteria.

void checkRoomCreated(){
   List <RoomInfo> roomInfoList = new List<RoomInfo>(PhotonNetwork.GetRoomList());
   print("rilc" + roomInfoList.Count);
   for(int i = 0; i < roomInfoList.Count; i++){
      print("ril" + i + "n" + roomInfoList[i].name);
      print("ril" + i + "m" + roomInfoList[i].maxPlayers);
   }
}

However, the result is, that the roomInfoList, has a count of 0. So, how can I check??

Thanks for any help.
Rennie

Do you know our tutorials? Those should help with the initial matchmaking issues and some principles:

and:

The MasterClient is the one who’s longest in the room or one player you set.
The room list is only available (and valid) when you’re in the lobby. When you’re in a room, the list is not available. Checking that is not getting you results, I guess.

EDIT:
UPDATE:
I think I have made the proper adjustments. Entering lobby and waiting for single oppoent seems to work fine! http://www.codesend.com/view/8314896b147044ba9c894fb3f79e7491/

//original response…

Thank you,
Yes, I know the tutorials, and have been following them.

The issue may be my lack of complete jedi knowledge and my own custom needs.

In my game, when a player chooses multi, he has four options of gameplay, he chooses one. This opens a specific scene “Lobby X”. Once in the new lobby scene, my LobbyManager.cs connects to Photon, auto join lobby = true. OnJoinedLobby() I set a bool to true, isInLobby. With this bool true I am now allowed to watch in Update() to see when another player enters. Simple right?

This is why I was surprised as my code does work fine to this point, but when I run the standalone in tandem, following the same steps, the new player does not show in either.

So as it stands now, I have two players in separate lobby’s.

See my LobbyManager.cs here. It is the sole script of the Lobby scene. Its purpose is to connect to Photon Network and wait for opponent.
http://www.codesend.com/view/02cdc1ca5daaa00dd4ff7813a307d4f4/

In Photon, a Lobby is not the same as a room. It’s a list of rooms for users to pick one.
You won’t ever notice anyone else in a lobby (cause potentially thousands of players might be looking for matches in a lobby).
You can use a room. As done by ConnectAndJoinRandom.cs. One player opens the room and waits until someone else joins (which is always the first step).

1 Like

My current set up, works across two devices, my logic suggests it will so on an infinite number too.

Perhaps you can fact check for me?

On play multi()
load level across network (if is master client) this level is lobby.

On joined lobby()
Create room with certain parameters. From here I wait for another player to join the room (I watch via update, otherPlayers).

Once another player has joined the room, I load level across network (if is master).

Yes??
:slight_smile:

Why you watch via other players when there are simpler ways to check is someone else connected to your room? As tobias said you cant check for other players in lobby since it’s master server and not game server.

That’s how I would handle it

[PunRPC]
    private void LoadFinalLevel(int lvl_id)
    {
        PhotonControl.LoadLevel(lvl_id);
    }

    public void OnPhotonPlayerConnected(PhotonPlayer connectedPlayer)
    {
        // Someone joined our room send load final level over net
        if(PhotonControl.playerList.Length > 1 && PhotonControl.isMasterClient)
        {
            int lvlID = 1;

            playerView.RPC("LoadFinalLevel", connectedPlayer,lvlID);
        }
    }