question

bfg avatar image
bfg asked

server.GetPlayersInSegment returning empty list when there are users

Title ID: 238B

SegmentID:72A0826E43EFD02

I have a segment where the condition is a tag. Screenshot 1 shows that there is 1 user in it. I have this cloud script being called from a scheduled task that simply grabs the segment and prints the users. I know this code works because I have other functions doing a similar thing.

handlers.DailyMembershipReward = function(args, context)
{
  var result = server.GetPlayersInSegment({
      MaxBatchSize: 10000,
      SegmentId: "72A0826E43EFD02"
    });


  if(result)
  {
    if(result.ProfilesInSegment != 0)
        {
          	log.info("# OF USERS: " + result.ProfilesInSegment);
          	for(i = 0; i < result.PlayerProfiles.length; i++)
            {
                //Get the profile
                var profile = result.PlayerProfiles[i];
                log.info("{Name : " + profile.DisplayName+","+" PlayFabId: " + profile.PlayerId+"}");
            }
        }
        else
        {
          	log.info("MEMBERSHIP SEGMENT IS EMPTY");
        }
  }

}

However, when the scheduled task fires it returns an empty list.

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.

bfg avatar image bfg commented ·

I forgot to upload the screenshot. I am attempting to upload it but it is not uploading. Anyways, it is just a screenshot showing that there is 1 account in the segment.

0 Likes 0 ·
bfg avatar image bfg commented ·

Using the Try It in the documentation, I can get other segmens just fine. If I try to get the segment in my question it still returns as empty.

0 Likes 0 ·

1 Answer

·
brendan avatar image
brendan answered

It's the same as this thread:

https://community.playfab.com/questions/22956/putting-players-into-a-segment-based-on-tag.html

In short, you must use the fully qualified tag name ("title.[title ID].[tag name]"). The fact that the Game Manager segment page was matching on a sub-string of the tag was the issue causing confusion. I'll open a bug on that.

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.