GameMaker Studio · GML · Groups & clans
gmda_createGroup
Creates a group; the caller becomes its leader.
Signature
gmda_createGroup(name, [opts_struct]) -> realWhat it does
POSTs /groups/create, then queues group_created. On the next gmda_pollEvent() you get { event: "group_created", success, response }. e.response is the raw server body: on success the new group { id, name, tag, description, join_policy, max_members, member_count, created_at, my_role } is at e.response.group. On failure success is false and e.error carries the raw server message (e.g. "Group name is already taken", "Group tag is already taken", "You are already in a group") plus http_status.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| name | string | required | Group name (sanitized to max 50 chars). |
| opts_struct | struct | {} | Optional settings: tag (<=8 chars), description (<=500), join_policy ("open"|"request"|"invite_only"|"closed"), max_members (1-1000). Omit any key to use the server default. |
How to call it
Call it any time after the session is active; it returns 1 when the request was sent, or 0 if there is no session yet. Read the result later by draining gmda_pollEvent() in the Step loop and matching e.event == "group_created". Groups are gated by your plan (AllowGroups) AND game.groups_enabled; if disabled, e.error is "Groups feature is not enabled for this game" (or "Groups are not enabled for this game").
Result event: group_created { success, response }
Example
gmda_createGroup("Dragons", { tag: "DRG", join_policy: "request" });
// in the controller Step event, drain the queue:
var e = gmda_pollEvent();
while (!is_undefined(e)) {
if (e.event == "group_created") {
if (e.success) show_debug_message("Created " + e.response.group.name);
else show_debug_message("Failed: " + e.error); // e.g. "Group name is already taken"
}
e = gmda_pollEvent();
}Use cases
- Let a player start a clan.
- Create a guild with an approval (request) join policy.