GameMaker Studio · GML · Friends
gmda_sendFriendInvite
Sends a friend invitation to a player by key, with an optional message.
Signature
gmda_sendFriendInvite(player_key, [message]) -> realWhat it does
POSTs /friends/invite. Returns 1 when the request is fired, 0 when there is no active session. The result arrives later as an invite_sent event: on success response.invitation is the created row { id, to_player_key, to_player_name, status, message, created_at, expires_at }. On failure success is false and error explains why (self-invite, already friends, a duplicate pending invite, the other player already invited you, that player is not accepting invitations, or not found).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| player_key | string | required | The target player's key (e.g. from a leaderboard row, search result, or profile). |
| message | string | "" | Optional note attached to the invite (stripped of control chars and capped at 200 chars). |
How to call it
Fire gmda_sendFriendInvite(), then read the invite_sent event from gmda_pollEvent() in your Step loop. Reverse-pending means they already invited you, so accept their pending invite instead of sending a new one.
Result event: invite_sent { success, response }
Example
gmda_sendFriendInvite(player_key, "Let's play!");
// In the Step event, drain results:
var _e = gmda_pollEvent();
while (!is_undefined(_e)) {
if (_e.event == "invite_sent") {
if (_e.success) show_debug_message("invited " + _e.response.invitation.to_player_name);
else show_debug_message("invite failed: " + string(_e.error));
}
_e = gmda_pollEvent();
}Use cases
- Add-friend button on a player's profile.
- Invite someone you saw on a leaderboard or in search results.