question

Livvy avatar image
Livvy asked

Getting MasterPlayerAccountId of opponent from their EntityId,Getting MasterPlayerAccountId of another player

Hello all!

I have been working on creating a matchmaker where the players can look at the opponent's variable to see if they are set up (by having the player look at the other player's ready key to see if it is 1 or 0).

I know I need to find the other player's MasterPlayerAccountId in order to look at the data, but have been having trouble with seeing how to write it.


I am a visual learner and work best with examples, and although I have been looking at the API, I haven't seen any examples which can lead me to the solution.

Here are the key methods I have so far, and thank you in advance:

private void StartMatchmaking()
    {
      PlayFabMultiplayerAPI.CreateMatchmakingTicket(
        new CreateMatchmakingTicketRequest
        {
          Creator = new MatchmakingPlayer
          {
            Entity = new PlayFab.MultiplayerModels.EntityKey
            {
              Id = EntityId,
              Type = "title_player_account"
            },
            Attributes = new MatchmakingPlayerAttributes
            {
              DataObject = new { }
            }
          },
          GiveUpAfterSeconds = 60,
          QueueName = QUEUE
        },
        OnMatchMakingTicketCreated,
        OnMatchmakingError
      );
    }


//Where I assume I should be getting the player's MasterPlayerAccountId
private void OnMatchMakingTicketCreated(CreateMatchmakingTicketResult result)
    {
      /*var request = PlayFabProfileModels.GetEntityProfileRequest {Entity = EntityKey};
      PlayFabProfilesAPI.GetProfile(request,
      response =>
      {
        Debug.Log(response.Profile.Lineage.MasterPlayerAccountId);
      }, GetProfileError);*/
      
      ticketId = result.TicketId;
      pollTicketCoroutine = StartCoroutine(PollTicket());
      leaveBtn.gameObject.SetActive(true);
    }

//Where the opponent's ready status can be searched
public void GetReady() {
  PlayFabServerAPI.GetUserData(new PlayFab.ServerModels.GetUserDataRequest
  {
    //PlayFabId = opponent's playFabId
  }, result =>
  {
    if (result.Data != null && result.Data.ContainsKey("Ship"))
    {
      ready = int.Parse(result.Data["Ship"].Value);
    }
  }, error =>
  {
    Debug.LogError(error.GenerateErrorReport());
  });
}

,

Hello all!

I have been working on creating a matchmaker where the players can look at the opponent's variable to see if they are set up (by having the player look at the other player's ready key to see if it is 1 or 0).

I know I need to find the other player's MasterPlayerAccountId in order to look at the data, but have been having trouble with seeing how to write it.


I am a visual learner and work best with examples, and although I have been looking at the API, I haven't seen any examples which can lead me to the solution.

Here are the key methods I have so far, and thank you in advance:

private void StartMatchmaking()
    {
      PlayFabMultiplayerAPI.CreateMatchmakingTicket(
        new CreateMatchmakingTicketRequest
        {
          Creator = new MatchmakingPlayer
          {
            Entity = new PlayFab.MultiplayerModels.EntityKey
            {
              Id = EntityId,
              Type = "title_player_account"
            },
            Attributes = new MatchmakingPlayerAttributes
            {
              DataObject = new { }
            }
          },
          GiveUpAfterSeconds = 60,
          QueueName = QUEUE
        },
        OnMatchMakingTicketCreated,
        OnMatchmakingError
      );
    }


//Where I assume I should be getting the player's MasterPlayerAccountId
private void OnMatchMakingTicketCreated(CreateMatchmakingTicketResult result)
    {
      /*var request = PlayFabProfileModels.GetEntityProfileRequest {Entity = EntityKey};
      PlayFabProfilesAPI.GetProfile(request,
      response =>
      {
        Debug.Log(response.Profile.Lineage.MasterPlayerAccountId);
      }, GetProfileError);*/
      
      ticketId = result.TicketId;
      pollTicketCoroutine = StartCoroutine(PollTicket());
      leaveBtn.gameObject.SetActive(true);
    }

//Where the opponent's ready status can be searched
public void GetReady() {
  PlayFabServerAPI.GetUserData(new PlayFab.ServerModels.GetUserDataRequest
  {
    //PlayFabId = opponent's playFabId
  }, result =>
  {
    if (result.Data != null && result.Data.ContainsKey("Ship"))
    {
      ready = int.Parse(result.Data["Ship"].Value);
    }
  }, error =>
  {
    Debug.LogError(error.GenerateErrorReport());
  });
}

Player DataMatchmaking
10 |1200

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

1 Answer

·
Seth Du avatar image
Seth Du answered

If you mean getting Master Player Account ID (PlayFab ID) from Title Player Account ID, you need to have an additional GetProfile API call. The property EntityChain and Lineage contains master player account.

To be clear, the default Entity Policy may deny access to other players' profile, and you may either implement this feature on Azure Function (title player account in and master player account out) or modify the global entity policy in title settings.

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.