Skip to content

Friends

Francisco Dias edited this page Nov 24, 2022 · 7 revisions

Back To Top

This a module that manages social info and activities.

Functions

The following functions are provided to interact with this module:

Constants

These are the constants used by this module:




Back To Top

Removes all rich presence data for the user. This is an asynchronous function that will trigger the an Async Social when the task is finished.


Syntax:

GOG_Friends_ClearRichPresence()

Returns:

undefined

Triggers:

Asynchronous Social Event
Key Type Description
type string "GOG_Friends_ClearRichPresence"
error string The error message; only if request failed ✴️ OPTIONAL

Example:

GOG_Friends_ClearRichPresence()

The code sample above starts a clear rich presence task which results can be caught inside an Async Social event.

if (async_load[? "type"] == "GOG_Friends_ClearRichPresence")
{
    if (ds_map_exists(async_load,"error"))
    {
        show_debug_message(async_load[?"error"])
        exit
    }

    show_debug_message("ClearRichPresence SUCCESS")
}

This code sample provides an example of handling the returned callback data.




Back To Top

Removes a user from the friend list. This is an asynchronous function that will trigger the an Async Social when the task is finished.


Syntax:

GOG_Friends_DeleteFriend(userID)
Argument Type Description
userID GalaxyID The GalaxyID of the user to be removed from the friend list.

Returns:

undefined

Triggers:

Asynchronous Social Event
Key Type Description
type string "GOG_Friends_DeleteFriend"
error string The error message; only if request failed ✴️ OPTIONAL
userID struct GOG Galaxy user identifier

Example:

GOG_Friends_DeleteFriend(myFriendID)

The code sample above starts a friend deletion task which result can be caught inside an Async Social event.

if (async_load[? "type"] == "GOG_Friends_DeleteFriend")
{
    if (ds_map_exists(async_load,"error"))
    {
        show_debug_message(async_load[?"error"])
        exit
    }
    var deletedFriend = async_load[?"userID"]
    show_debug_message("Friend Deleted")
}

This code sample provides an example of handling the returned callback data.




Back To Top

Removes the variable value under a specified name. If the variable doesn't exist method call has no effect. This is an asynchronous function that will trigger the an Async Social when the task is finished.


Syntax:

GOG_Friends_DeleteRichPresence(key)
Argument Type Description
key string The name of the variable to be removed.

Triggers:

Asynchronous Social Event
Key Type Description
type string "GOG_Friends_DeleteRichPresence"
error string The error message; only if request failed ✴️ OPTIONAL

Example:

GOG_Friends_DeleteRichPresence("playing")

The code sample above starts a rich presence delete task which results can be caught inside an Async Social event.

if (async_load[? "type"] == "GOG_Friends_DeleteRichPresence")
{
    if (ds_map_exists(async_load,"error"))
    {
        show_debug_message(async_load[?"error"])
        exit
    }

    show_debug_message("DeleteRichPresence SUCCESS")
}

This code sample provides an example of handling the returned callback data.




Back To Top

Finds a specified user. This is an asynchronous function that will trigger the an Async Social when the task is finished.


Syntax:

GOG_Friends_FindUser(userSpecifier)
Argument Type Description
userSpecifier string The specifier of the user.

Returns:

undefined

Triggers:

Asynchronous Social Event
Key Type Description
type string "GOG_Friends_FindUser"
error string The error message; only if request failed ✴️ OPTIONAL
userID GalaxyID The ID of the user.

Example:

GOG_Friends_FindUser(userSpecifier)

The code sample above starts a find user task which results can be caught inside an Async Social event.

if (async_load[? "type"] == "GOG_Friends_FindUser")
{
    if (ds_map_exists(async_load,"error"))
    {
        show_debug_message(async_load[?"error"])
        exit
    }
    var user = async_load[?"userID"]
    show_debug_message("FindUser SUCCESS")
}

This code sample provides an example of handling the returned callback data.




Back To Top

Returns the default avatar criteria which is a real with the bit sum of default AvatarType.


Syntax:

GOG_Friends_GetDefaultAvatarCriteria()

Returns:

real

Example:

var AvatarCriteria = GOG_Friends_GetDefaultAvatarCriteria()

The code above provides a simple usage example.




Back To Top

Returns the ID of the avatar of a specified user.

