Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

RoomList & players

Discussion in 'Connected Games' started by mimat18, Jul 16, 2019.

  1. mimat18

    mimat18

    Joined:
    Feb 16, 2019
    Posts:
    11
    Hi ... I don't know how to get the RoomList and the number if players on the room . I tried to use the functions but i had some errors and had no result .
    Any one please can help me and give me a simple example about how to use it .
    I am using photon pun 2 .
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,185
  3. Livindaki

    Livindaki

    Joined:
    Jun 13, 2017
    Posts:
    35
    ok let me so ask you please about RPC
    public override void OnJoinedRoom()
    {

    Debug.Log("4-State is: " + PhotonNetwork.NetworkClientState.ToString());
    parents = PhotonNetwork.Instantiate("My_View", new Vector3(0, 0.5f, 0), Quaternion.identity, 0);
    parents.transform.SetParent(source.transform);
    pv = parents.GetComponent<PhotonView>();
    if (pv.IsMine && Load_Rooms.Player_Name=="tamim")
    pv.RPC("Reg_Room", RpcTarget.OthersBuffered, Load_Rooms.ClientRoomName, Load_Rooms.ClientRoomSize, Load_Rooms.ClintRoomPassword, Load_Rooms.ClientRoomCoast, Load_Rooms.MasterConfirmCode);
    Debug.Log("Name: " + Load_Rooms.ClientRoomName + " Password: " + Load_Rooms.ClintRoomPassword + " Confirm: " + Load_Rooms.MasterConfirmCode);
    }
    [PunRPC]
    public void Reg_Room (string RN,int RS,string RP,int RC,string MCC)
    {
    Debug.Log("5-State is: " + PhotonNetwork.NetworkClientState.ToString());
    if (Load_Rooms.ClientConfirmCode == MCC)
    {
    Load_Rooms.ClientRoomName = RN;
    Load_Rooms.ClientRoomSize = RS;
    Load_Rooms.ClintRoomPassword = RP;
    Load_Rooms.ClientRoomCoast = RC;
    Create_Room_Is_OK = true;

    PhotonNetwork.LeaveRoom();
    }
    }
    .doesnt work ; the variables on the clients doesnt change ... why ?
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,185
    I'm sorry but I can't debug your code and don't see the problem without that.
    In cases like this: Try to scale back and try to implement a minimal case to check what's working and what isn't.
    The Basics Tutorial could be a good guide for starters. Read and code along. It uses RPCs, too.
     
  5. Livindaki

    Livindaki

    Joined:
    Jun 13, 2017
    Posts:
    35
    Ok NP.
    in a case that i have create a room and entered the room .. and i have a Variable X for each player .. i want to change for every player enter room the value of X .
    i cant do that . cause i am new on multiplyer programming :-(