Skip to content

General

Francisco Dias edited this page Feb 9, 2024 · 8 revisions

General

The following set of functions are all for checking the availability of certain aspects of the Steam client or server API. This means that these functions should be used before any other Steam API function call to ensure that the client/server setup is correct and communicating with your game:

Functions

This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.



Back To Top

steam_initialised

When using the Steam API, this function can be called to check that the Steam client API has been initialised correctly before doing any further calls to Steam-specific functions in your game.


Syntax:

steam_initialised()

Returns:

Boolean


Example:

global.steam_api = false;
if (steam_initialised())
{
    if (steam_stats_ready() && steam_is_overlay_enabled())
    {
        global.steam_api = true;
    }
}

The above code will set a global variable to true if the Steam client API is correctly initialised, along with the Steam statistics and overlay functionality, or it will set the variable to false otherwise.




Back To Top

steam_stats_ready

When using the Steam API, this function can be called to check that the Steam client API has correctly initialised the statistics for your game.


Syntax:

steam_stats_ready()

Returns:

Boolean


Example:

global.steam_api = false;
if steam_initialised()
{
    if steam_stats_ready() && steam_is_overlay_enabled()
    {
        global.steam_api = true;
    }
}

The above code will set a global variable to true if the Steam client API is correctly initialised, along with the Steam statistics and overlay functionality, or it will set the variable to false otherwise.




Back To Top

steam_get_app_id

This function is used retrieve the unique app ID that Steam assigns to your game, which is required for using some of the UGC functions.


Syntax:

steam_get_app_id()

Returns:

Real


Example:

global.app_id = steam_get_app_id();

The above code gets the unique app ID for your game on Steam and stores it in a global variable.




Back To Top

steam_get_user_account_id

This function is used to retrieve the unique User ID that Steam assigns to each user, which is required for using some of the UGC functions.


Syntax:

steam_get_user_account_id()

Returns:

Real


Example:

global.user_id = steam_get_user_account_id();

The above code gets the unique user ID for the person who owns the game and stores it in a global variable.




Back To Top

steam_get_user_steam_id

You can use this function to return the unique Steam user ID of the user currently logged into the Steam client. If you need to get the user's on screen user name you should refer to the function steam_get_persona_name.


Syntax:

steam_get_user_steam_id()

Returns:

Int64


Example:

if steam_initialised()
{
    global.u_id = steam_get_user_steam_id();
}

The above code will set a global variable to the current users unique Steam ID if the Steam client API is correctly initialised.




Back To Top

steam_get_persona_name

You can use this function to return the user name of the user currently logged into the Steam client. This is the visible screen name and not the unique user ID (this can be found using the function steam_get_user_steam_id).


Syntax:

steam_get_persona_name()

Returns:

String


Example:

if steam_initialised()
{
    global.p_name = steam_get_persona_name();
}

The above code will set a global variable to current users screen name if the Steam client API is correctly initialised.




Back To Top

steam_get_user_persona_name

This function can be used to retrieve the user name (screen name) for any specific user ID. This is an asynchronous function that will return an asynchronous ID and trigger the Steam Async Event when the task is finished.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Steam Async Event.


Syntax:

steam_get_user_persona_name(steamID)
Argument Type Description
steamID Int64 The unique Steam ID for a user.

Returns:

Real


Triggers:

Steam Async Event

Key Type Description
id Real The asynchronous request ID
event_type String The string value "user_persona_name"
steamid Int64 The unique user ID of the user currently logged into the Steam client
persona_name String The visible screen name of the user currently logged into the Steam client

Example:

request = steam_get_user_persona_name(global.UGC_UserID);

The above code will request the user name of the user ID stored in the global variable "UGC_UserID", storing the returned value in a variable for parsing in the Steam Async Event.




Back To Top

steam_get_user_persona_name_sync

This function gets the specified user's persona (display) name.

This will only be known to the current user if the other user is in their friends list, on the same game server, in a chat room or lobby, or in a small Steam group with the local user.


Syntax:

steam_get_user_persona_name_sync(steamID)
Argument Type Description
steamID Int64 The unique Steam ID for a user.

Returns:

String




Back To Top

steam_is_user_logged_on

This function will return true if the Steam client currently has a live connection to the Steam servers. If it returns false, it means there is no active connection due to either a networking issue on the local machine, or the Steam server being down or busy.


Syntax:

steam_is_user_logged_on()

Returns:

Boolean


Example:

if (steam_is_user_logged_on())
{
    global.user_id = steam_get_user_account_id();
}

The above code will check to see if the user is logged onto the Steam server and if it stores the user ID in a global variable.




Back To Top

steam_user_cancel_auth_ticket

This function cancels an authentication ticket.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Steam Async Event.


Syntax:

steam_user_cancel_auth_ticket(ticket_handle=undefined)
Argument Type Description
ticket_handle Real OPTIONAL The ticket handle to cancel

Returns:

N/A


Triggers:

Steam Async Event

Key Type Description
event_type String The string value "ticket_response"
result Real The Steam EResult code
success Boolean Whether result is equal to the value k_EResultOK
auth_ticket_handle Real The handle of the auth ticket, can be passed to steam_user_cancel_auth_ticket



Back To Top

steam_current_game_language

This function retrieves the current language that Steam is using (as a string), for example "english".


Syntax:

steam_current_game_language()

Returns:

String


Example:

language = steam_current_game_language();

The above code gets the language used for the current game.




Back To Top

steam_available_languages

This function can be used to retrieve a list of all available languages for Steam. The returned value is simply a comma-separated list of languages.


Syntax:

steam_available_languages()

Returns:

String


Example:

languages = steam_available_languages();

The above gets the available languages for Steam as a string and stores it in a variable.




Back To Top

steam_is_subscribed

This function checks if the active user is subscribed to the current App ID.

Note

This will always return true if you're using Steam DRM.


Syntax:

steam_is_subscribed()

Returns:

Boolean


Example:

if (steam_is_subscribed())
{
    show_debug_message("is_subscribed");
}

The above code will check to see if the user is subscribed and shows a debug message if that is the case.




Back To Top

steam_set_warning_message_hook

This function sets a warning message hook to receive Steam API warnings and info messages in the console.


Syntax:

steam_set_warning_message_hook()

Returns:

N/A


Example:

steam_set_warning_message_hook();

The above code start Steamworks logging messages in console.