> ## 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 Default 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 callback. If you want to change the minigames used for each step, this is the only file you need to edit.

### Minigame Callback

Each robbery step triggers the `projectx-storerobbery-default:client:Minigames` callback with the step name. You can swap any minigame by replacing the export call inside the matching `elseif` block.

```lua theme={null}
lib.callback.register('projectx-storerobbery-default:client:Minigames', function(Step)
    local p = promise.new()
    if 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
        if not exports['projectx-bridge']:MinigameCheck("bl_ui") then p:resolve(false) return Citizen.Await(p) end
        local success = exports["bl_ui"]:Progress(4, 50)
        p:resolve(success)
    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 == "Npc" then
        if not exports['projectx-bridge']:MinigameCheck("bl_ui") then p:resolve(false) return Citizen.Await(p) end
        local success = exports["bl_ui"]:KeySpam(1, 50)
        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)
    end
    return Citizen.Await(p)
end)
```

<Info>
  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.
</Info>

The default minigames per step are:

| Step        | Minigame Resource | Function         |
| ----------- | ----------------- | ---------------- |
| `Fusebox`   | `bl_ui`           | `NumberSlide`    |
| `Register`  | `bl_ui`           | `CircleShake`    |
| `Atm`       | `bl_ui`           | `Progress`       |
| `Door`      | `bl_ui`           | `CircleProgress` |
| `Server`    | `bl_ui`           | `PathFind`       |
| `Npc`       | `bl_ui`           | `KeySpam`        |
| `Computer1` | `SN-Hacking`      | `MemoryCards`    |
| `Computer2` | `SN-Hacking`      | `Thermite`       |
| `Safe`      | `pure-minigames`  | `numberCounter`  |
| `GangSafe`  | `pd-safe`         | `createSafe`     |
| `Shelf`     | `bl_ui`           | `CircleProgress` |

***

## opensource/server/server.lua

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

### Hooks

<AccordionGroup>
  <Accordion title="SuccessfulStep(source, location, step)" icon="circle-check">
    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
            -- exports['projectx-bridge']:AddExperience(source, 'criminal', 10)
        elseif step == "Register" then
            -- exports['projectx-bridge']:AddExperience(source, 'criminal', 10)
        end
    end
    ```

    Step names match the minigame callback steps and interaction keys defined in `Config.Stores`.
  </Accordion>

  <Accordion title="FailedStep(source, location, step)" icon="circle-xmark">
    Called whenever a player fails a robbery step. 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>

  <Accordion title="InitialCheck(src, Location, Interaction)" icon="shield-check">
    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>

  <Accordion title="RobberyResetHook(location)" icon="rotate">
    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
    ```
  </Accordion>
</AccordionGroup>
