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 /
  • General Discussion /
avatar image
Question by brendan-1 · Jun 30 at 05:33 AM · unity3d

I created a cloudscript that calls server.GetPlayersInSegment. FunctionResult is a list of PlayerProfiles. Instead of returning PlayerProfile[] to the client, I just want to return a list of the PlayerIds contained within all of the PlayerProfiles.

(Unity) My application has a separate Admin functionality which will use the PlayerIds of all the players to Get and Update their PlayerData. The client executes a cloudscript that executes GetPlayersInSegment and returns the PlayerProfile[] as a FunctionResult. I do not want to make a class object for PlayerProfile all I want is a list of all the PlayerIds returned. I have spend way too much time looking for a way to solve this can someone please give me a pointer? I am having trouble with the FunctionResult JSON I believe and none of the PlayFab tutorials explain anything to do with working with FunctionResult.

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 30 at 09:06 AM

If you don't want to process JSON objects on the client side, then you can process the data in Cloud Script (Leagcy) and return it to the client side, refer to the code below. Note that doing this still requires some simple processing on the client side.

Also, we do not recommend calling GetPlayersInSegment in Cloud Script (Leagcy), because this API is resource intensive and should not be used in scenarios which might generate high request volumes. Using this API in Cloud Script (Leagcy) may result in timeout error.

handlers.GetPlayerIdInSegment=function(args,context){
    var result=server.GetPlayersInSegment({
        SegmentId: " "
    });
    var playerIds=new Array();
    result.PlayerProfiles.forEach(Item=>{
        playerIds.push(Item.PlayerId);
    })
    return playerIds;
}
Comment

People who like this

0 Show 0 · 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

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

    2 People are following this question.

    avatar image avatar image

    Related Questions

    Setting up Playfab + Photon on Unity... which SDKs do I need? 1 Answer

    SDK for Unity 2017.4 LTS (probably 2018 too) has no Editor asmdef. Fails to build standalone. 2 Answers

    OAuth consent screen and Playfab: Can't verify because I don't own playfab.com domain 3 Answers

    Unicorn Battle iOS build returns "GetAccountInfo Timed out after 10 seconds." 1 Answer

    Logging in with the Custom ID throws an error in Unity "The account is unavailable, because it is being deleted" 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