> ## 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 TStudio Store 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, add hooks for custom systems, and extend the script without touching escrow.

## opensource/client/client.lua

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

### Minigame Function

Each robbery step calls `Minigame(Step)` through the `projectx-storerobbery-tstudio:client:Minigames` callback. You can swap any minigame by replacing the export call inside the matching `elseif` block.

```lua theme={null}
function Minigame(Step)
    local p = promise.new()
    -- TStudio stores
    if Step == "Gate" then
        if not exports['projectx-bridge']:MinigameCheck("bl_ui") then p:resolve(false) return Citizen.Await(p) end
        local success = exports["bl_ui"]:CircleProgress(3, 50)
        p:resolve(success)
    elseif Step == "LaptopLogin" then
        if not exports['projectx-bridge']:MinigameCheck("SN-Hacking") then p:resolve(false) return Citizen.Await(p) end
        local success = exports['SN-Hacking']:MemoryCards('medium')
        p:resolve(success)
    elseif Step == "ComputerLogin" then
        if not exports['projectx-bridge']:MinigameCheck("SN-Hacking") then p:resolve(false) return Citizen.Await(p) end
        local success = exports['SN-Hacking']:MemoryCards('hard')
        p:resolve(success)
    elseif Step == "SafeHack" then
        if not exports['projectx-bridge']:MinigameCheck("SN-Hacking") then p:resolve(false) return Citizen.Await(p) end
        local success = exports['SN-Hacking']:Thermite(7, 5, 10000, 2, 2, 3000)
        p:resolve(success)
    elseif Step == "Fusebox" then
        if not exports['projectx-bridge']:MinigameCheck("bl_ui") then p:resolve(false) return Citizen.Await(p) end
        local success = exports["bl_ui"]:NumberSlide(4, 50, 4)
        p:resolve(success)
    elseif Step == "Register" then
        if not exports['projectx-bridge']:MinigameCheck("bl_ui") then p:resolve(false) return Citizen.Await(p) end
        local success = exports["bl_ui"]:CircleShake(1, 50, 2)
        p:resolve(success)
    elseif Step == "Atm" then
        -- ATM hack, settings in Config.Minigames.Atm
        p:resolve(AtmMinigame())
    elseif Step == "Door" then
        if not exports['projectx-bridge']:MinigameCheck("bl_ui") then p:resolve(false) return Citizen.Await(p) end
        local success = exports["bl_ui"]:CircleProgress(3, 50)
        p:resolve(success)
    elseif Step == "Server" then
        if not exports['projectx-bridge']:MinigameCheck("bl_ui") then p:resolve(false) return Citizen.Await(p) end
        local success = exports["bl_ui"]:PathFind(1,  { numberOfNodes = 10, duration = 7500, })
        p:resolve(success)
    elseif Step == "Computer1" then
        if not exports['projectx-bridge']:MinigameCheck("SN-Hacking") then p:resolve(false) return Citizen.Await(p) end
        local success = exports['SN-Hacking']:MemoryCards('hard')
        p:resolve(success)
    elseif Step == "Computer2" then
        if not exports['projectx-bridge']:MinigameCheck("SN-Hacking") then p:resolve(false) return Citizen.Await(p) end
        local success = exports['SN-Hacking']:Thermite(7, 5, 10000, 2, 2, 3000)
        p:resolve(success)
    elseif Step == "Safe" then
        local gameData = {totalNumbers = 20, seconds = 20, timesToChangeNumbers = 4, amountOfGames = 1, incrementByAmount = 5}
        if not exports['projectx-bridge']:MinigameCheck("pure-minigames") then p:resolve(false) return Citizen.Await(p) end
        local success = exports['pure-minigames']:numberCounter(gameData)
        p:resolve(success)
    elseif Step == "GangSafe" then
        if not exports['projectx-bridge']:MinigameCheck("pd-safe") then p:resolve(false) return Citizen.Await(p) end
        local success = exports["pd-safe"]:createSafe({math.random(0,99)})
        p:resolve(success)
    elseif Step == "Shelf" then
        if not exports['projectx-bridge']:MinigameCheck("bl_ui") then p:resolve(false) return Citizen.Await(p) end
        local success = exports["bl_ui"]:CircleProgress(1, 50)
        p:resolve(success)
    else
        p:resolve(false)
    end
    return Citizen.Await(p)
end

lib.callback.register('projectx-storerobbery-tstudio:client:Minigames', function(Step)
    return Minigame(Step)
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.

The default minigames per step are:

| Step | Used in | Minigame Resource | Function |
| - | - | - | - |
| `Fusebox` | TStudio 24/7 (silent start) | `bl_ui` | `NumberSlide` |
| `Gate` | TStudio (stock cage) | `bl_ui` | `CircleProgress` |
| `LaptopLogin` | TStudio (stock room laptop) | `SN-Hacking` | `MemoryCards` (medium) |
| `ComputerLogin` | TStudio (office computer) | `SN-Hacking` | `MemoryCards` (hard) |
| `SafeHack` | TStudio (office computer) | `SN-Hacking` | `Thermite` |
| `Atm` | All stores | Built-in | `AtmMinigame()` (tuned in `Config.Minigames.Atm`) |
| `Register` | Classic | `bl_ui` | `CircleShake` |
| `Door` | Classic | `bl_ui` | `CircleProgress` |
| `Server` | Classic | `bl_ui` | `PathFind` |
| `Computer1` | Classic | `SN-Hacking` | `MemoryCards` |
| `Computer2` | Classic | `SN-Hacking` | `Thermite` |
| `Safe` | Classic | `pure-minigames` | `numberCounter` |
| `GangSafe` | Classic | `pd-safe` | `createSafe` |
| `Shelf` | All stores | `bl_ui` | `CircleProgress` |

> [!NOTE]
>
> The TStudio keypads, laptop screen, office computer screen, electrical box, and sticky note use built-in UIs. Their difficulty is tuned in `Config.Minigames` in `config/config.lua`, not in this file.

***

## 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.

### Hooks

> [accordion] SuccessfulStep(source, location, step)
>
> Called whenever a player successfully completes a robbery step. Use this to award XP, trigger events, or log individual step completions.
>
> ```lua theme={null}
> function SuccessfulStep(source, location, step)
>     if step == "Fusebox" then
>         -- if Config.SkillSystem then exports['projectx-bridge']:AddExperience(source, 'criminal', 10) end
>     elseif step == "Register" then
>         -- if Config.SkillSystem then exports['projectx-bridge']:AddExperience(source, 'criminal', 10) end
>     end
> end
> ```
>
> Step names match the interaction keys defined in `Config.Stores` (e.g. `Fusebox`, `Clerk`, `Keypad1`, `Gate`, `Laptop`, `Computer`, `Safe`).

> [accordion] FailedStep(source, location, step)
>
> Called whenever a player fails a robbery step, including being tased at the stock cage gate. Use this to remove XP, items, or apply penalties.
>
> ```lua theme={null}
> function FailedStep(source, location, step)
>     if step == "Fusebox" then
>         -- RemoveItem(source, 'x_circuittester', 1)
>     elseif step == "Register" then
>         -- Apply custom penalty
>     end
> end
> ```

> [accordion] InitialCheck(src, Location, Interaction)
>
> Called before a player can start a robbery at a location. Return `false` to block them.
>
> ```lua theme={null}
> function InitialCheck(src, Location, Interaction)
>     return true
>     -- Add a group check, tablet requirement, or any other gate here
> end
> ```

> [accordion] RobberyResetHook(location)
>
> Called whenever a store location resets. Use this to update a scoreboard, trigger an external event, or notify players.
>
> ```lua theme={null}
> function RobberyResetHook(location)
>     -- TriggerEvent('my-scoreboard:update', location)
> end
> ```


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