question

sidlondon avatar image
sidlondon asked

Join group automatically?

I want new players to be able to join 3 of my groups automatically (so no one needs to accept their invitation, they can just request to join via the client and they will be added as members of the group). I'm trying to do this via the Revisions script and group policy, then (I'm guessing) add a Rule that runs the script when a player requests to join the group.

So, my question is in 3 parts:

* Firstly, which event type do I use for the Rule that tells it to run the Revision script when a player requests to join the group? I found a list at

https://learn.microsoft.com/en-us/gaming/playfab/api-references/events/ but none of these seem to apply.

* Secondly, I've added group policies for Apply to join group and Accept applications. Do these look correct? Both should allow any player of the game title to apply and accept group membership.

{
"Action": "Create",
"Effect": "Allow",
"Resource": "pfrn:group--*!*/Applications/*",
"Principal": {
"ChildOf": {
"EntityType": "title",
"EntityId": "24566"
}
},
"Comment": "Allow all players to apply to join the group",
"Condition": null
},
{
"Action": "Accept",
"Effect": "Allow",
"Resource": "pfrn:group--group!*/Applications/*",
"Principal": {
"ChildOf": {
"EntityType": "title",
"EntityId": "24566"
}
},
"Comment": "Allow all players to accept group applications",
"Condition": null
},

* Thirdly, the Revision script I have is the below. I've modified it several times, but it's still not working. Can anyone advise?

// Accept group membership application.
handlers.AutoJoinGroup = function (args) {
var group = { Id: args.groupId, Type: "group" }
var playerData = server.GetUserInternalData({
PlayFabId: currentPlayerId;

try
{
var PlayFabId = entity.AcceptGroupApplicationRequest (
{
Group: group
});
}
catch (e)
{
var msg = "Error: " + JSON.stringify(e);
log.info(msg);

return "error";
}

return true;
};

unreal
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

·
Xiao Zha avatar image
Xiao Zha answered

>> which event type do I use for the Rule that tells it to run the Revision script when a player requests to join the group?

PlayFab doesn’t provide a built-in event which will be triggered when a player request to join the group.

>> I've added group policies for Apply to join group and Accept applications. Do these look correct?

You can’t accept an application only with the permission of Application, you also need the permission of Members and Roles. Also, we recommend using the API call.

>>the Revision script I have is the below. I've modified it several times, but it's still not working. Can anyone advise?

Since you want players to be able to join the group automatically, you can directly call the Add Member API in the Cloud Script when the player wants to join the group instead of asking players to apply to join first, and then accept the application in the Cloud Script. You can refer to the code example in this thread: How to join group for new player - Playfab Community.

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.

danghoang2109 avatar image danghoang2109 commented ·

what policy i need for these permission

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.