question

Teodor Plop avatar image
Teodor Plop asked

Scheduled Task and Context Entity

Hi there!

I am running a scheduled task on a segment of players, calling a custom cloud script function. In that function, I want to call ListMembership for the player. How can I get the entity of the player? The context seems to return my profile, which is the master player id. What I need is the title player id.

Or am I missing something?

Thanks in advance!

Teo

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

·
Citrus Yan avatar image
Citrus Yan answered

You can utilize the GetTitlePlayersFromMasterPlayerAccountIds API to retrieve the entity of a title player account from a master player account id, and then use that with ListMembership. Here is a sample CloudScript function code I tested in my title you may find helpful:

handlers.test = function(args, context) {
  
  var titlePlayerAccountEntity = entity.GetTitlePlayersFromMasterPlayerAccountIds({MasterPlayerAccountIds : currentPlayerId}).TitlePlayerAccounts[currentPlayerId];

  var memberships = entity.ListMembership({Entity: titlePlayerAccountEntity});

  return memberships;

}

What the function does is the following:

  1. Retrieve the title player entity from a master player id, the title player entity looks like this:
{
   "Id": "7F5657806909EC0A",
   "Type": "title_player_account",
   "TypeString": "title_player_account"
}

2. Pass the title player entity as a parameter for the ListMembership API to consume.

3. Return the result

2 comments
10 |1200

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

Teodor Plop avatar image Teodor Plop commented ·

Cheers! Exactly what I needed. Thanks!

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Teodor Plop commented ·

Glad it helped:)

0 Likes 0 ·

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.