Skip to content

LocalPlayer

Francisco Dias edited this page Jul 17, 2026 · 6 revisions

Local Player

This module provides functions to authenticate and query the local Game Center player.

Note

Game Center is an Apple-only feature, available on iOS and macOS. You must authenticate the local player using gamecenter_local_player_authenticate before using any other Game Center feature.

Functions

The following functions are provided to work with the local player:

Structs

The following structs are used by the local player functions:



Back To Top

gamecenter_local_player_authenticate

This function authenticates the local player with Game Center. You must authenticate the local player before using any other Game Center feature.

The result of the authentication is delivered to the given callback, which receives a single GameCenterAuthResult struct argument.

Note

GameKit re-invokes the authentication handler whenever the authentication state changes (for example when the app returns to the foreground, or the player signs out and back in). This means the callback is recurring: it can fire multiple times across the lifetime of the app, not just once. Do not free any state the callback depends on after its first invocation.

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 Callback.


Syntax:

gamecenter_local_player_authenticate(callback)
Argument Type Description
callback Function The function to call with the authentication result

Returns:

N/A


Triggers:

Callback

This callback is triggered whenever the local player's authentication state changes.

Key Type Description
result GameCenterAuthResult A GameCenterAuthResult struct describing the result of the authentication

Example:

gamecenter_local_player_authenticate(function(_result) {
    if (_result.success) {
        show_debug_message($"Authenticated as {_result.player.display_name}");
    } else {
        show_debug_message($"Authentication failed ({_result.error_code}): {_result.error_message}");
    }
});

This code authenticates the local player and outputs a debug message with the result.



Back To Top

gamecenter_local_player_is_authenticated

This function returns whether the local player is currently authenticated with Game Center.


Syntax:

gamecenter_local_player_is_authenticated()

Returns:

Boolean


Example:

if (gamecenter_local_player_is_authenticated()) {
    show_debug_message("Player is authenticated.");
}

This code checks whether the local player is authenticated.



Back To Top

gamecenter_local_player_is_underage

This function returns whether the local player is underage.


Syntax:

gamecenter_local_player_is_underage()

Returns:

Boolean


Example:

var _underage = gamecenter_local_player_is_underage();

This code gets whether the local player is underage.



Back To Top

gamecenter_local_player_is_multiplayer_gaming_restricted

This function returns whether multiplayer gaming is restricted for the local player.


Syntax:

gamecenter_local_player_is_multiplayer_gaming_restricted()

Returns:

Boolean


Example:

var _restricted = gamecenter_local_player_is_multiplayer_gaming_restricted();

This code gets whether multiplayer gaming is restricted for the local player.



Back To Top

gamecenter_local_player_is_personalized_communication_restricted

This function returns whether personalized communication is restricted for the local player, i.e. whether the player can use personalized communication on the device.


Syntax:

gamecenter_local_player_is_personalized_communication_restricted()

Returns:

Boolean


Example:

var _restricted = gamecenter_local_player_is_personalized_communication_restricted();

This code gets whether personalized communication is restricted for the local player.



Back To Top

gamecenter_local_player_get_info

This function synchronously returns the local player's information as a GameCenterPlayer struct.

Note

The local player must be authenticated (see gamecenter_local_player_authenticate) before the returned information is valid.


Syntax:

gamecenter_local_player_get_info()

Returns:

GameCenterPlayer


Example:

var _player = gamecenter_local_player_get_info();
show_debug_message(_player.display_name);

This code gets the local player's information and outputs the display name in a debug message.



Back To Top

GameCenterPlayer

This struct contains the information of a Game Center player.

This struct is referenced by the following functions:

This struct is referenced by the following structs:


Member Type Description
alias String The player's alias (nickname)
display_name String The player's display name
player_id String The player's Game Center identifier (legacy)
game_player_id String The player's game-scoped Game Center identifier
team_player_id String The player's team-scoped Game Center identifier (may be empty on older OS versions)


Back To Top

GameCenterAuthResult

This struct contains the result of a local player authentication attempt (see gamecenter_local_player_authenticate).

Note

When success is false, error_code and error_message describe the failure and the other fields may be empty.

This struct is referenced by the following functions:


Member Type Description
success Boolean Whether the authentication succeeded
error_code Real The error code (valid when success is false)
error_message String A description of the error (valid when success is false)
authentication_state String A short string describing the authentication state (e.g. "authenticated", "presenting_view", "unknown")
authenticated Boolean Whether the local player is authenticated
player GameCenterPlayer A GameCenterPlayer struct with the local player's information


Clone this wiki locally