# MX-Robbery
Preview: https://youtu.be/UK9D63V56lY
Discord: https://discord.gg/fNNf4Rqv9V
Store and NPC robbery system for RedM with **RSG** and **VORP** support.
## Features
-
**Store & bank robbery**: Lockpick + minigame (t3_lockpick) + progress bar
-
**NPC robbery**: Aim weapon at NPC → hands up → reward
-
**Police alert** at the start of the robbery
-
**Cooldown** per location and per player (NPC)
-
**Minimum police** on duty required to allow robbery
-
**Block** for police and medics (RSG)
-
**Auto framework detection**: RSG or VORP
## Dependencies
| Framework | Required resources |
|-----------|-------------------|
| **RSG** | rsg-core, rsg-inventory, rsg-lawman |
| **VORP** | vorp_core, vorp_inventory |
| **Common**| ox_lib, t3_lockpick |
## Installation
1. Place `MX-robbery` in `resources/[framework]/`
2. Add to `server.cfg`:
```
ensure MX-robbery
```
3. Configure `config.lua` and `server/police_bridge.lua`
## Configuration
### config.lua
| Option | Description |
|--------|-------------|
| `Config.Framework` | `'auto'`, `'rsg'` or `'vorp'` |
| `Config.LockpickItem` | Required item (e.g. `lockpick`) |
| `Config.RewardItem` | Reward item (e.g. `blood_dollar`) |
| `Config.RewardMin` / `Config.RewardMax` | Random reward amount |
| `Config.RobberyDuration` | Robbery duration in ms |
| `Config.CooldownSeconds` | Cooldown per location (seconds) |
| `Config.MinPolice` | Minimum police on duty |
| `Config.Locations` | List of locations (id, name, coords, alertText, minPolice) |
| `Config.NPCRobbery` | NPC robbery (enabled, maxDistance, aimDuration, rewardMin/Max, cooldownSeconds) |
### server/police_bridge.lua
Configure police triggers:
-
**AlertPolice(alertText, coords)** – triggers the alert
-
**GetPoliceCount()** – returns number of police on duty
Default: `rsg-lawman:server:lawmanAlert` and count by `job.type == 'leo'` + `onduty`.
## Translations
Edit `locales/en.json` or `locales/pt-br.json` to change notification messages and the robbery button text. Add new locale files (e.g. `locales/es.json`) for other languages. The language is set by `set ox:locale en` (or `pt-br`, etc.) in `server.cfg`.
| Key | Description |
|-----|-------------|
| `title_robbery` | Notification title (stores/banks) |
| `title_assault` | Notification title (NPC) |
| `btn_rob` | Button text `[E] Rob - {name}` |
| `msg_restricted_job` | Police/medic block message |
| `msg_police` | Not enough police |
| `msg_cooldown` | Cooldown message `{seconds}` |
| `msg_need_lockpick` | Missing lockpick |
| `msg_lockpick_failed` | Lockpick failed |
| `msg_progress` | Progress bar label |
| `msg_success` | Robbery completed |
| `msg_cancelled` | Robbery cancelled |
| `msg_robbed` | Reward message `{amount}` `{item}` |
| `msg_npc_cooldown` | NPC cooldown `{seconds}` |
| `msg_npc_robbed` | NPC reward `{amount}` `{item}` |
## File Structure
```
MX-robbery/
├── config.lua # General configuration
├── locales/
│ ├── en.json # English
│ └── pt-br.json # Portuguese (Brazil)
├── shared/
│ └── framework.lua # RSG/VORP bridge (single file)
├── client/
│ └── client.lua # Client logic (prompts, NPC, minigame)
├── server/
│ ├── police_bridge.lua # Police triggers (edit here)
│ └── server.lua # Callbacks, rewards, cooldowns
└── fxmanifest.lua
```
## Adding New Locations
In `config.lua`, add to `Config.Locations`:
```lua
{
id = 'my_location',
name = 'Location Name',
coords = vector3(x, y, z),
alertText = 'Robbery in progress - Location Name',
minPolice = 2, -- optional, uses Config.MinPolice if omitted
},
```
## NPC Robbery
1. Aim your weapon at an NPC
2. Keep aiming for `aimDuration` (default: 2.5s)
3. NPC raises hands and gives the reward
4. Cooldown before robbing another NPC
**Restrictions**: Police and medics cannot rob (RSG). Already robbed NPC cannot be robbed again.
## Credits
- **t3_lockpick** – Lockpick minigame by [T3 Development]()
## License
Open source. Edit `shared/framework.lua`, `config.lua` and `server/police_bridge.lua` as needed.