question

kennyroy avatar image
kennyroy asked

How to access ListMembership in cloud script?

I'm awarding gold to all groups a user is a member of, and first I need to call ListMemberships with CloudScript.

I can't find the right function to call, "group" and "groups" are not predefined objects and calling groups.ListMembership throws:

 "StackTrace": "ReferenceError: groups is not defined\n    at handlers.awardGold (A2460-main.js:216:26)"
        }
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.

kennyroy avatar image
kennyroy answered

got it.

entity predefined object.

Note for anybody not getting a result, this is run on a "title_player_account" so you need this call beforehand for it to work:

var titlePlayerAccount = server.GetUserAccountInfo({ PlayFabId: currentPlayerId }).UserInfo.TitleInfo.TitlePlayerAccount;
    var getMemberships = entity.ListMembership(titlePlayerAccount);
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.

Citrus Yan avatar image Citrus Yan commented ·

Yes, the key here is to get the player's title Entity first and then call ListMembership with that as a parameter:)

0 Likes 0 ·
kennyroy avatar image
kennyroy answered

@Citrus Yan well that is not working. I'm doing a log.debug on both, and even though this titleplayeraccount is in a few entity groups, the result from ListMembership is always empty:

        "Logs": [
            {
                "Level": "Debug",
                "Message": "{\"Id\":\"5B10B8FB62A227C7\",\"Type\":\"title_player_account\",\"TypeString\":\"title_player_account\"}",
                "Data": null
            },
            {
                "Level": "Debug",
                "Message": "{\"Groups\":[]}",
                "Data": null
            }
        ]

as you can see, the GetUserAccountInfo returns correctly, but the groups are empty in the next call.

I'm concerned that this works fine through the Unity SDK and not Cloudscript. This is one of the pivotal aspects of my game that is very easy to exploit and cheat - Cloudscript doing the check is the only way to try to prevent this.

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.