Godot 4 · GDScript
Groups & clans
Groups (clans/guilds) let players band together. A player belongs to at most one group. Membership has roles and permissions, all enforced on the server.
Requirements
Groups must be enabled for your game (in the panel) and included in your plan. If disabled, group calls fail with error_code "forbidden".
Join policies: open (anyone joins instantly), request (needs approval), invite_only, and closed.
Create a Group
Create a group; the caller becomes its leader. Optionally pass a tag, description, join policy and member cap. Listen to group_created.
Gamdato.group_created.connect(_on_group_created)
Gamdato.create_group("Dragons", {"tag": "DRG", "join_policy": "request"})
func _on_group_created(ok: bool, group: Dictionary, error_code: String) -> void:
if ok: print("Created %s" % group.name)
else: print("Failed: %s" % error_code) # e.g. name_taken, already_in_group# group: Dictionary
{
"id": String, # pass this to join/info/request
"name": String,
"tag": String,
"description": String,
"join_policy": "open" | "request" | "invite_only" | "closed",
"max_members": int,
"member_count": int,
"created_at": String,
"my_role": String # your role in this group
}Browse & Join
List or search groups, then join one. join_group works only for open groups; for request groups, send a join request instead (below).
Gamdato.groups_listed.connect(_on_groups)
Gamdato.list_groups("dra") # search by name
Gamdato.group_joined.connect(_on_joined)
Gamdato.join_group(group_id) # open groups only
func _on_groups(groups: Array) -> void:
for grp in groups:
print("%s - %d members" % [grp.name, grp.member_count])# groups: Array, each group (no my_role here):
{
"id": String,
"name": String,
"tag": String,
"description": String,
"join_policy": String,
"max_members": int,
"member_count": int,
"created_at": String
}Group Details & Members
Get a group full details plus its member list. Omit the id to fetch your own group. Arrives through group_info_loaded.
Gamdato.group_info_loaded.connect(_on_group_info)
Gamdato.get_group_info() # your own group
func _on_group_info(group: Dictionary, members: Array) -> void:
if group.is_empty():
return
for m in members:
print("%s - %s" % [m.player_name, m.role])# group: Dictionary (same shape as Create a Group), or {} if you have none
# members: Array, each member:
{
"player_key": String,
"player_name": String,
"role": String,
"joined_at": String
}Invitations (Group to Player)
Members with permission invite players, list invitations, and respond to ones addressed to them.
Gamdato.group_invite_sent.connect(_on_g_invite)
Gamdato.send_group_invite(player_key, "Join us!")
Gamdato.group_invitation_responded.connect(_on_g_resp)
Gamdato.list_group_invitations("incoming") # -> group_invitations_listed
Gamdato.respond_group_invitation(invitation_id, true) # accept# group_invitations_listed -> invitations: Array, each:
{
"id": String,
"direction": "incoming" | "outgoing",
"group_id": String,
"group_name": String,
"counterpart": {
"player_key": String,
"player_name": String
},
"status": String,
"message": String,
"created_at": String,
"responded_at": String, # null while pending
"expires_at": String
}Join Requests (Player to Group)
For request groups: a player asks to join, and a reviewer (with permission) approves or rejects.
Gamdato.group_request_created.connect(_on_req)
Gamdato.create_group_request(group_id, "Please let me in")
# Reviewer side:
Gamdato.list_group_requests("incoming") # -> group_requests_listed
Gamdato.respond_group_request(request_id, true) # approve# group_requests_listed -> requests: Array, each:
{
"id": String,
"direction": "incoming" | "outgoing",
"group_id": String,
"group_name": String,
"player": {
"player_key": String,
"player_name": String
},
"status": String,
"message": String,
"created_at": String,
"responded_at": String # null while pending
}Manage Members
Leaders and officers manage the roster: kick a member, change a member role, or transfer leadership.
Gamdato.kick_group_member(player_key)
Gamdato.assign_group_role(player_key, "admin") # not "leader"
Gamdato.transfer_group_leadership(player_key)Roles and ranks are enforced server-side. Lacking permission returns error_code "forbidden" or "insufficient_rank". To make someone leader use transfer_group_leadership, not assign_group_role.
Leave or Disband
A member leaves the group; a leader can disband it entirely.
Gamdato.group_left.connect(_on_left)
Gamdato.leave_group() # status: "left" or "disbanded"
Gamdato.disband_group() # leader only
func _on_left(ok: bool, status: String, error_code: String) -> void:
if ok: print("You %s the group" % status)