⚠️ REQUIREMENT

Retrieve the avatar image first by calling GOG_Friends_RequestUserInformation with appropriate avatar criteria.


Syntax:

GOG_Friends_GetFriendAvatarImageID(userID, avatarType)
Argument Type Description
userID GalaxyID The ID of the user.
avatarType AvatarType The type of avatar.

Returns:

real

Example:

var ImageID = GOG_Friends_GetFriendAvatarImageID(userID, GOG_AVATAR_TYPE_SMALL)

The code above provides a simple usage example.




Back To Top

Copies the avatar of a specified user.

⚠️ REQUIREMENT

You might need to retrieve the data first by calling GOG_Friends_RequestUserInformation.

ℹ️ NOTE

The size of the output buffer will be 4 * height * width (check AvatarType, for width and height values).

WARNING This function creates a new buffer everytime it is called you need to ensure you correctly delete the buffer when you don't need it anymore using the buffer_delete function. Failing to do so will result in memory leaks.


Syntax:

GOG_Friends_GetFriendAvatarImageRGBA(userID, avatarType)
Argument Type Description
userID GalaxyID The ID of the user.
AvatarType AvatarType The type of avatar.

Returns:

id.buffer

Example:

if(GOG_Friends_IsFriendAvatarImageRGBAAvailable(userID,GOG_AVATAR_TYPE_LARGE))
{
    var buff = GOG_Friends_GetFriendAvatarImageRGBA(userID,GOG_AVATAR_TYPE_LARGE)

    var size = buffer_get_size(buff)
    var L = sqrt(size/4)

    surf = surface_create(L,L)
    buffer_set_surface(buff,surf,0)

    buffer_delete(buff)
}

The code above provides a simple usage example.




Back To Top

Returns the URL of the avatar of a specified user.

⚠️ REQUIREMENT

You might need to retrieve the data first by calling GOG_Friends_RequestUserInformation.


Syntax:

GOG_Friends_GetFriendAvatarUrl(userID, AvatarType)
Argument Type Description
userID GalaxyID The ID of the user.
avatarType AvatarType The type of avatar.

Returns:

string

Example:

var url = GOG_Friends_GetFriendAvatarUrl(userID, GOG_AVATAR_TYPE_SMALL)

The code above provides a simple usage example.




Back To Top

Returns the GalaxyID for a friend.

⚠️ REQUIREMENT

Retrieve the list of friends first by calling GOG_Friends_RequestFriendList.


Syntax:

GOG_Friends_GetFriendByIndex(index)
Argument Type Description
index real Index as an integer in the range of [0, number of friends).

Returns:

struct (GalaxyID)

Example:

for(var a = 0 ; a < GOG_Friends_GetFriendCount() ; a++)
{
    var friendID = GOG_Friends_GetFriendByIndex(a),GOG_AVATAR_TYPE_LARGE)
}

The code above provides a simple usage example.




Back To Top

Returns the number of retrieved friends in the user's list of friends.

⚠️ REQUIREMENT

Retrieve the list of friends first by calling GOG_Friends_RequestFriendList.


Syntax:

GOG_Friends_GetFriendCount()

Returns:

real

Example:

for(var a = 0 ; a < GOG_Friends_GetFriendCount() ; a++)
{
    var friendID = GOG_Friends_GetFriendByIndex(a),GOG_AVATAR_TYPE_LARGE)
}

The code above provides a simple usage example.




Back To Top

Reads the details of the friend invitation.


Syntax:

GOG_Friends_GetFriendInvitationByIndex(index)
Argument Type Description
index real Index as an integer in the range of [0, number of friend invitations).

Returns:

struct
Struct Member Type Description
userID GalaxyID The ID of the user who sent the invitation.
sendTime real The time at which the friend invitation was sent.

Example:

for(var i = 0 ; i < GOG_Friends_GetFriendInvitationCount() ; i++)
{
    var struct = GOG_Friends_GetFriendInvitationByIndex(i)
    var userID = struct.userID
    var sendTime = struct.sendTime
}

The code above provides a simple usage example.




Back To Top

Returns the number of retrieved friend invitations.


Syntax:

GOG_Friends_GetFriendInvitationCount()

Returns:

real

Example:

for(var i = 0 ; i < GOG_Friends_GetFriendInvitationCount() ; i++)
{
    var struct = GOG_Friends_GetFriendInvitationByIndex(i)
    var userID = struct.userID
    var sendTime = struct.sendTime
}

The code above provides a simple usage example.




Back To Top

Returns the nickname of a specified user.

⚠️ REQUIREMENT

You might need to retrieve the data first by calling GOG_Friends_RequestUserInformation.


Syntax:

GOG_Friends_GetFriendPersonaName(userID)
Argument Type Description
userID GalaxyID The ID of the user.

Returns:

string

Example:

var name = GOG_Friends_GetFriendPersonaName(GOG_User_GetGalaxyID())

The code above provides a simple usage example.




Back To Top

Returns the state of a specified user, see PersonaState.

⚠️ REQUIREMENT

You might need to retrieve the data first by calling GOG_Friends_RequestUserInformation.


Syntax:

GOG_Friends_GetFriendPersonaState(userID)
Argument Type Description
userID GalaxyID The ID of the user.

Returns:

real (PersonaState)

Example:

if (GOG_Friends_GetFriendPersonaState(myFriendID) == GOG_PERSONA_STATE_ONLINE)
{
    //My friend is online, do something
}

The code above provides a simple usage example.




Back To Top

Returns the user's nickname.


Syntax:

GOG_Friends_GetPersonaName()

Returns:

string

Example:

var name = GOG_Friends_GetPersonaName()

The code above provides a simple usage example.




Back To Top

Returns the user's state.


Syntax:

GOG_Friends_GetPersonaState (userID)

Returns:

real (PersonaState)

Example:

if(GOG_Friends_GetPersonaState() == GOG_PERSONA_STATE_ONLINE)
{
    // I'm online right now
}

The code above provides a simple usage example.




Back To Top

Returns the rich presence of a specified user.

⚠️ REQUIREMENT

Retrieve the rich presence first by calling GOG_Friends_RequestRichPresence.


Syntax:

GOG_Friends_GetRichPresence(key, userID)
Argument Type Description
key string The name of the property of the user's rich presence.
userID GalaxyID The ID of the user.

Returns:

string

Example:

var value = GOG_Friends_GetRichPresence("playing",GOG_User_GetGalaxyID())

The code above provides a simple usage example.




Back To Top

Returns a property from the rich presence storage by index.

⚠️ REQUIREMENT

Retrieve the rich presence first by calling GOG_Friends_RequestRichPresence.


Syntax:

GOG_Friends_GetRichPresenceByIndex(index, userID)
Argument Type Description
index real Index as an integer in the range of [0, number of entries).
userID GalaxyID The ID of the user.

Returns:

struct
Struct Member Type Description
key string The name of the property of the user's rich presence.
value string The value of the property.

Example:

for(var i = 0 ; i < GOG_Friends_GetRichPresenceCount(GOG_User_GetGalaxyID()) ; i++)
{
    var struct = GOG_Friends_GetRichPresenceByIndex(i,GOG_User_GetGalaxyID())
    var key = struct.key
    var value = struct.value
}

The code above provides a simple usage example.




Back To Top

Returns the number of retrieved properties in user's rich presence.

⚠️ REQUIREMENT

Retrieve the rich presence first by calling GOG_Friends_RequestRichPresence.


Syntax:

GOG_Friends_GetRichPresenceCount(userID)
Argument Type Description
userID GalaxyID The ID of the user.

Returns:

real

Example:

for(var i = 0 ; i < GOG_Friends_GetRichPresenceCount(GOG_User_GetGalaxyID()) ; i++)
{
    var struct = GOG_Friends_GetRichPresenceByIndex(i,GOG_User_GetGalaxyID())
    var key = struct.key
    var value = struct.value
}

The code above provides a simple usage example.




Back To Top

Returns a key from the rich presence storage by index.

⚠️ REQUIREMENT

Retrieve the rich presence first by calling GOG_Friends_RequestRichPresence.


Syntax:

GOG_Friends_GetRichPresenceKeyByIndex(index, userID)
Argument Type Description
index real Index as an integer in the range of [0, number of entries).
userID GalaxyID The ID of the user.

Returns:

string

Example:

for (var i = 0; i < GOG_Friends_GetRichPresenceCount(GOG_User_GetGalaxyID()); i++)
{
    var key = GOG_Friends_GetRichPresenceKeyByIndex(i,GOG_User_GetGalaxyID())
}

