Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Kim Strasser · Jun 08 at 07:38 PM · CloudScript

How can I get a player's tags when I call server.GetFriendsList?

I want to find out if the player has a certain player tag("blocked") but I don't know how to get the player's tags in CloudScript. My code returns 1 for element.Tags.length. This is correct because the player has 1 tag. But element.Tags is always empty, it doesn't return the player's tag.

How can I get the player's tags when I call server.GetFriendsList? I need to find out if the player has a certain tag.

var result = server.GetFriendsList( 
{ 
  "PlayFabId":friendid, 
  "ProfileConstraints":
  {"ShowTags":true
  }
});

if ((result != null) && (result.Error == null))
{ 
  result.Friends.forEach(element => {
  if (element.FriendPlayFabId == currentPlayerId)
  {
    log.info("element.Tags.length: " + element.Tags.length + " " + element.Tags);
    if ((element.Tags.length > 0) && (friendblocked == false))
    {
      element.Tags.forEach(tag => {
      log.info("current tag: " + tag);
      if (tag == "blocked")
      {
        friendblocked = true;
      }
      });
    }
  }
  });
}
else
{
  log.info("error");
  errorcode = result.Error;
}
Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Made Wang · Jun 09 at 07:35 AM

In my test the script reported an error on line 15, the error is that friendblocked is not defined. After adding "var friendblocked=false;" the script works as expected.

You can set GeneratePlayStreamEvent to true when calling ExecuteCloudScript to check whether the script runs successfully in Game Manager->Data->Data Explorer (basic), and you can add "return result;" to get all the information returned.

Also, to clarify, there are two kinds of tags in the result of GetFriendsList, FriendInfo.Tags is added by SetFriendTags, PlayerProfileModel.Tags is added by AddPlayerTag, please make sure which one you are using.

Comment

People who like this

0 Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kim Strasser · Jun 10 at 11:17 AM 0
Share

I use SetFriendTags to update the players friend tags. I found out that the problem was on the client side. The friend tags were not updated in the client and therefore it displayed different friend tags in the client than in the server code. It was correct that element.Tags was empty in CloudScript.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    12 People are following this question.

    avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

    Related Questions

    Update Cloud Script limits? 1 Answer

    [Unreal Engine Blueprints] Cloud function parameter 1 Answer

    What is the execution time limit for a Cloud Script function called From a Task? 1 Answer

    SetFriendTags works for one player but not the other. 1 Answer

    What could cloudscriptapirequesterror indicate? 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges