> For the complete documentation index, see [llms.txt](https://k0ssek-scripts.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://k0ssek-scripts.gitbook.io/docs/scripts/dart-game/frameworks-and-targets.md).

# Frameworks & Targets

What each framework and target option does, and how to adapt the bridge.

## Frameworks

The framework is detected on start from the resources that are running. There is nothing to set.

| Framework  | Used when                    | Player name                   | Identifier           | Admin check                                | Notifications             |
| ---------- | ---------------------------- | ----------------------------- | -------------------- | ------------------------------------------ | ------------------------- |
| ESX        | `es_extended` is started     | Character name                | ESX identifier       | Group listed in `ConfigServer.AdminGroups` | `ESX.ShowNotification`    |
| QBCore     | `qb-core` is started         | Character first and last name | `citizenid`          | Ace from `ConfigServer.AdminAce`           | `QBCore.Functions.Notify` |
| QBX        | `qbx_core` is started        | Character first and last name | `citizenid`          | Ace from `ConfigServer.AdminAce`           | `exports.qbx_core:Notify` |
| Standalone | none of the above is started | FiveM player name             | `license` identifier | Ace from `ConfigServer.AdminAce`           | `lib.notify`              |

The identifier is the key of the player's row in `darts_stats`.

{% hint style="warning" %}
Start your framework before `kossek_darts`. If it starts later, the script runs in standalone mode.
{% endhint %}

## Targets

The target system is chosen with a convar in `server.cfg`:

```cfg
setr kossek_darts:target "ox_target"
```

| Value                 | Needs                                                      | How players interact                                                                        |
| --------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `ox_target` (default) | [ox\_target](https://github.com/overextended/ox_target)    | Target the board and choose **Join darts game** or **Leave darts game**.                    |
| `qb_target`           | [qb-target](https://github.com/qbcore-framework/qb-target) | Same options, through qb-target.                                                            |
| `helptext`            | nothing                                                    | A text prompt appears within `Config.LobbyRadius` of a board. Press **E** to join or leave. |

### The helptext prompt

Near a board the player sees the join prompt with the number of players already in the lobby:

```
[E] Join the game
Players: 2
```

Once they are in the lobby, the prompt changes to `[E] Leave the game`. The player count works on placed boards and on world props. Both texts are in the language files (`join` and `leave`), see [Localization](/docs/scripts/dart-game/localization.md).

### Config.AutoTargetModels

Applies to `ox_target` and `qb_target`.

* `true` (default): the join and leave options are added once to every prop model in `Config.BoardModels`. Every prop of those models on the map gets the options.
* `false`: the options are added to a board's own prop when a player comes within `Config.LobbyRadius` of it, and removed when they walk away. This works for boards placed with `/darts_create` and for auto-detected world props.

## Adapting the bridge

The files in `bridge/` are not encrypted.

```
bridge/
  init.lua
  framework/
    esx/        client.lua, server.lua
    qbcore/     client.lua, server.lua
    qbx/        client.lua, server.lua
    standalone/ client.lua, server.lua
  target/
    ox_target.lua
    qb_target.lua
    helptext.lua
```

To change how an existing framework is used (for example to send notifications through your own resource), edit the files of that framework.

To support a framework that is not listed, edit `bridge/framework/standalone/`. Those two files are used whenever ESX, QBCore and QBX are not running.

### Server functions

| Function                                     | Returns   | Description                                                                                                      |
| -------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------- |
| `Bridge.Framework.GetPlayerName(source)`     | `string`  | Name shown in the lobby and on the scoreboard.                                                                   |
| `Bridge.Framework.GetIdentifier(source)`     | `string`  | Unique id of the player, used as the key in `darts_stats`. Return an empty string when the player is not loaded. |
| `Bridge.Framework.IsAdmin(source)`           | `boolean` | Whether the player can use the board commands.                                                                   |
| `Bridge.Framework.OnPlayerDropped(callback)` | -         | Calls `callback(source)` when a player leaves the server.                                                        |

### Client functions

| Function                                           | Returns | Description                                                                   |
| -------------------------------------------------- | ------- | ----------------------------------------------------------------------------- |
| `Bridge.Framework.WaitForPlayerLoaded()`           | -       | Waits until the player's character is loaded.                                 |
| `Bridge.Framework.OnPlayerLoaded(callback)`        | -       | Calls `callback` once the player's character is loaded.                       |
| `Bridge.Framework.Notify(notifyType, description)` | -       | Shows a notification. `notifyType` is `success`, `error`, `info` or `inform`. |
