question

Carl Winder avatar image
Carl Winder asked

CloudScript AddSharedGroupMembers

I'm trying to create a shared group in CloudScript after 2 players have matched in matchmaking.

handlers.gameHostCreateGroup = function (args, context) {
    var groupId = args.group_id;
    var members = args.members;
    log.info(members[0].id);

    var createSharedGroupRequest = { SharedGroupId: groupId };
    server.CreateSharedGroup(createSharedGroupRequest);

    var updateSharedGroupDataRequest = { 
        SharedGroupId: groupId, 
        Data: {
            'network': args.network
        } 
    };

    server.UpdateSharedGroupData(updateSharedGroupDataRequest);

    var playFabIds = [];

    for(var i = 0; i < members.length; i++) {
        playFabIds.push(members[i].id);
    }

    var addSharedGroupMembersRequest = {
        PlayFabIds: playFabIds,
        SharedGroupId: groupId
    };

    server.AddSharedGroupMembers(addSharedGroupMembersRequest);

    return { 'status': 'OK' };
};

The id property on the members array is the ID from the EntityKey from the login result.

However, when I try and call AddSharedGroupMembers I get the error

"code":400,
"status":"BadRequest",
"error":"AccountNotFound",
"errorCode":1001,
"errorMessage":"User not found"

I'm using CustomLogin with CreateAccount = true at the moment for testing purposes.

I'm guessing the entity key ID is not the same as a PlayFabId

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

·
Citrus Yan avatar image
Citrus Yan answered

I believe you’re using ids from this section:

https://docs.microsoft.com/en-us/rest/api/playfab/client/authentication/loginwithcustomid?view=playfab-rest#entitykey

which is the id of the title player account. In your case, you should use PlayFabId instead, which is also returned from login calls:

https://docs.microsoft.com/en-us/rest/api/playfab/client/authentication/loginwithcustomid?view=playfab-rest#loginresult

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.

Carl Winder avatar image Carl Winder commented ·

Ahhh this won't work in my scenario because it's for creating a group once match making has succeeded.

Thanks for your help.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Carl Winder commented ·

So you're using ids from matchmaking results?

0 Likes 0 ·
Carl Winder avatar image Carl Winder Citrus Yan commented ·

Yeah, I'm doing research into PlayFab, so I was basing some of it on the Bumble Rumble sample from the PlayFab Samples repo.

0 Likes 0 ·
Show more comments

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.