The code above provides a simple usage example.




Back To Top

Checks if a specified user is a friend.

⚠️ REQUIREMENT

Retrieve the list of friends first by calling GOG_Friends_RequestFriendList.


Syntax:

GOG_Friends_IsFriend(userID)
Argument Type Description
userID GalaxyID The ID of the user.

Returns:

bool

Example:

if (GOG_Friends_IsFriend(friendID))
{
    //Is my friend, do something
}

The code above provides a simple usage example.




Back To Top

Checks if a specified avatar image is available.


Syntax:

GOG_Friends_IsFriendAvatarImageRGBAAvailable(userID, avatarID)
Argument Type Description
userID GalaxyID The ID of the user.
avatarID AvatarType The type of avatar.

Returns:

bool

Example:

if (GOG_Friends_IsFriendAvatarImageRGBAAvailable(userID,GOG_AVATAR_TYPE_LARGE))
{
    var buff = GOG_Friends_GetFriendAvatarImageRGBA(userID,GOG_AVATAR_TYPE_LARGE)

    var size = buffer_get_size(buff)
    var L = sqrt(size/4)

    surf = surface_create(L,L)
    buffer_set_surface(buff,surf,0)

    buffer_delete(buff)
}

The code above provides a simple usage example.




Back To Top

Checks if the information of specified user is available.


Syntax:

GOG_Friends_IsUserInformationAvailable(userID)
Argument Type Description
userID GalaxyID The ID of the user.

Returns:

bool

Example:

if (GOG_Friends_IsUserInformationAvailable(GOG_User_GetGalaxyID()))
{
   var name = GOG_Friends_GetPersonaName(GOG_User_GetGalaxyID())
}

The code above provides a simple usage example.




Back To Top

Checks if a specified user is playing the same game.

⚠️ REQUIREMENT

Retrieve the rich presence first by calling GOG_Friends_RequestRichPresence.


Syntax:

GOG_Friends_IsUserInTheSameGame(userID)
Argument Type Description
userID GalaxyID The ID of the user.

Returns:

bool

Example:

if(GOG_Friends_IsUserInformationAvailable(friendID))
{
   if(GOG_Friends_IsUserInTheSameGame(friendID))
   {
       //my friend is on same game, do something
   }
}

The code above provides a simple usage example.




Back To Top

Performs a request for the user's list of incoming friend invitations. This is an asynchronous function that will trigger the an Async Social when the task is finished.


Syntax:

GOG_Friends_RequestFriendInvitationList()

Returns:

undefined

Triggers:

Asynchronous Social Event
Key Type Description
type string "GOG_Friends_RequestFriendInvitationList"
error string The error message; only if request failed ✴️ OPTIONAL

Example:

GOG_Friends_RequestFriendInvitationList()

The code sample above starts task for requesting friends invitation data which results can be caught inside an Async Social event.

if (async_load[? "type"] == "GOG_Friends_RequestFriendInvitationList")
{
    if (ds_map_exists(async_load,"error"))
    {
        show_debug_message(async_load[?"error"])
        exit
    }

    show_debug_message("RequestFriendInvitationList SUCCESS")
}

This code sample provides an example of handling the returned callback data.




Back To Top

Performs a request for the user's list of friends. This is an asynchronous function that will trigger the an Async Social when the task is finished.


Syntax:

GOG_Friends_RequestFriendList()

Returns:

undefined

Triggers:

Asynchronous Social Event
Key Type Description
type string "GOG_Friends_RequestFriendList"
error string The error message; only if request failed ✴️ OPTIONAL

Example:

GOG_Friends_RequestFriendList()

The code sample above starts task for requesting friends data which results can be caught inside an Async Social event.

if (async_load[? "type"] == "GOG_Friends_RequestFriendList")
{
    if (ds_map_exists(async_load,"error"))
    {
        show_debug_message(async_load[?"error"])
        exit
    }

    show_debug_message("RequestFriendList SUCCESS")
}

This code sample provides an example of handling the returned callback data.




Back To Top

Performs a request for the user's rich presence. This is an asynchronous function that will trigger the an Async Social when the task is finished.


Syntax:

GOG_Friends_RequestRichPresence(userID)
Argument Type Description
userID GalaxyID The ID of the user.

