# Platform Parameters

At any time, you can retrieve values for specific parameters that you might use in your game, such as the user's browser language.

#### Platform ID <a href="#platform-id" id="platform-id"></a>

Identify the platform on which the game is currently running to customize features and settings accordingly.

```gdscript
Bridge.platform.id
```

Returns the platform ID on which the game is currently running. Possible values: `playgama`, `vk`, `ok`, `yandex`, `facebook`, `crazy_games`, `game_distribution`, `playdeck`, `telegram`, `y8`, `lagged`, `msn`, `microsoft_store`, `poki`, `qa_tool`, `discord`, `gamepush`, `bitquest`, `huawei`, `jio_games`, `reddit`, `youtube`, `mock`, `xiaomi`.

#### <img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2F9BooaofCI33U9Np5oeif%2FFrame%203%20(1).png?alt=media&#x26;token=0750b56a-a069-4759-bda9-29951f06cd30" alt="" data-size="line"> Language <a href="#language" id="language"></a>

{% hint style="warning" %}
Check the language to display proper text labels.&#x20;
{% endhint %}

Get the language set by the user on the platform or the browser language if not provided by the platform, to localize game content.

```gdscript
Bridge.platform.language
```

Returns the language set by the user on the platform. If the platform does not provide this data, it returns the browser language. Format: ISO 639-1. Example: `jp`, `en`.

#### URL Parameter <a href="#url-parameter" id="url-parameter"></a>

Embed auxiliary information into the game URL to pass additional data or settings when launching the game.

```gdscript
Bridge.platform.payload
```

Allows embedding auxiliary information into the game URL.

| Platform    | URL Format                                                           |
| ----------- | -------------------------------------------------------------------- |
| VK          | <http://vk.com/game\\_i&#x64;**#your-info>\*\*                       |
| Yandex      | <http://yandex.com/games/app/game\\_i&#x64;**?payload=your-info>\*\* |
| Crazy Games | crazygames.com/game/game\_nam&#x65;**?payload=your-info**            |
| Mock        | site.com/game\_nam&#x65;**?payload=your-info**                       |

#### Domain Information <a href="#domain-information" id="domain-information"></a>

Retrieve the top-level domain of the platform to handle domain-specific configurations and behavior.

```gdscript
Bridge.platform.tld
```

Returns the top-level domain (TLD) of the platform. If there is no data – `null`. If the data is available – `com`, `ru`, etc.

#### Is Get All Games Supported

Verify whether the platform supports the `getAllGames` method to retrieve the correct links to the developer's other games.

```javascript
Bridge.platform.is_get_all_games_supported
```

#### Is Get Game By Id Supported

Verify whether the platform supports the`getGameById` method to retrieve the correct link to a specific game.

```javascript
Bridge.platform.is_get_game_by_id_supported
```

#### Get All Games

This method retrieves the correct links to the developer's other games.

