# Wagon Chop

***

### 1. Overview

Codex Wagon Chop (wagon boosting / wagon chop) adds an immersive “steal and chop” job loop to your **RedM** server. It runs on [CodexCore](https://codexstudios.gitbook.io/codexstudios-store/codex-docs/redm-resources/codexcore) and uses [Trust Level System](https://codexstudios.gitbook.io/codexstudios-store/codex-docs/redm-resources/publish-your-docs) progression to unlock better boosting contracts.

Use this resource if you want:

* A contract-based **wagon boosting** system with a “chop shop” delivery finale
* Trust-gated wagon tiers (starter wagons → high-value wagons)
* A config-only setup for most servers (no code edits)

Core loop:

* Players use a special **mission letter item** to start a boosting contract.
* A parchment-style UI asks if they want to accept the mission.
* On acceptance:
  * A fee is charged.
  * A bird delivers a physical contract object.
  * The player receives the mission letter.
* The player:
  * Steals a wagon from a random spawn location.
  * Delivers it to a random chop yard.
  * Chops wagon parts using a keypress minigame and progress bar.
* On success:
  * Players receive item rewards.
  * Gain trust in the **boost** category.
  * Unlock better wagons and raids at higher trust levels.

All gameplay is driven through `config.lua`. This makes it easy to run on VORP, RSGCore, or TPZCore servers via CodexCore.

***

### 2. Requirements & Dependencies

#### Game

* **RedM** (game `rdr3`)

#### Supported Frameworks

Supported through CodexCore:

* **VORP**
* **RSGCore**
* **TPZCore**

#### Required Resources

* `codex_core` – Core framework (money, inventory, callbacks, UI)
* `ox_lib` – Progress bars (if enabled)
* `codex_trustlevel` – Trust system (reads `boost` trust)
* Notification system:
  * Client event: `codex-notification`
  * Server event: `codex-notification:server`
* Minigame:
  * `legends-keypress`

#### Optional / Fallback

* `progressBars` – Used if Ox Lib progress bars are disabled

Ensure all dependencies start **before** this resource.

***

### 3. Installation

#### 3.1 Add Resource

1. Place the resource folder into your `resources` directory.
2. Verify UI files exist:
   * `html/index.html`
   * `html/script.js`
   * `html/styles.css`
   * `html/img/*.png`

#### 3.2 Start Order

Add to `server.cfg`:

```cfg
ensure codex_core
ensure ox_lib
ensure codex_trustlevel
ensure legends-keypress
ensure codex_boosting
```

#### 3.3 Database

The script references `mysql-async`. Install and start a supported MySQL driver used by your Codex ecosystem (commonly `mysql-async`, `oxmysql`, or `ghmattimysql`).

***

### 4. Gameplay Flow

#### 4.1 Starting a Mission

* Player uses the configured item:

```lua
ItemForMessage = "boosting_latter"
```

* Inventory closes and the parchment UI opens.

#### 4.2 Accepting the Mission

On accept:

* Script checks player money (`MoneyNeeded`).
* If successful:
  * Money is removed.
  * Notification is sent.
  * A bird spawns to deliver the contract.

If insufficient funds, the mission is cancelled.

***

#### 4.3 Bird Delivery

* A bird (`BirdModel`) flies to the player.
* Drops an object (`ObjectModel`).
* Player picks it up via a progress bar.
* Receives the mission letter item.

***

#### 4.4 Wagon Theft

* A random spawn is chosen from `ChopLocations`.
* A blip guides the player.
* Wagon model is selected based on **trust level**.

***

#### 4.5 Delivery & Chopping

At the chop location:

* Player drops off the wagon.
* Each wheel/part:
  * Prompt appears
  * Keypress minigame runs
  * Progress bar plays
  * Part is removed visually

Raiders may spawn depending on trust settings.

***

#### 4.6 Rewards & Trust

On full completion:

* Items are granted from `GivenItems`.
* Trust increases in category `boost`.
* Wagon and NPCs are cleaned up.

Aborted or failed missions grant **no rewards**.

***

### 5. Configuration Reference (`config.lua`)

#### 5.1 Controls

```lua
Codex.Keys = {
  ["A"] = 0x7065027D,
  ["RIGHT"] = 0xDEB34313,
}
```

Key name → RedM control hash mapping.\
Usually no changes needed.

***

#### 5.2 Developer & Interaction

```lua
DeveloperMode = false
DistanceForInteraction = 3.0
UseCodexTextUI = true
UseOxLibProgressBar = true
```

| Option                 | Description                         |
| ---------------------- | ----------------------------------- |
| DeveloperMode          | Enables debug output                |
| DistanceForInteraction | Interaction range                   |
| UseCodexTextUI         | Use Codex TextUI instead of prompts |
| UseOxLibProgressBar    | Use Ox Lib progress bars            |

***

#### 5.3 UI & Minigame Settings

```lua
UiMessage = "Are you sure you wanna start this mission?"
progressBarDuration = 5000
MiniGameTotalTime = math.random(7,10)
MiniGameKeyNeededSuccess = math.random(3,4)
```

Controls UI message text, progress bar timing, and minigame difficulty.

***

#### 5.4 Raiders & Combat

```lua
NumberOfRaidersToBeSpawned = 3
RaidersWeapon = "WEAPON_SNIPERRIFLE_CARCANO"
```

Defines raider count, spawn radius, models, and weapons.

***

#### 5.5 Mission Vendors

```lua
NpcsLocations = {
  {
    name = "Mateo Romualdo",
    npcmodel = "u_m_m_bht_outlawmauled",
    coords = {x=-2774.7,y=-3214.89,z=-9.36,h=197.24},
  },
}
```

Add more NPCs to create multiple mission start points.

***

#### 5.6 Wagon & Chop Locations

```lua
ChopLocations = {
  [1] = { Pos = {...}, WagonPos = {...} }
}

LocationChopping = {
  [1] = {x=984.77, y=-1978.44, z=48.05}
}
```

Randomized wagon spawns and chop yards.

***

#### 5.7 Rewards

```lua
GivenItems = {
  ["consumable_herb_dill"] = math.random(5,10)
}
```

Item rewards granted after mission success.

***

#### 5.8 Wagon Trust Progression

```lua
WagonModels = {
  ['StarterTrust'] = { model = "wagon05x", TrustLevelNeeded = 0 },
  ['HighTrust']    = { model = "wagondairy01x", TrustLevelNeeded = 20 },
}
```

Higher trust unlocks better wagons.

***

#### 5.9 Trust & Mission Items

```lua
TrustGiven = "boost"
GainTrust = 1
ItemForMessage = "boosting_latter"
```

Controls trust category and mission start item.

***

#### 5.10 Money

```lua
MoneyAccount = 0
MoneyNeeded = 1000
```

Defines payment account and mission fee.

***

#### 5.11 NPC Working Hours

```lua
NpcsBasedOnHours = true
NpcHours = { StartHour = 0, CloseHour = 7 }
```

Limits mission availability by in-game time.

***

### 6. UI (NUI)

The parchment UI shows:

* Custom mission text
* Accept / Abort buttons
* Close button

You can customize:

* Text via `UiMessage`
* Visuals via `html/style.css` and `html/img/*.png`

***

### 7. What You Can Safely Change

You may freely edit:

* All values in `config.lua`
* NPC, wagon, and chop coordinates
* Trust thresholds and rewards
* UI text strings
* Raider models and weapons

⚠️ You should **not** edit escrowed logic files.

***

### 8. Tips & Best Practices

* Use trust progression to unlock harder wagons.
* Balance `MoneyNeeded` vs. rewards to avoid farming abuse.
* Enable raiders only at higher trust for difficulty scaling.
* Test with `DeveloperMode = true` before production.

***

End of Codex Wagon Chop Documentation.
