question

barigamb avatar image
barigamb asked

How to get playfab id of other players?

Hello.
I am currently working on a game with playfab but I ran into a problem.

I am using Mirror and not playfab's multiplayer and so I want to get the IP address of players.
I did not find a way to directly get that so I saved it in the player data on login.
But I can only get the user data with the playfab id and having to input the playfab id would be inconvenient for the players. I wanted to work around this by getting the playfab id from the username behind the scenes so that the player can input the username and will get connected. But I found no way to get other player's playfab id, not just from the username but in any way.

Is there a way to do it?
And if there is really no way to do this then why?

Player Dataunity3d
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

barigamb avatar image barigamb commented ·

Also if there is a way to get the IP from the username that would be good too.

0 Likes 0 ·
barigamb avatar image
barigamb answered

Hello.

I solved the issue.

Turnes out this was 100% my fault because I first tried using GetAccountInfo but I got an error because I didn't give an authentication context. I thought this meant that the authentication context has to be from the same user as the one you are trying to access. But now it workes.

Here is the code:

PlayFabClientAPI.GetAccountInfo(new GetAccountInfoRequest { 
	TitleDisplayName = username,
	AuthenticationContext = Login.login.AuthenticationContext 
	},
        result =>
        {
            Debug.Log(result.AccountInfo.PlayFabId);
            PlayFabClientAPI.GetUserData(new GetUserDataRequest {  
		PlayFabId = result.AccountInfo.PlayFabId,
		AuthenticationContext = Login.login.AuthenticationContext 
	},
            result2 =>
            {
                if (result2.Data != null && result2.Data.ContainsKey("ipAddress"))
                {
                    ipAddress = result2.Data["ipAddress"].Value;
                    networkLobbyManager.networkAddress = ipAddress;
                    networkLobbyManager.StartClient();
                }
            },
            error => { Debug.LogError(error.GenerateErrorReport()); });
        },
        error => { Debug.LogError(error.GenerateErrorReport()); });
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

barigamb avatar image barigamb commented ·

Login.login is the variable where the LoginResult is stored.

0 Likes 0 ·
barigamb avatar image
barigamb answered

please someone help.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.