Returns:

undefined

Triggers:

Asynchronous Social Event
Key Type Description
type string "GOG_Friends_RequestRichPresence"
error string The error message; only if request failed ✴️ OPTIONAL

Example:

GOG_Friends_RequestRichPresence() 

The code sample above starts task for requesting rich presence data which results can be caught inside an Async Social event.

if (async_load[? "type"] == "GOG_Friends_RequestRichPresence")
{
    if (ds_map_exists(async_load,"error"))
    {
        show_debug_message(async_load[?"error"])
        exit
    }

    show_debug_message("RequestRichPresence SUCCESS")
}

This code sample provides an example of handling the returned callback data.




Back To Top

Performs a request for the user's list of outgoing friend invitations. This is an asynchronous function that will trigger the an Async Social when the task is finished.


Syntax:

GOG_Friends_RequestSentFriendInvitationList()

Returns:

undefined

Triggers:

Asynchronous Social Event
Key Type Description
type string "GOG_Friends_RequestSentFriendInvitationList"
error string The error message; only if request failed ✴️ OPTIONAL

Example:

GOG_Friends_RequestSentFriendInvitationList() 

The code sample above starts task for requesting sent friendship invitation data which results can be caught inside an Async Social event.

if (async_load[? "type"] == "GOG_Friends_RequestSentFriendInvitationList")
{
    if (ds_map_exists(async_load,"error"))
    {
        show_debug_message(async_load[?"error"])
        exit
    }

    show_debug_message("RequestSentFriendInvitationList SUCCESS")
}

This code sample provides an example of handling the returned callback data.




Back To Top

Performs a request for information about specified user. This is an asynchronous function that will trigger the an Async Social when the task is finished.


Syntax:

GOG_Friends_RequestUserInformation(userID)
Argument Type Description
userID GalaxyID The ID of the user.

Triggers:

Asynchronous Social Event
Key Type Description
type string "GOG_Friends_RequestUserInformation"
error string The error message; only if request failed ✴️ OPTIONAL

Example:

GOG_Friends_RequestUserInformation() 

The code sample above starts task for requesting user information data which results can be caught inside an Async Social event.

if (async_load[? "type"] == "GOG_Friends_RequestUserInformation")
{
    if (ds_map_exists(async_load,"error"))
    {
        show_debug_message(async_load[?"error"])
        exit
    }

    show_debug_message("GOG_Friends_RequestUserInformation SUCCESS")
}

This code sample provides an example of handling the returned callback data.




Back To Top

Responds to the friend invitation. This is an asynchronous function that will trigger the an Async Social when the task is finished.


Syntax:

Discord_Core_Create(userID, accept)
Argument Type Description
userID GalaxyID The ID of the user who sent the friend invitation.
accept bool True when accepting the invitation, false when declining.

Returns:

undefined

Triggers:

Asynchronous Social Event
Key Type Description
type string "GOG_Friends_RespondToFriendInvitation"
error string The error message; only if request failed ✴️ OPTIONAL
userID GalaxyID The ID of the user.
accept bool true to accept invitation, false to refuse

Example:

GOG_Friends_RespondToFriendInvitation()

The code sample above starts task for responding to a pending invitation which results can be caught inside an Async Social event.

if (async_load[? "type"] == "GOG_Friends_RespondToFriendInvitation") 
{
    if (ds_map_exists(async_load,"error"))
    {
        show_debug_message(async_load[?"error"])
        exit
    }

    show_debug_message("RespondToFriendInvitation SUCCESS")
}

This code sample provides an example of handling the returned callback data.




Back To Top

Sends a friend invitation. This is an asynchronous function that will trigger the an Async Social when the task is finished.


Syntax:

GOG_Friends_SendFriendInvitation(userID)
Argument Type Description
userID GalaxyID The ID of the user.

Returns:

undefined

Triggers:

Asynchronous Social Event
Key Type Description
type string "GOG_Friends_SendFriendInvitation"
error string The error message; only if request failed ✴️ OPTIONAL
userID GalaxyID The ID of the user.

Example:

GOG_Friends_SendFriendInvitation (friendID)

The code sample above starts task for sending a friend invitation which results can be caught inside an Async Social event.

