> For the complete documentation index, see [llms.txt](https://visionstore.gitbook.io/visionstore-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://visionstore.gitbook.io/visionstore-docs/scripts/weaponhub/developers/framework-bridge.md).

# Framework bridge

The open framework and target bridges, and how to plug in another framework or your armory.

The hub talks to your framework and target system only through the files in `bridge/`. They are open source: change them freely.

| File                          | What                                                           |
| ----------------------------- | -------------------------------------------------------------- |
| `bridge/framework/server.lua` | Money, jobs and gangs, admins, issued equipment, notifications |
| `bridge/target/client.lua`    | Workbench zones: ox\_target, qb-target or an ox\_lib prompt    |

**Inventory:** ox\_inventory is required. The hub stores installed parts, the tint and the camo colour in ox\_inventory's weapon metadata, which is what ox\_inventory reads when the gun is drawn.

## Server functions

| Function                                              | What it does                                                                |
| ----------------------------------------------------- | --------------------------------------------------------------------------- |
| `Bridge.HasGroups(source, groups)`                    | Job / gang check. `groups = { police = 0, mechanic = 2 }` or `{ 'police' }` |
| `Bridge.GetMoney(source, account)`                    | Balance of `'cash'` or `'bank'`                                             |
| `Bridge.RemoveMoney(source, account, amount, reason)` | Take money. Returns `false` if they can't afford it                         |
| `Bridge.AddMoney(source, account, amount, reason)`    | Give money (refunds). Returns a boolean                                     |
| `Bridge.IsAdmin(source)`                              | Admin check for `/weaponhub` and `/weaponhub_here`                          |
| `Bridge.CanModifyIssued(source, metadata)`            | The issued-equipment rule (`Config.IssuedEquipment`)                        |
| `Bridge.Notify(source, text, type)`                   | Show a notification (`'inform'`, `'success'`, `'error'`, `'warning'`)       |
| `Bridge.Framework`                                    | `'qbx'`, `'qb'`, `'esx'`, `'ox'` or `'standalone'`                          |

Every call into another resource is wrapped in `pcall`, so a broken framework export can never break a save.

## What is used per framework

|                         | Jobs / gangs                                                               | Money                                                                 | Admins                                                       |
| ----------------------- | -------------------------------------------------------------------------- | --------------------------------------------------------------------- | ------------------------------------------------------------ |
| **Qbox** (`qbx_core`)   | Every job and gang the character holds (multi-job)                         | `cash`, `bank`                                                        | Ace `admin` / `group.admin` (and your `Config.Admin.groups`) |
| **QBCore** (`qb-core`)  | Job and gang                                                               | `cash`, `bank`                                                        | `QBCore.Functions.HasPermission` with `Config.Admin.groups`  |
| **ESX** (`es_extended`) | Job                                                                        | Accounts `money` (cash) and `bank`                                    | `xPlayer.getGroup()` in `Config.Admin.groups`                |
| **ox\_core**            | Groups                                                                     | Cash = the ox\_inventory `money` item, bank = the character's account | Aces                                                         |
| **Standalone**          | Ace `vision_weaponhub.job.<name>` (grade 0), or ox\_inventory's own groups | The ox\_inventory `money` item for cash and bank                      | Aces                                                         |

Every framework also accepts the ace in `Config.Admin.ace` (`vision_weaponhub.admin`). Every charge carries a reason (`weapon customization WEAPON_...`) for your framework's money logs.

## Notifications

`Bridge.Notify` uses ox\_lib notifications. To use another system, replace its body:

```lua
function Bridge.Notify(src, message, kind)
    TriggerClientEvent('ox_lib:notify', src, {
        title = L('notify_title'),
        description = message,
        type = kind or 'inform',
        icon = 'gun',
    })
end
```

## Issued equipment

The default rule checks `Config.IssuedEquipment.jobs`. To use your armory's own rule, replace `Bridge.CanModifyIssued`:

```lua
function Bridge.CanModifyIssued(src, metadata)
    local rule = Config.IssuedEquipment
    if not rule or not rule.key or type(metadata) ~= 'table' or metadata[rule.key] ~= true then return true end
    return exports.my_armory:CanUseIssued(src, metadata)
end
```

## Another framework

Add a branch to each function in `bridge/framework/server.lua` (`playerGroups`, `Bridge.GetMoney`, `Bridge.RemoveMoney`, `Bridge.AddMoney`, `Bridge.IsAdmin`) and a name to `detect()`:

```lua
local function detect()
    local forced = Config.Framework
    if forced and forced ~= 'auto' then return forced end
    if started('qbx_core') then return 'qbx' end
    if started('qb-core') then return 'qb' end
    if started('es_extended') then return 'esx' end
    if started('ox_core') then return 'ox' end
    return 'standalone'
end
```

Nothing else in the resource has to change.

## Targets

| System     | Zone                                    | Rules shown by the target                 |
| ---------- | --------------------------------------- | ----------------------------------------- |
| ox\_target | Box zone (`coords`, `size`, `rotation`) | `groups = jobs`, `items`                  |
| qb-target  | Box zone                                | `job = jobs`, the first required item     |
| `textui`   | `[E] <label>` prompt within `distance`  | None (the server still checks everything) |

`bridge/target/client.lua` exposes `Target.AddBench(index, location, onSelect)`, `Target.RemoveBench(handle)` and `Target.OnRestart(fn)`. After ox\_target or qb-target restarts, the zones are added again by themselves.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://visionstore.gitbook.io/visionstore-docs/scripts/weaponhub/developers/framework-bridge.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
