# Functions/Events

### client/bridge.lua

The **Bridge System** is a universal compatibility layer designed to automatically detect and integrate with f**rameworks, target systems, notification systems...**

***

#### Auto Detection Logic

| Config Value         | Behavior                        |
| -------------------- | ------------------------------- |
| `framework = 'auto'` | Detects qb-core or es\_extended |
| `target = 'auto'`    | Detects qb-target or ox\_target |
| `notify = 'auto'`    | Uses tablet/NUI                 |

***

## Notifications

### `Bridge.Notify(text, type, duration, title)`

Unified notification system.

```lua
Bridge.Notify("Vehicle locked", "success", 5000)
```

#### Supported Systems

* **QB-Core** → `QBCore.Functions.Notify`
* **ESX** → `ESX.ShowNotification`
* **okokNotify**
* **Fallback** → NUI message

:information\_source: You can add your custom notification logic&#x20;

***

## Inventory Check

### `Bridge.HasItem(itemName, amount, callback)`

Checks if player has an item.

```lua
Bridge.HasItem("medkit", 1, function(hasItem)
    if hasItem then
        print("Player has medkit")
    end
end)
```

***

## Vehicle Keys

### `Bridge.getKey(vehicle)`

Gives player vehicle key.

QB:

```lua
TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)
```

***

### `Bridge.removeKey(vehicle)`

Removes key from player.

ESX:

```lua
exports.wasabi_carlock:RemoveKey(plate)
```

:information\_source: You can add your vehicle keys script logic if not supported by default.

***

## Target System

The Bridge supports:

* `qb-target`
* `ox_target`
* Standalone fallback system

***

### Add Target

#### `Bridge.AddTargetEntity(entity, options)`

Adds interaction to an entity.

```lua
Bridge.AddTargetEntity(entity, {
    options = {
        {
            label = "Rescue Ped",
            event = "fire:rescue",
            type = "client"
        }
    }
})
```

#### What Happens Internally

* Detects networked entity
* Tracks NetID
* Starts entity watcher
* Auto re-adds target when entity returns in range

***

### Remove Target

#### `Bridge.RemoveTargetEntity(entity, perma)`

```lua
Bridge.RemoveTargetEntity(entity, true)
```

If `perma = true`:

* Stops entity watcher
* Removes from tracked list

***

### Remove All Networked Targets

```lua
Bridge.RemoveAllNetworkedTargets()
```

Removes:

* All tracked entities
* All watchers
* All target interactions

***

## Progress Bar

### `Bridge.Progressbar(options)`

Unified progress system.

```lua
Bridge.Progressbar({
    name = "revive",
    label = "Reviving...",
    duration = 5000,
    animDict = "mini@cpr@char_a@cpr_str",
    animName = "cpr_pumpchest",
    disableMovement = true,
    cb = function()
        print("Finished")
    end
})
```

***

## Job Check

### `Bridge.HasJob(jobName, grade)`

```lua
if Bridge.HasJob("police", 2) then
    print("Player is police grade 2+")
end
```

#### Behavior

QB:

* Uses `PlayerData.job.name`
* Grade = `job.grade.level`

ESX:

* Uses `ESX.GetPlayerData().job`
* Grade = `job.grade`

Standalone:

* Always returns `true`

***

### server/bridge.lua

#### Add Item

#### `Bridge.AddItem(source, item, amount)`

```lua
Bridge.AddItem(source, "medkit", 1)
```

#### Supported Systems

* **QB Inventory**
* **OX Inventory**
* **ESX Inventory**

If none are detected, you can add your own logic.

***

#### Remove Item

#### `Bridge.RemoveItem(source, item, amount)`

```lua
Bridge.RemoveItem(source, "bandage", 2)
```

Works the same way as `AddItem`, automatically routing to the correct inventory.

***

#### Has Item

#### `Bridge.HasItem(source, item, amount, cb)`

```lua
Bridge.HasItem(source, "radio", 1, function(hasItem)
    if hasItem then
        print("Player has radio")
    end
end)
```

***

#### Inventory Callback (Framework)

The Bridge automatically registers a shared callback:

QB

```lua
bridge:checkItem
```

ESX

```lua
bridge:checkItem
```

Used by client-side scripts for item validation.

***

Money Functions

#### Add Money

#### `Bridge.AddMoney(source, moneyType, amount)`

```lua
Bridge.AddMoney(source, "cash", 500)
```

#### Default Support

* QB → `AddMoney`
* ESX → `addMoney`

***

#### Remove Money

#### `Bridge.RemoveMoney(source, moneyType, amount)`

```lua
Bridge.RemoveMoney(source, "bank", 250)
```

If using a custom banking system, add your logic inside the fallback block.

***

## Usable Items

### `Bridge.CreateUsableItem(item, cb)`

```lua
Bridge.CreateUsableItem("firetablet", function(source, item)
    TriggerClientEvent("firetablet:use", source)
end)
```

#### Supported Systems

| Inventory | Method              |
| --------- | ------------------- |
| QB        | `CreateUseableItem` |
| OX        | `useItem export`    |
| QS        | `CreateUsableItem`  |

You can replace or extend this logic freely.

***

### Custom Integrations (Important)

The Bridge **does not lock you** into any inventory, money, or framework system.

You are expected to add your own logic if your server uses something else.

***

### Functions You Can Customize

| Feature              | Function                                |
| -------------------- | --------------------------------------- |
| Inventory add/remove | `Bridge.AddItem`, `Bridge.RemoveItem`   |
| Inventory check      | `Bridge.HasItem`                        |
| Money                | `Bridge.AddMoney`, `Bridge.RemoveMoney` |
| Player data          | `Bridge.GetPlayerData`                  |
| Usable items         | `Bridge.CreateUsableItem`               |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://enyo-scripts.gitbook.io/documentations/fivem-scripts/firefighter-multiplayer-job-simulator/functions-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
