Godot 4 · GDScript
Friends
Friendship system: invitations, pending list, and leaderboards filtered to friends only.
Send an Invitation
Invite a player by their key and listen to invite_sent:
Gamdato.invite_sent.connect(_on_invite)
Gamdato.send_friend_invite(player_key, "Let's play!")# invitation: Dictionary (the one just created)
{
"id": String,
"to_player_key": String,
"to_player_name": String,
"status": "pending",
"message": String,
"created_at": String,
"expires_at": String
}List Invitations
Get pending invitations (sent and received) combined:
Gamdato.invitations_listed.connect(_on_invites)
Gamdato.list_pending_invitations()# invitations: Array, each invitation:
{
"id": String, # pass this to respond/cancel
"direction": "incoming" | "outgoing",
"counterpart": {
"player_key": String,
"player_name": String
},
"status": "pending",
"message": String, # may be empty
"created_at": String, # ISO date
"responded_at": String, # null while pending
"expires_at": String # ISO date
}Respond & Cancel
Accept or decline a received invitation, or cancel one you sent:
Gamdato.respond_invitation(invitation_id, true) # accept
Gamdato.cancel_invitation(invitation_id) # cancel a sent oneList Your Friends
Get the accepted friends list (not invitations). Optionally filter by name.
Gamdato.friends_loaded.connect(_on_friends)
Gamdato.list_friends() # or list_friends(50, "text")
func _on_friends(friends: Array) -> void:
for f in friends:
print("%s (since %s)" % [f.player_name, f.friends_since])# friends: Array, each friend:
{
"player_key": String,
"player_name": String,
"friends_since": String # ISO date
}Remove a Friend
Delete an existing friendship by player key.
Gamdato.friend_removed.connect(_on_removed)
Gamdato.remove_friend(player_key)
func _on_removed(ok: bool, key: String, error_code: String) -> void:
if ok: print("Friend removed")