question

sidlondon avatar image
sidlondon asked

Get the current number of members in a group from the client side

I want to limit the number of members in a specific group to a maximum of 10. When a player asks to join the group during the game, I need to get the current number of players in that group. If it returns a value < 10, allow the player to send a join request. If it is already at the 10 limit, stop the player from sending a join request.

Is there a way to do this via blueprints? I can get the number of roles in the group, but there doesn't seem to be an option for number of members.

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.

Rick Chen avatar image
Rick Chen answered

Normally, the client cannot get a group’s member information (the player count) until they are a member of this group. But you can use the Cloud Script to implement it. When the client apply to a group, your script calls the ListGroupMembers and checks this player count in the group before adding this client to the group.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sidlondon avatar image
sidlondon answered

The blueprints...blueprint1.pngblueprint2.png


blueprint1.png (350.5 KiB)
blueprint2.png (400.4 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sidlondon avatar image
sidlondon answered

@Rick Chen I can't delete the above, but the below is what I'm now adding to the end of the revisions script. On the client side, I tell it to only run this code for the few groups that have membership limits. Then when a response is returned, I can check if the response number is at the limit for that group.

I guess there is still the possibility that a player can cheat by changing it to not run the script for any group or set the accepted response number to a much higher one.

var group = { Id: args.groupId, Type: "group" };
try
{
var allStudents = entity.ListGroupMembers (
{
Group: group
});
}
catch (e)
{
var msg = "Error: " + JSON.stringify(e);
log.info(msg);
return "error";
}
return allStudents.Members;
}
};
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sidlondon avatar image
sidlondon answered

error.pngcloud-script.pngOk, I'm not sure where my other reply has disappeared to, but after trying a few things I'm just getting errors. The latest one is saying there's an issue with the parameters I'm inputting. I'm adding the group entity Id, as that's the only argument in my cloudscript. And the group I'm giving is definitely the right one. So I'm not sure why it's not happy.

I've attached the error, my cloudscript and blueprints (below) for reference. It's failing on the execute cloud script section.

(the rest of the blueprint is for if there is room in the group, send the join request, and if it's successful, I want to get the Id for the members in the group so I can get the data for their character).


error.png (79.6 KiB)
cloud-script.png (22.1 KiB)
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.

Rick Chen avatar image Rick Chen ♦ commented ·

Sorry for the late reply. The error shown in this screenshot is indicating that you are calling the CloudScript with “RevisionSelection” set as “live” and “SpecificRevision” set with a number. Please check your blueprint1.png, you may leave the “SpecificRevision” as null instead of “3” in the “Make ClientExecuteCloudScriptRequest” action.

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.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]