# Script Integrations

If you want to use your own scripts, the important files are easy to find:

* Inventory: `modules/inventory/server.lua`
* Target: `modules/target/client.lua`
* Notify, progressbar, skillbar, HUD, dispatch, fuel, and vehicle keys: `modules/utils/client.lua`
* Server-side helper functions: `modules/utils/server.lua`
* Job start/stop hooks: `modules/exports/client.lua` and `modules/exports/server.lua`

## Inventory Integration

File: `modules/inventory/server.lua`

This file contains 4 main functions:

* `giveItem`
* `removeItem`
* `hasItem`
* `getItemCountByName`

If you use a custom inventory, replace the logic inside these functions with your own export or event calls.

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`

The script already includes support for `ox_target` and `qb-target`. If you use another target system, replace the fallback `else` sections with your own target exports.

Main functions:

* `addBoxZone`
* `removeZone`
* `addLocalEntity`
* `removeLocalEntity`
* `addBone`
* `removeBone`

## Notify, Progressbar, Skillbar, HUD, Dispatch, Keys, Fuel

File: `modules/utils/client.lua`

This is the main file for custom client-side integrations. The functions most servers edit are:

* `Utils.notify`
* `Utils.toggleHud`
* `Utils.triggerPoliceAlert`
* `Utils.giveVehicleKey`
* `Utils.setFuel`
* `Utils.progressBar`
* `Utils.skillCheck`

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,
        coords = GetEntityCoords(cache.ped)
    })
end
```

## Server-Side Helper Functions

File: `modules/utils/server.lua`

Important functions in this file:

* `Utils.getPoliceCount`
* `Utils.server_notify`
* `Utils.spawnVehicle`

If your server handles police checks or notifications differently, this is where you should adapt the logic.

## Job Hooks and Custom Logic

Files:

* `modules/exports/client.lua`
* `modules/exports/server.lua`

These hooks let you add extra logic without changing the whole job flow:

* `beforeJobStart`
* `onJobStarted`
* `onJobStopped`

Common use cases:

* Extra checks before a job starts
* Sending logs to Discord
* Triggering your own dispatch or analytics
* Giving extra rewards after a job ends

Example:

```lua
function server.exports.beforeJobStart(lobby, job)
    if job.name == 'car_theft' and Utils.getPoliceCount() < 2 then
        return false
    end

    return true
end
```

## Safest Way To Integrate

Use this order:

1. Read the existing function and keep the same input/output logic.
2. Replace only the integration part with your own export or event.
3. Do not change boolean return values unless you know why.
4. Test one job at a time in-game.

{% hint style="success" %}
If your server already uses `ox_target`, `qb-target`, and `ox_lib`, most of the work is already done. Custom integrations are usually needed for inventory, dispatch, notify, progressbar, keys, fuel, and HUD.
{% endhint %}