{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
func _ready():
    Bridge.platform.get_all_games(funcref(self, "_on_get_all_games_completed"))

func _on_get_all_games_completed(success, games):
     print(success)

     match Bridge.platform.id:
         "yandex":
             for game in games:
                 print("App ID: " + str(game.appID))
                 print("Title: " + str(game.title))
                 print("URL: " + str(game.url))
                 print("Cover URL: " + str(game.coverURL))
                 print("Icon URL: " + str(game.iconURL))
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
func _ready():
    Bridge.platform.get_all_games(Callable(self, "_on_get_all_games_completed"))

func _on_get_all_games_completed(success, games):
     print(success)

     match Bridge.platform.id:
         "yandex":
             for game in games:
                 print("App ID: " + str(game.appID))
                 print("Title: " + str(game.title))
                 print("URL: " + str(game.url))
                 print("Cover URL: " + str(game.coverURL))
                 print("Icon URL: " + str(game.iconURL))
```

{% endtab %}
{% endtabs %}

#### Get Game By Id

This method retrieves the correct link to a specific game from the developer.

{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
func _ready():
    var options

    options = {
        "gameId": "111111"
    }

    Bridge.platform.get_game_by_id(options, funcref(self, "_on_get_game_by_id_completed"))

func _on_get_game_by_id_completed(success, game):
    print(success)

    match Bridge.platform.id:
        "yandex":
            print("App ID: " + str(game.appID))
            print("Title: " + str(game.title))
            print("URL: " + str(game.url))
            print("Cover URL: " + str(game.coverURL))
            print("Icon URL: " + str(game.iconURL))
            print("Is Available: " + str(game.isAvailable))
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
func _ready():
    var options

    options = {
        "gameId": "111111"
    }

    Bridge.platform.get_game_by_id(options, funcref(self, "_on_get_game_by_id_completed"))

func _on_get_game_by_id_completed(success, game):
    print(success)

    match Bridge.platform.id:
        "yandex":
            print("App ID: " + str(game.appID))
            print("Title: " + str(game.title))
            print("URL: " + str(game.url))
            print("Cover URL: " + str(game.coverURL))
            print("Icon URL: " + str(game.iconURL))
            print("Is Available: " + str(game.isAvailable))
```

{% endtab %}
{% endtabs %}

#### <img src="https://1088849411-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5ukgSPDBOdbQp4FYtbz1%2Fuploads%2F9BooaofCI33U9Np5oeif%2FFrame%203%20(1).png?alt=media&#x26;token=0750b56a-a069-4759-bda9-29951f06cd30" alt="" data-size="line"> Sending a Message to the Platform <a href="#sending-a-message-to-the-platform" id="sending-a-message-to-the-platform"></a>

{% hint style="danger" %}
The call to <mark style="color:purple;">send\_message</mark> with the parameter <mark style="color:orange;">game\_ready</mark> is mandatory!

Don't forget to implement it. Send this message only when the game is fully loaded.
{% endhint %}

Send predefined messages to the platform to trigger specific actions or events, such as signaling that the game is ready.

```gdscript
Bridge.platform.send_message("game_ready")
```

To use constants for convenience:

```gdscript
Bridge.platform.send_message(Bridge.PlatformMessage.GAME_READY)
```

| Message                    | Parameters                                     | Description                                                                                    |
| -------------------------- | ---------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| game\_ready                | No parameters                                  | The game has loaded, all loading screens have passed, the player can interact with the game.   |
| in\_game\_loading\_started | No parameters                                  | Any loading within the game has started. For example, when a level is loading.                 |
| in\_game\_loading\_stopped | No parameters                                  | In-game loading has finished.                                                                  |
| player\_got\_achievement   | No parameters                                  | The player reached a significant moment. For example, defeating a boss, setting a record, etc. |
| level\_started             | <p>Optional. "world" <br>Optional. "level"</p> | Gameplay has started. For example, the player has entered a level from the main menu.          |
| level\_completed           | <p>Optional. "world" <br>Optional. "level"</p> | Gameplay has completed. For example, the player won level.                                     |
| level\_failed              | <p>Optional. "world" <br>Optional. "level"</p> | Gameplay has failed. For example, the player lost level.                                       |
| level\_paused              | <p>Optional. "world" <br>Optional. "level"</p> | Gameplay has paused. Opened settings menu or used pause button                                 |
| level\_resumed             | <p>Optional. "world" <br>Optional. "level"</p> | Gameplay has resumed. Returned from settings menu or hit unpause button                        |

#### Is Audio Enabled

Check if the audio is turned on on the platform.

```gdscript
Bridge.platform.is_audio_enabled
```

{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
# Listen for state changes
func _ready():
    Bridge.platform.connect("audio_state_changed", self, "_on_audio_state_changed")

func _on_audio_state_changed(is_enabled):
    print(is_enabled)
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
# Listen for state changes
func _ready():
    Bridge.platform.connect("audio_state_changed", Callable(self, "_on_audio_state_changed"))

func _on_audio_state_changed(is_enabled):
    print(is_enabled)
```

{% endtab %}
{% endtabs %}

#### Pause

{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
# Listen for state changes
func _ready():
    Bridge.platform.connect("pause_state_changed", self, "_on_pause_state_changed")

func _on_pause_state_changed(is_paused):
    print(is_paused)
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
# Listen for state changes
func _ready():
    Bridge.platform.connect("pause_state_changed", Callable(self, "_on_pause_state_changed"))

func _on_pause_state_changed(is_paused):
    print(is_paused)
```

{% endtab %}
{% endtabs %}

#### Server Time <a href="#server-time" id="server-time"></a>

{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
func _ready():
    Bridge.platform.get_server_time(funcref(self, "_on_get_server_time_completed"))
	
func _on_get_server_time_completed(result):
    print(result) # UTC time in milliseconds
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
func _ready():
    Bridge.platform.get_server_time(Callable(self, "_on_get_server_time_completed"))

func _on_get_server_time_completed(result):
    print(result) # UTC time in milliseconds
```

{% endtab %}
{% endtabs %}

#### Current Visibility State <a href="#current-visibility-state" id="current-visibility-state"></a>

Check if the game tab is visible or hidden, and adjust game behavior accordingly, such as muting sound when hidden.

```gdscript
Bridge.game.visibility_state
```

Returns the current visibility st

ate of the game (the tab with the game). Possible values: `visible`, `hidden`.

{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
# To track visibility state changes, connect to the signal
func _ready():
    Bridge.game.connect("visibility_state_changed", self, "_on_visibility_state_changed")

func _on_visibility_state_changed(state):
    print(state)
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
# To track visibility state changes, connect to the signal
func _ready():
    Bridge.game.connect("visibility_state_changed", Callable(self, "_on_visibility_state_changed"))

func _on_visibility_state_changed(state):
    print(state)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
React to changes in visibility state. For example, mute the game sound when the state is `hidden` and unmute when the state is `visible`.
{% endhint %}
