# Script Integrations

If you want to use your own server scripts, the important integration points are the same ones referenced by the original documentation:

* Inventory: `modules/inventory/server.lua`
* Target: `modules/target/client.lua`
* Notify, progressbar, skillbar, and other helper functions: `modules/utils/client.lua`
* Server-side helper functions: `modules/utils/server.lua`

## Inventory Integration

File: `modules/inventory/server.lua`

Use this file if your server does not match the default inventory logic. The core things you usually need are:

* Give item
* Remove item
* Check item
* Count item

If you use a custom inventory, replace the inventory calls in this module with your own exports or events.

Basic example:

```lua
function Inventory.giveItem(source, itemName, count)
    return exports['my_inventory']:AddItem(source, itemName, count)
end
```

## Target Integration

File: `modules/target/client.lua`

If you do not use the target system expected by the script, adapt the target zone and entity interaction calls here.

This usually includes:

* Adding zones
* Removing zones
* Adding entity interactions
* Removing entity interactions

## Notify, Progressbar, Skillbar, Dispatch

File: `modules/utils/client.lua`

Most servers customize this file when they want to connect their own UI systems.

Common changes:

* Replace notify logic
* Replace progressbar logic
* Replace skillcheck logic
* Replace police dispatch alerts
* Replace other helper functions used during heist steps

Notify example:

```lua
function Utils.notify(title, type, duration, description)
    exports['my_notify']:Send({
        title = title,
        description = description,
        type = type,
        duration = duration
    })
end
```

Progressbar example:

```lua
function Utils.progressBar(data)
    return exports['my_progressbar']:Progress(data)
end
```

Dispatch example:

```lua
function Utils.triggerPoliceAlert(alertType)
    exports['my_dispatch']:SendAlert({
        code = alertType
    })
end
```

## Vehicle Key Integration

File: `modules/utils/client.lua`

Spawned scenario vehicles can give or remove keys through these helper functions:

* `Utils.giveVehicleKey(plate, entity)`
* `Utils.removeVehicleKey(plate)`

Purpose of this integration:

* Give the player keys for heist-related vehicles when the script spawns or assigns one
* Remove keys again if your flow requires cleanup
* Adapt the key logic if your server does not use `qb-vehiclekeys`

Default script behavior:

```lua
function Utils.giveVehicleKey(plate, entity)
    TriggerServerEvent("qb-vehiclekeys:server:AcquireVehicleKeys", plate)
end
```

If you use `0r-vehiclekeys`, you can adapt it like this:

```lua
function Utils.giveVehicleKey(plate, entity)
    TriggerServerEvent('0r-vehiclekeys:server:AcquireVehicleKeys', plate)
end

function Utils.removeVehicleKey(plate)
    TriggerServerEvent('0r-vehiclekeys:server:RemoveKeys', plate)
end
```

If your key script uses exports instead of events, replace these lines with your own export calls. Keep the same function names so the rest of the heist flow continues to work without other changes.

## Server-Side Helpers

File: `modules/utils/server.lua`

This is the place to adapt server-side helper behavior if your framework or utility layer is custom.

Common examples:

* Police count checks
* Server-side notifications
* Vehicle or entity spawning helpers

## Safest Way To Integrate

Use this order:

1. Read the existing function and keep the same input/output behavior.
2. Replace only the integration-specific lines with your own export or event.
3. Do not change return types unless you know the script expects it.
4. Test one scenario at a time in game.

{% hint style="success" %}
If your server already uses `ox_lib` and the same common target and inventory systems as the resource expects, you may only need small changes or no changes at all.
{% endhint %}
