Problem with FriendList isOnline

Options
Hi, I have a problem with PhotonNetwork.Friends list. It always says that player is online, even if I'm logged on second client with the same name. Everything is commented in code. :) Please help me ASAP ;)
Here's a code on pastebin http://pastebin.com/MftpSawv (Bad things happen at 17 line)
public void Login() //activated by button
    {
        string login = loginClass.nicknameInput.text; // get my nickname from inputfield
        string password = loginClass.passwordInput.text; // get my password from inputfield
        nickname = login; //just set variable
        PhotonNetwork.FindFriends(new string[] { nickname }); // find me in lobby to check if I am online
        loginClass.nicknameInput.interactable = false; // disable player to change values of inputfield
        loginClass.passwordInput.interactable = false; // disable player to change values of inputfield
    }
    public void OnUpdatedFriendList()
    {
        print(PhotonNetwork.Friends[0].Name); 
        print(PhotonNetwork.Friends[0].IsOnline); // show my status 
        StartCoroutine(CheckIfLogged()); 
    IEnumerator CheckIfLogged()
    {
        if (PhotonNetwork.Friends[0].IsOnline) // check if my nickname is already in lobby (here's error,
        {                                      //it is always false, even if i am logged in another client of game
            loginClass.nicknameInput.text = ""; //reset nickname inputfield
            loginClass.passwordInput.text = ""; //reset password inputfield
            loginClass.Warning.text = "Already logged!"; // show warning 
            yield return new WaitForSeconds(1.0f);
            loginClass.Warning.text = ""; // reset wawning text
            loginClass.nicknameInput.interactable = true; //enable player to change values of inputfield
            loginClass.passwordInput.interactable = true; //enable player to change values of inputfield
        }
        else
        {
            PhotonNetwork.playerName = nickname; // set my nickname
            SetMenuState(2); // switch to main menu
        }
    }

Comments

  • vadim
    Options
    You need to set PhotonNetwork.playerName before connecting to Photon. Otherwise lobby would not be able to put the name into its lists.
  • xblade724
    xblade724
    edited March 2017
    Options
    EDIT: 99% sure it has something to do with since I'm using PlayFab with custom auth..
    vadim said:

    You need to set PhotonNetwork.playerName before connecting to Photon. Otherwise lobby would not be able to put the name into its lists.

    If you don't mind the necro bump, I'm in the same situation -- I am sure to fill my PhotonNetwork.playerName BEFORE I connect. I can see my friend online, and I'm not just calling myself I'm calling a list of friends that's NOT me so it definitely has their name or it wouldn't even show up, right?

    The friend shows, but is always offline.





  • JohnTube
    JohnTube ✭✭✭✭✭
    edited March 2017
    Options
    Hi @xblade724,

    I see the issue you are having.
    You need to use UserId / PlayFabId instead of playerName (Nickname) / DisplayName to find friends.
    Please set the userId first before connecting:

    AuthenticationValues customAuth = new AuthenticationValues(pfid);

    or

    customAuth.UserId = pfid;
  • xblade724
    Options
    JohnTube said:

    Hi @xblade724,
    customAuth.UserId = pfid;

    Worked like a charm, mate ;D That was EXACTLY it!