question

doronhn avatar image
doronhn asked

Get players in segment count Via cloud script and update title data

Hey,

i want to update my title data key once a day with the number of players in segment.

the problem is not matter what i am doing, it keeps fail on timeout.

what do i do wrong?

i tried also to just get the players in segment without the update (just to see if it causing this to fail).

const NUMBER_OF_PLAYER_TODAY_TITLE_DATA_KEY = "NumberOfPlayersToday";
    
    var getPlayersInSegmentRequest = {
  				    "SegmentId": "4BE38807058EC69B",
  				    "MaxBatchSize": 1
                  };
  
    var playersInSegmentResult = server.GetPlayersInSegment(getPlayersInSegmentRequest);


    var setTitleDataRequest = 
    {
        "Key": NUMBER_OF_PLAYER_TODAY_TITLE_DATA_KEY,
        "Value": playersInSegmentResult.ProfilesInSegment
    };
    
        server.SetTitleData(setTitleDataRequest);
Player DataapisCloudScript
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

·
brendan avatar image
brendan answered

GetPlayersInSegment triggers re-evaluation of the segment, so it can take a non-trivial amount of time to complete. If you want to update Title Data with this value as a daily triggered action, we'd recommend running it in Azure Functions Cloud Script as a queued function, so that it can run for as long as it needs to (but yes, limiting the batch size to 1 will also help).

1 comment
10 |1200

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

doronhn avatar image doronhn commented ·

Is it free?how do i do that?

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.