> For the complete documentation index, see [llms.txt](https://klbstore.gitbook.io/docs-klbstore/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://klbstore.gitbook.io/docs-klbstore/klb-scrapyard.md).

# KLB Scrapyard

## 🚗 KLB Scrapyard

KLB-Scrapyard is a **plug-and-play scrapyard and vehicle contract system** for **QBCore** servers.\
Players can pick up contracts of different difficulties, locate vehicles, strip parts on-site, and deliver them for **cash, XP, and items**.\
Built entirely from scratch — optimized, balanced, and styled the **KLB way**.

***

### 🔍 Overview

KLB-Scrapyard introduces a complete scrapyard job loop to your city.\
Players can:

* Pick up contracts in multiple difficulty levels
* Locate and deliver vehicles
* Strip valuable parts for additional rewards

All systems are configurable, dynamic, and deeply integrated with QBCore for smooth gameplay and performance.

***

### ⚙️ Core Contract & Gameplay Features

* **Three contract types:** Easy, Standard, Heavy\
  Each tier includes distance-based payouts, police risk profiles, and optional tow requirements for heavy missions.
* **Dynamic spawn logic:**\
  Blacklists, mission types, and vehicle pools determine where cars appear, if they require GPS hacking, and which vehicle classes are available per tier.
* **Timed contracts:**\
  Optional rotating job pools with custom reward tables, tool requirements, guard spawns, and supercar probabilities for added variety and limited-time missions.

***

### 🧰 Integrations & Tools

* 🧭 **qb-target support** with automatic 3D text fallback
* 🧩 Supports `ox_inventory`, `ps-inventory`, and `qb-inventory`
* 💾 Optional persistence through **oxmysql**
* ⚒️ Built-in tool logic, hacking system, and towing integration
* 🔧 Mechanic compatibility — reuse collected parts in **KLB-Mechanic**
* 🚨 Dispatch integrations for `ps-dispatch`, `qb-dispatch`, `cd_dispatch`, and `lb-tablet` with automatic legacy fallback
* ⚙️ Full control through `config.lua`

***

### 💰 Progression, Economy & Rewards

* 🏆 **Reputation system** controls access to higher contracts and bonus payouts
* 💵 Economy fully configurable via multipliers and reward tables
* 🚗 Payouts scale dynamically based on:
  * Vehicle condition
  * Distance travelled
  * Contract category
  * Optional long-distance or high-tier bonuses

***

### 🧠 Events & Exports

#### 🔹 Client Events

```
klb_scrapyard:clientStart      -- Contract assigned
klb_scrapyard:clientComplete   -- Delivery finished
klb_scrapyard:clientCancel     -- Contract cancelled
klb_scrapyard:stripResult      -- Strip attempt result
```

#### 🔹 Server Events

```
klb_scrapyard:requestContract
klb_scrapyard:cancelContract
klb_scrapyard:deliver
klb_scrapyard:stripStep
```

#### 🔹 Exports

```lua
exports['klb_scrapyard']:SellAllScrap(source)
```

Removes all scrap items listed in the config and pays based on item value.

***

### 🧾 Reputation & Database

If `Config.UseDatabase = true`, reputation persists between restarts using **oxmysql**.\
The resource automatically creates the following table:

```sql
CREATE TABLE IF NOT EXISTS `klb_scrapyard_rep` (
  `identifier` VARCHAR(60) PRIMARY KEY,
  `reputation` INT NOT NULL DEFAULT 0
);
```

If disabled, reputation will only exist during runtime.

***

### 🧩 Dependencies

* **Required:** `qb-core`
* **Optional:** `qb-target`, `qb-progressbar`, `qb-menu`
* **Optional:** `oxmysql` *(for persistent reputation)*

> Works perfectly standalone — no other KLB scripts required.

***

### 🛠 Configuration

All settings can be found in `config.lua`.

Example:

```lua
Config.Locale = 'en'
Config.UseTarget = true
Config.UseDatabase = true
Config.RequireHackingForIntact = true
Config.UseFlatbedForDamaged = true
Config.UsePoliceRisk = true
```

Includes setup for:

* Contract payout scaling
* Cooldowns & tool requirements
* Police alert risk
* Reputation rewards
* Vehicle spawn zones & blacklists

### 🚨 Dispatch Integration

* Auto-detects popular dispatch resources (`ps-dispatch`, `qb-dispatch`, `cd_dispatch`, `lp-tablet`) and falls back to classic QBCore alerts.
* Configure behaviour through the new `Config.Dispatch` block (jobs, codes, messages, legacy fallback, etc.).
* Step-by-step setup for each system is available in the Dispatch Integration Guide.

***

### 🧰 Items Reference

Add these to your inventory system if missing:

```lua
    car_battery         = { name = 'car_battery', label = 'Car Battery', weight = 200, type = 'item', image = 'car-battery.png', unique = false, useable = false, shouldClose = false, description = 'Heavy old battery' },
    catalytic_converter = { name = 'catalytic_converter', label = 'Catalytic Converter', weight = 200, type = 'item', image = 'catalytic.png', unique = false, useable = false, shouldClose = false, description = 'Precious metal honeycomb' },
    rubber_tire         = { name = 'rubber_tire', label = 'Rubber Tire', weight = 300, type = 'item', image = 'rubber_tire.png', unique = false, useable = false, shouldClose = false, description = 'A worn tire from the scrapyard' },
    klb_grinder                 = { name = 'klb_grinder', label = 'Scrapyard Grinder', weight = 500, type = 'item', image = 'klb_grinder.png', unique = false, useable = false, shouldClose = false, combinable = nil, description = 'Used to grind broken scrapyard bolts.' },
    klb_cutter                = { name = 'klb_cutter', label = 'Scrapyard Cutter', weight = 500, type = 'item', image = 'klb_cutter.png', unique = false, useable = false, shouldClose = false, combinable = nil, description = 'Heavy-duty cutters for scrapyard parts.' },
    klb_torch               = { name = 'klb_torch',  label = 'Scrapyard Torch', weight = 500, type = 'item', image = 'klb_torch.png',  unique = false, useable = false, shouldClose = false, combinable = nil, description = 'Cut through metal when stripping vehicles.' },
    tool_kit               = { name = 'tool_kit', label = 'Toolkit', weight = 1000, type = 'item', image = 'screwdriverset.png', unique = false, useable = false, shouldClose = false, description = 'Very useful to screw... screws...' },
    hacking_device                       = { name = 'hacking_device', label = 'hacking device', weight = 4000, type = 'item', image = 'laptop.png', unique = false, useable = true, shouldClose = true, description = 'Have something to with gps' },
    mechanic_bumpers       = { name = 'mechanic_bumpers',       label = 'Kofangere',        weight = 0, type = 'item', image = 'bumpers.png',        unique = false, useable = true, shouldClose = true, description = '' },
    mechanic_skirts        = { name = 'mechanic_skirts',        label = 'Sideskørter',      weight = 0, type = 'item', image = 'skirts.png',         unique = false, useable = true, shouldClose = true, description = '' },
    mechanic_exhaust       = { name = 'mechanic_exhaust',       label = 'Udstødning',       weight = 0, type = 'item', image = 'exhaust.png',        unique = false, useable = true, shouldClose = true, description = '' },
    mechanic_hood          = { name = 'mechanic_hood',          label = 'Motorhjelm',       weight = 0, type = 'item', image = 'hood.png',           unique = false, useable = true, shouldClose = true, description = '' },
    mechanic_roof          = { name = 'mechanic_roof',          label = 'Tag',              weight = 0, type = 'item', image = 'roof.png',           unique = false, useable = true, shouldClose = true, description = '' },
    mechanic_spoilers      = { name = 'mechanic_spoilers',      label = 'Spoilere',         weight = 0, type = 'item', image = 'spoilers.png',       unique = false, useable = true, shouldClose = true, description = '' },
    mechanic_rollcage      = { name = 'mechanic_rollcage',      label = 'Sikkerhedsbur',    weight = 0, type = 'item', image = 'rollcage.png',       unique = false, useable = true, shouldClose = true, description = '' },
    mechanic_seats         = { name = 'mechanic_seats',         label = 'Sæder',            weight = 0, type = 'item', image = 'seats.png',          unique = false, useable = true, shouldClose = true, description = '' },


```

Default scrap items:

```
plastic, metalscrap, copper, aluminum, steel, iron, rubber, glass
```

Mechanic-compatible parts:

```
mechanic_bumpers, mechanic_skirts, mechanic_exhaust, mechanic_spoilers,
mechanic_rollcage, mechanic_roof, mechanic_hood, mechanic_seats
```

***

### ⚡ Performance

* Idle usage: **\~0.00–0.01 ms**
* Conditional threads and optimized entity checks
* Designed to scale with city size and player count

***

### 🛒 Available on Tebex

**Official Download:** <https://klbstore.tebex.io/>\
**Discord Support:** [(Discord)](https://discord.gg/7ykC5F4z47)

***

> “Collect. Strip. Hack. Deliver.\
> Build your scrapyard empire — the KLB way.”
