Skip to content
YYBartT edited this page Nov 19, 2025 · 3 revisions

Users

Log in, log out and log in from previously cached user data. Access user's account information to customise your game to your target audience.

Functions

The following functions are provided for working with user and accounts:

Structs

Extra details on structs that are returned as user fetching results:



Back To Top

GameJolt_User_FetchMe

This function fetches the logged user data (see UserData).

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 Success Callback, or Failure Callback.


Syntax:

GameJolt_User_FetchMe(callback_success=undefined, callback_failed=undefined)
Argument Type Description
callback_success Function The callback function executed if the request succeeds
callback_failed Function The callback function executed if the request fails



Returns:

N/A


Triggers:

Success Callback

Triggered when the request succeeds

Key Type Description
user_data UserData The user data

Failure Callback

Triggered when the request fails

Key Type Description
error_message String The error message

Example:

GameJolt_User_FetchMe(
    function(_userData)
    {
        var _id = _userData.id;
        var _type = _userData.type;
        var _username = _userData.username;
        var _avatar_url = _userData.avatar_url;
        var _signed_up = _userData.signed_up;
        var _signed_up_timestamp = _userData.signed_up_timestamp;
        var _last_logged_in = _userData.last_logged_in;
        var _last_logged_in_timestamp = _userData.last_logged_in_timestamp;
        var _status = _userData.status;
        var _developer_name = _userData.developer_name;
        var _developer_website = _userData.developer_website;
        var _developer_description = _userData.developer_description;
        sprite = sprite_add(_avatar_url, 0, 0, 0, 0, 0);
    },
    function(message)
    {
        show_message_async(message);
    }
);

The code above will fetch the current logged user data (see UserData) and after successfully retrieving it it starts loading the avatar_url of the user (using the function sprite_add). If it fails, it prints an asynchronous message with the error.




Back To Top

GameJolt_User_FetchWithUserID

This function fetches the user data of a specific user ID (see UserData).

Tip

This function is helpful for retrieving information from friends' user_id, GameJolt_Friends.

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 Success Callback, or Failure Callback.


Syntax:

GameJolt_User_FetchWithUserID(user_id, callback_success=undefined, callback_failed=undefined)
Argument Type Description
user_id String The player's user ID
callback_success Function The callback function executed if the request succeeds
callback_failed Function The callback function executed if the request fails



Returns:

N/A


Triggers:

Success Callback

Triggered when the request succeeds

Key Type Description
user_data UserData The user data

Failure Callback

Triggered when the request fails

Key Type Description
error_message String The error message

Example:

GameJolt_User_FetchWithUserID(32323,
    function(_userData)
    {
        var _id = _userData.id;
        var _type = _userData.type;
        var _username = _userData.username;
        var _avatar_url = _userData.avatar_url;
        var _signed_up = _userData.signed_up;
        var _signed_up_timestamp = _userData.signed_up_timestamp;
        var _last_logged_in = _userData.last_logged_in;
        var _last_logged_in_timestamp = _userData.last_logged_in_timestamp;
        var _status = _userData.status;
        var _developer_name = _userData.developer_name;
        var _developer_website = _userData.developer_website;
        var _developer_description = _userData.developer_description;
        sprite = sprite_add(_avatar_url, 0, 0, 0, 0, 0);
    },
    function(message)
    {
        show_message_async(message);
    });

The code above will fetch the user data (see UserData) of a given user ID (you can get the user IDs of friends using the GameJolt_Friends function) and after successfully retrieving it it starts loading the avatar_url of the user (using the function sprite_add). If it fails, it prints an asynchronous message with the error.




Back To Top

GameJolt_User_FetchWithUserName

This function fetches the user data of a specific username (see UserData).

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 Success Callback, or Failure Callback.


Syntax:

GameJolt_User_FetchWithUserName(username, callback_success=undefined, callback_failed=undefined)
Argument Type Description
username String The player's username
callback_success Function The callback function executed if the request succeeds
callback_failed Function The callback function executed if the request fails



Returns:

N/A


Triggers:

Success Callback

Triggered when the request succeeds

Key Type Description
user_data UserData The user data

Failure Callback

Triggered when the request fails

Key Type Description
error_message String The error message

Example:

