> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectx.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Open Source

> Open source files available for customization in the Container Robbery resource

Most of the core logic in this resource is handled by the bridge. The open source files are provided so you can customize minigames, the fixer dialog, add hooks for custom systems, and extend the script without touching escrow.

## opensource/client/client.lua

This file handles zone creation, drawtext, evidence, stress, the fixer dialog, and the minigame callback. If you want to change the minigames used for each step, this is the only file you need to edit.

### Minigame Callback

Each lock and crate triggers the `projectx-containerrobbery:client:Minigames` callback with its `Minigame` step name from the config. You can swap any minigame by replacing the export call inside the matching `elseif` block.

```lua theme={null}
lib.callback.register('projectx-containerrobbery:client:Minigames', function(Step)
    local p = promise.new()
    if Step == "padlock" then
        if not MinigameReady("bl_ui", Step) then p:resolve(false) return Citizen.Await(p) end
        p:resolve(exports["bl_ui"]:PathFind(1, { numberOfNodes = 10, duration = 10000}))
    elseif Step == "reinforced" then
        if not MinigameReady("lightsout", Step) then p:resolve(false) return Citizen.Await(p) end
        p:resolve(exports['lightsout']:StartLightsOut(4, 20))
    elseif Step == "electronic" then
        if not MinigameReady("bl_ui", Step) then p:resolve(false) return Citizen.Await(p) end
        p:resolve(exports["bl_ui"]:WaveMatch(1, {duration = 30000}))
    elseif Step == "guncrate" then
        if not MinigameReady("bl_ui", Step) then p:resolve(false) return Citizen.Await(p) end
        p:resolve(exports["bl_ui"]:CircleProgress(4, 50))
    elseif Step == "woodencrate" then
        if not MinigameReady("bl_ui", Step) then p:resolve(false) return Citizen.Await(p) end
        p:resolve(exports["bl_ui"]:KeySpam(3, 50))
    elseif Step == "explosivecase" then
        if not MinigameReady("bl_ui", Step) then p:resolve(false) return Citizen.Await(p) end
        p:resolve(exports["bl_ui"]:MineSweeper(1, {grid = 6, duration = 10000, target = 8, previewDuration = 2000}))
    elseif Step == "electronicscrate" then
        if not MinigameReady("bl_ui", Step) then p:resolve(false) return Citizen.Await(p) end
        p:resolve(exports["bl_ui"]:DigitDazzle(1, {length = 4, duration = 20000}))
    elseif Step == "cashbox" then
        if not MinigameReady("bl_ui", Step) then p:resolve(false) return Citizen.Await(p) end
        p:resolve(exports["bl_ui"]:RapidLines(2, 50, 5))
    else
        -- No minigame for this step (e.g. a new lock / crate type without a branch above): it passes for free
        print(("^1[WARN] ^3No minigame set up for '%s' in opensource/client/client.lua: the step counts as PASSED^7"):format(tostring(Step)))
        return true
    end
    return Citizen.Await(p)
end)
```

> [!NOTE]
>
> You can return `true` unconditionally inside any step block to skip that minigame entirely. This can be useful for testing or for steps you want to make automatic.

> [!WARNING]
>
> If a minigame's resource isn't started, `MinigameReady` prints a warning and the step counts as **failed**. On the electronic lock, a fail applies `FailGoesLoud` and the device's `BreakChance` on every attempt.

The default minigames per step are:

| Step | Used for | Minigame Resource | Function |
| - | - | - | - |
| `padlock` | Padlock (when `Config.Cutter.Enabled = false`) | `bl_ui` | `PathFind` |
| `reinforced` | Reinforced padlock (when `Config.Cutter.Enabled = false`) | `lightsout` | `StartLightsOut` |
| `electronic` | Electronic lock (when `Config.Cutter.Enabled = false`) | `bl_ui` | `WaveMatch` |
| `guncrate` | Gun crate | `bl_ui` | `CircleProgress` |
| `woodencrate` | Wooden crate | `bl_ui` | `KeySpam` |
| `explosivecase` | Explosives case | `bl_ui` | `MineSweeper` |
| `electronicscrate` | Electronics crate | `bl_ui` | `DigitDazzle` |
| `cashbox` | Cash box | `bl_ui` | `RapidLines` |

> [!NOTE]
>
> With `Config.Cutter.Enabled = true` (the default), locks use the built-in grinder and bypass UIs tuned in `Config.Cutter.Locks` instead of the lock minigames above.

### Fixer Dialog

`ShowDialog(data)` opens the fixer conversation with `projectx-ui` when `Config.Dialog = "projectx"`. `AlertDialog(data)` is used for `Config.Dialog = "ox"`, or as a fallback when `projectx-ui` isn't started. You can replace either function to use your own dialog UI.

***

## opensource/server/server.lua

This file handles dispatch, item/money functions, logging, the admin command, and exposes several hooks you can use to run custom logic at specific points in the robbery.

### Inventory Helpers

> [accordion] HasItemAmount(source, item, amount)
>
> Checks that the player has at least `amount` of an item. Used for the fixer's item price. Supports `ox_inventory` and `qb-inventory` out of the box. Add your inventory here if it isn't listed, otherwise only "has at least one" is checked.

> [accordion] ItemLabel(item)
>
> Returns the item label used in notifications (e.g. "Your X Grinder broke"). Reads from `ox_inventory` if available, otherwise returns the item name.

> [accordion] RewardNotDelivered(source, item, amount)
>
> Called when a reward didn't fit in the player's inventory. Return `true` if you put it somewhere (the player is told it fell on the ground), or `false` to tell them their pockets are full. By default, it's dropped at their feet with `ox_inventory`.

### Hooks

> [accordion] SuccessfulStep(source, step)
>
> Called whenever a player successfully completes a step. `step` is `"Container"` or `"Crate"`.
>
> ```lua theme={null}
> function SuccessfulStep(source, step)
>     if step == "Container" then
>         -- if Config.SkillSystem then exports['projectx-bridge']:AddExperience(source, 'criminal', 10) end
>     elseif step == "Crate" then
>         -- if Config.SkillSystem then exports['projectx-bridge']:AddExperience(source, 'criminal', 5) end
>     end
> end
> ```

> [accordion] FailedStep(source, step)
>
> Called whenever a player fails a step, e.g. `"Padlock"`, `"Reinforced"`, `"Electronic"`, `"Hack"`, `"GunCrate"`. Use this to remove XP, items, or apply penalties.
>
> ```lua theme={null}
> function FailedStep(source, step)
>     -- Add whatever you want on a failed step, for example removing exp or money
> end
> ```

> [accordion] InitialCheck(src, approach)
>
> Called before a robbery starts. `approach` is `"Fixer"` for a fixer contract or `"Detection"` for the loud approach. Return `false` to block it.
>
> ```lua theme={null}
> function InitialCheck(src, approach)
>     return true
> end
> ```

> [accordion] RobberyResetHook()
>
> Called whenever the heist resets.
>
> ```lua theme={null}
> function RobberyResetHook()
>     -- Called when the heist is reset
> end
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.