if(async_load[? "type"] == "GOG_Friends_SendFriendInvitation")
{
    if (ds_map_exists(async_load,"error"))
    {
        show_debug_message(async_load[?"error"])
        exit
    }

    show_debug_message("SendFriendInvitationSUCCESS")
}

This code sample provides an example of handling the returned callback data.




Back To Top

Sends a game invitation without using the overlay. This is an asynchronous function that will trigger the an Async Social when the task is finished.


Syntax:

GOG_Friends_SendInvitation(userID, connectionString)
Argument Type Description
userID GalaxyID The ID of the user.
connectionString string The string which contains connection info with the limit of 4095 bytes.

Returns:

undefined

Triggers:

Asynchronous Social Event
Key Type Description
type string "GOG_Friends_RespondToFriendInvitation"
error string The error message; only if request failed ✴️ OPTIONAL
userID GalaxyID The ID of the user.
connectionString string connectionString

Example:

GOG_Friends_SendInvitation(userID,connectionString)

The code sample above starts task for sending a play invitation which results can be caught inside an Async Social event.

if (async_load[? "type"] == "GOG_Friends_RespondToFriendInvitation")
{
    if (ds_map_exists(async_load,"error"))
    {
        show_debug_message(async_load[?"error"])
        exit
    }

    show_debug_message("SendInvitation SUCCESS")
}

This code sample provides an example of handling the returned callback data.




Back To Top

Sets the default avatar criteria.


Syntax:

GOG_Friends_SetDefaultAvatarCriteria(defaultAvatarCriteria)
Argument Type Description
defaultAvatarCriteria real The bit sum of default AvatarType.

Returns:

undefined

Example:

GOG_Friends_SetDefaultAvatarCriteria(GOG_AVATAR_TYPE_SMALL)

The code above provides a simple usage example.




Back To Top

Sets the variable value under a specified name. There are three keys that can be used:

  • "status" - The description visible in Galaxy Client with the limit of 3000 bytes.

  • "metadata" - The metadata that describes the status to other instances of the game with the limit of 2048 bytes.

  • "connect" - The string which contains connection info with the limit of 4095 bytes. It can be regarded as a passive version of GOG_Friends_SendInvitation because it allows friends that notice the rich presence to join a multiplayer game.

    This is an asynchronous function that will trigger the an Async Social when the task is finished.


Syntax:

GOG_Friends_SetRichPresence(key, value)
Argument Type Description
key string The name of the property of the user's rich presence (see above).
value string The value of the property to set.

Returns:

undefined

Triggers:

Asynchronous Social Event
Key Type Description
type string "GOG_Friends_RespondToFriendInvitation"
error string Only if request failed

Example:

GOG_Friends_RespondToFriendInvitation()

The code sample above starts task for setting the rich presence value which results can be caught inside an Async Social event.

if (async_load[? "type"] == "GOG_Friends_SetRichPresence")
{
    if (ds_map_exists(async_load,"error"))
    {
        show_debug_message(async_load[?"error"])
        exit
    }

   show_debug_message("SetRichPresence SUCCESS")
}

This code sample provides an example of handling the returned callback data.




Back To Top

Shows game invitation dialog that allows to invite users to game.

ℹ️ NOTE

For this call to work, the overlay needs to be initialized first. To check whether the overlay is initialized, call GOG_Utils_GetOverlayState.


Syntax:

GOG_Friends_ShowOverlayInviteDialog(connectionString)
Argument Type Description
connectionString string The string which contains connection info with the limit of 4095 bytes.

Returns:

undefined

Example:

GOG_Friends_ShowOverlayInviteDialog(connectionString)

The code above provides a simple usage example.




Back To Top

These constants represent state of a user, are used with the following function calls:

Persona State Constant Description
GOG_PERSONA_STATE_OFFLINE User is not currently logged on.
GOG_PERSONA_STATE_ONLINE User is logged on.




Back To Top

These constants represent type of an user avatar, are used with the following function calls:

Avatar Type Constant Description
GOG_AVATAR_TYPE_NONE No avatar type specified.
GOG_AVATAR_TYPE_SMALL Avatar resolution size: 32x32.
GOG_AVATAR_TYPE_MEDIUM Avatar resolution size: 64x64.
GOG_AVATAR_TYPE_LARGE Avatar resolution size: 184x184.




Clone this wiki locally