question

ben-2 avatar image
ben-2 asked

Group API with Cloudscript

Hey,

As I understand it the Server API is available in CloudScript, however are any other of the API's exposed synchronously in the same way? I can't seem to find any information on it in the documentation. More specifically, we would like to use the Group API and perform some validation before the user leaves a group for instance: A player leaves a group, if they're an admin of the given group, the admin role is passed to another member. Or if they are the final remaining member the group is closed. Among a bunch of other interactions with the Group API.

Thanks,

Ben

CloudScript
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

Right now, only the Server API is exposed in Cloud Script. We'll be providing additional options for the Group API in an upcoming release, though I can't provide a specific date for that just yet.

4 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.

herzock avatar image herzock commented ·

Hello, is there any update on this?

I am trying to add new players to a group automatically from cloudcode and can't figure out a way to do that.

Is that somehow possible?

0 Likes 0 ·
Andy avatar image Andy ♦♦ herzock commented ·

Yes, though it's not well documented yet, the various parts of the entity API are available in cloud script. An example was recently added to all new titles. I'll include it as a separate comment. The key is using the pre-defined "entity" object.

0 Likes 0 ·
Andy avatar image Andy ♦♦ herzock commented ·
// This an example of a function that calls a PlayFab Entity API. The function is called using the 
// 'ExecuteEntityCloudScript' API (https://api.playfab.com/documentation/CloudScript/method/ExecuteEntityCloudScript).
handlers.makeEntityAPICall = function (args, context) {
    // The profile of the entity specified in the 'ExecuteEntityCloudScript' request.
    // Defaults to the authenticated entity in the X-EntityToken header.
    var entityProfile = context.currentEntity;
    // The pre-defined 'entity' object has functions corresponding to each PlayFab Entity API,
    // including 'SetObjects' (https://api.playfab.com/documentation/Data/method/SetObjects).
    var apiResult = entity.SetObjects({
        Entity: entityProfile.Entity,
        Objects: [
            {
                ObjectName: "obj1",
                DataObject: {
                    foo: "some server computed value",
                    prop1: args.prop1
                }
            }
        ]
    });
    return {
        profile: entityProfile,
        setResult: apiResult.SetResults[0].SetResult
    };
};
0 Likes 0 ·
herzock avatar image herzock commented ·

Thank you! Works like a charm!

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.