GameJolt_User_FetchWithUserName("gameMaster",
    function(_userData)
    {
        var _id = _userData.id;
        var _type = _userData.type;
        var _username = _userData.username;
        var _avatar_url = _userData.avatar_url;
        var _signed_up = _userData.signed_up;
        var _signed_up_timestamp = _userData.signed_up_timestamp;
        var _last_logged_in = _userData.last_logged_in;
        var _last_logged_in_timestamp = _userData.last_logged_in_timestamp;
        var _status = _userData.status;
        var _developer_name = _userData.developer_name;
        var _developer_website = _userData.developer_website;
        var _developer_description = _userData.developer_description;
        sprite = sprite_add(_avatar_url, 0, 0, 0, 0, 0);
    },
    function(message)
    {
        show_message_async(message);
    });

The code above will fetch the user data (see UserData) of a given username and, after successfully retrieving it, it starts loading the avatar_url of the user (using the function sprite_add). If it fails, it prints an asynchronous message with the error.




Back To Top

GameJolt_User_IsLogged

This function checks if the user is currently logged in.


Syntax:

GameJolt_User_IsLogged()



Returns:

Boolean


Example:

if (GameJolt_User_IsLogged())
{
    GameJolt_User_LogOut();
}
else
{
    GameJolt_User_LogIn_FromCache();
}

The code sample above will check if the user is currently logged in and, if so, logs the user out (using the function GameJolt_User_LogOut), otherwise it will log the user in with the information stored in the cache (using the function GameJolt_User_LogIn_FromCache).




Back To Top

GameJolt_User_LogIn

This function authenticates the user's information. This should be done before you make any calls for the user, to make sure the user's credentials (username and token) are valid.

Note

You can use GameJolt_User_LogIn_FromCache to login with cached data over the next sessions.

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 Success Callback, or Failure Callback.


Syntax:

GameJolt_User_LogIn(user_name, game_token, callback_success=undefined, callback_failed=undefined)
Argument Type Description
user_name String The user's username
game_token String The user's token
callback_success String The callback function executed when the request succeeds
callback_failed String The callback function executed if the request fails



Returns:

N/A


Triggers:

Success Callback

Triggered when the request succeeds


Failure Callback

Triggered when the request fails

Key Type Description
error_message String The error message

Example:

GameJolt_User_LogIn(user, token,
    function()
    {
        instance_create_depth(200, 250, 0, objPlayer);
    },
    function(message)
    {
        show_message_async("Error: " + message);
    }
);

The code sample above will log in a user to a specific game using the game token for that game. After a successful login it creates an instance of objPlayer in the room (using the instance_create_depth function), otherwise it will display an error message.




Back To Top

GameJolt_User_LogIn_FromCache

This function logs in using the cached data from previous sessions (see GameJolt_User_LogIn).


Syntax:

GameJolt_User_LogIn_FromCache()



Returns:

Boolean


Example:

if (GameJolt_User_LogIn_FromCache())
{
    instance_create_depth(200, 250, 0, objPlayer);
}

The code sample above will try to log in a user to a specific game using data cached from a previous session. If the login is successful, it creates an instance of objPlayer inside the room (using the instance_create_depth function).




Back To Top

GameJolt_User_LogOut

This function closes a session and clears its cache.


Syntax:

GameJolt_User_LogOut()



Returns:

N/A


Example:

if (GameJolt_User_IsLogged())
{
    GameJolt_User_LogOut();
}

The code sample above will check if the user is currently logged in (using the GameJolt_User_IsLogged function) and, if so, it logs out the user.




Back To Top

UserData

This struct contains details that describe a user.

This struct is referenced by the following functions:


Member Type Description
id Real The ID of the user
type String The type of user. Can be "User", "Developer", "Moderator", or "Administrator".
username String The user's username
avatar_url String The URL of the user's avatar
signed_up String How long ago the user signed up (example: "1 year ago")
signed_up_timestamp Real The timestamp (in seconds) of when the user signed up
last_logged_in String How long ago the user was last logged in. Will be "Online Now" if the user is currently online. (example: "2 minutes ago")
last_logged_in_timestamp Real The timestamp (in seconds) of when the user was last logged in
status String "Active" if the user is still a member of the site. "Banned" if they've been banned.
developer_name String The user's display name
developer_website String The user's website (or an empty string "" if not specified)
developer_description String The user's profile markdown description

Clone this wiki locally