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;
};