# Installation

Step-by-step guide to install the Multiplayer Scrapyard Job on your FiveM server.

***

## Prerequisites

Before installing, make sure you have:

| Requirement           | Description                                         |
| --------------------- | --------------------------------------------------- |
| **Framework**         | QBCore, QBox, ESX, vRP, or Standalone               |
| **Database Resource** | oxmysql (recommended), mysql-async, or ghmattimysql |
| **PolyZone**          | Required for all Tworst Scripts                     |
| **FiveM Server**      | Build 2802 or higher recommended                    |

***

## Step 1: Download the Script

### From Cfx.re Portal (Recommended)

1. Go to [portal.cfx.re](https://portal.cfx.re)
2. Navigate to **Granted Assets**
3. Find **tw-scrapyard** in your purchased scripts
4. Click **Download** to get the latest version

### From Tebex

1. Log in to your Tebex account
2. Go to your purchases
3. Download the script package

***

## Step 2: Extract Files

1. Extract the downloaded archive
2. You will find **two folders**:
   * `tw-scrapyard` - Main script
   * `tw_scrapyard_stream` - Stream assets (maps, props, vehicles)
3. Place **both folders** in your server's `resources` directory

```
resources/
├── [standalone]/
├── [qb]/
├── tw-scrapyard/              ← Main script
│   ├── config/
│   │   ├── config.lua
│   │   ├── coordinate.lua
│   │   └── GetCore.lua
│   ├── client/
│   ├── server/
│   ├── locales/
│   ├── html/
│   ├── ITEM/
│   └── fxmanifest.lua
└── tw_scrapyard_stream/       ← Stream assets (REQUIRED)
    ├── stream/
    │   ├── *.ydr              # 3D models
    │   ├── *.yft              # Fragment models
    │   ├── *.ytd              # Textures
    │   └── ...
    └── fxmanifest.lua
```

{% hint style="danger" %}
**Important:** The stream folder contains custom maps, props, and vehicle models. Without it, the job location will be invisible and vehicles won't spawn correctly!
{% endhint %}

***

## Step 3: Database Setup

{% hint style="success" %}
**Automatic Setup:** The script automatically creates the required database tables when it starts for the first time. No manual SQL import needed!
{% endhint %}

### If Automatic Setup Fails

In rare cases where automatic creation fails, you can manually import:

1. Find `insert.sql` in the script folder (if available)
2. Import it using HeidiSQL, phpMyAdmin, or command line

```bash
mysql -u username -p database_name < insert.sql
```

***

## Step 4: Add Items to Inventory

### For QBCore / QBox

Add these items to `qb-core/shared/items.lua`:

```lua
-- Scrapyard Job Items
gold_dust = { name = 'gold_dust', label = 'Golden Dust', weight = 100, type = 'item', image = 'gold_dust.png', unique = false, useable = false, shouldClose = true, description = 'A golden dust seems like the jackpot to me!' },
iron = { name = 'iron', label = 'Iron', weight = 100, type = 'item', image = 'iron.png', unique = false, useable = false, shouldClose = false, description = 'Handy piece of metal that you can probably use for something' },
pistol_part1 = { name = 'pistol_part1', label = 'Pistol Part 1', weight = 100, type = 'item', image = 'pistol_part1.png', unique = false, useable = false, shouldClose = true, description = '' },
pistol_part2 = { name = 'pistol_part2', label = 'Pistol Part 2', weight = 100, type = 'item', image = 'pistol_part2.png', unique = false, useable = false, shouldClose = true, description = '' },
pistol_part3 = { name = 'pistol_part3', label = 'Pistol Part 3', weight = 100, type = 'item', image = 'pistol_part3.png', unique = false, useable = false, shouldClose = true, description = '' },
pistol_part4 = { name = 'pistol_part4', label = 'Pistol Part 4', weight = 100, type = 'item', image = 'pistol_part4.png', unique = false, useable = false, shouldClose = true, description = '' },
```

### For ox\_inventory

Add these items to `ox_inventory/data/items.lua`:

```lua
["gold_dust"] = {
    label = "Gold Dust",
    weight = 1,
    stack = true,
    close = true,
},
["iron"] = {
    label = "Iron",
    weight = 1,
    stack = true,
    close = true,
},
["pistol_part1"] = {
    label = "Pistol Part 1",
    weight = 1,
    stack = true,
    close = true,
},
["pistol_part2"] = {
    label = "Pistol Part 2",
    weight = 100,
    stack = true,
    description = 'A component used in assembling a pistol.',
},
["pistol_part3"] = {
    label = "Pistol Part 3",
    weight = 100,
    stack = true,
    description = 'A component used in assembling a pistol.',
},
["pistol_part4"] = {
    label = "Pistol Part 4",
    weight = 100,
    stack = true,
    description = 'A component used in assembling a pistol.',
},
```

### Item Images

Copy the item images from `tw-scrapyard/ITEM/` folder to your inventory's image folder:

* **QBCore:** `qb-inventory/html/images/`
* **ox\_inventory:** `ox_inventory/web/images/`

***

## Step 5: Configure the Script

Open `config/config.lua` and set your framework:

```lua
-- Framework Selection
Config.Framework = 'qb'  -- Options: 'qb', 'oldqb', 'esx', 'oldesx', 'vrp', 'vrp2', 'standalone'

-- Database Resource
Config.SQL = "oxmysql"  -- Options: 'oxmysql', 'mysql-async', 'ghmattimysql'

-- Inventory System
Config.Inventory = "qb_inventory"  -- Options: 'qb_inventory', 'esx_inventory', 'ox_inventory', 'qs_inventory'

-- Interaction System
Config.InteractionHandler = 'drawtext'  -- Options: 'drawtext', 'ox-target'
```

{% hint style="info" %}
**QBox Users:** Set `Config.Framework = 'qb'` - QBox is fully compatible with the 'qb' setting.
{% endhint %}

See the [Configuration](https://docs.tworst.com/scripts/scrapyard-job/configuration) page for all available options.

***

## Step 6: Configure Database Resource

### For oxmysql (Recommended)

Make sure this line is in your `fxmanifest.lua`:

```lua
server_scripts {
    '@oxmysql/lib/MySQL.lua',
    -- other files...
}
```

### For mysql-async

Uncomment the mysql-async line and comment out oxmysql:

```lua
server_scripts {
    '@mysql-async/lib/MySQL.lua',  -- Uncomment this
    -- '@oxmysql/lib/MySQL.lua',   -- Comment this out
    -- other files...
}
```

***

## Step 7: Add to server.cfg

Add the following to your `server.cfg`:

```cfg
# Dependencies (must start before tw-scrapyard)
ensure oxmysql          # or mysql-async
ensure es_extended      # or qb-core (your framework)
ensure PolyZone

# Tworst Scripts - Stream files must be loaded!
ensure tw_scrapyard_stream
ensure tw-scrapyard
```

{% hint style="warning" %}
**Load Order:**

* Dependencies must start **before** the script
* Stream resource (`tw_scrapyard_stream`) must be started **before or with** the main script
  {% endhint %}

***

## Step 8: Restart Server

1. Save all configuration changes
2. Restart your server completely
3. Check the server console for any errors

***

## Verification

After starting the server, verify the installation:

### Check Console

Look for these messages in your server console:

* Database tables created successfully (first run only)
* No error messages related to tw-scrapyard

### In-Game Test

1. Go to the scrapyard location (default: El Burro Heights)
2. Look for the job blip on the map
3. Interact with the NPC to open the job menu
4. Create a lobby and start a job

***

## File Structure

```
tw-scrapyard/
├── config/
│   ├── config.lua         # Main configuration
│   ├── coordinate.lua     # Location coordinates
│   └── GetCore.lua        # Framework detection
├── client/
│   ├── main.lua           # Main client script
│   ├── vehicle.lua        # Vehicle system
│   ├── press.lua          # Press machine
│   ├── shredding.lua      # Shredding system
│   ├── furnace.lua        # Furnace system
│   ├── rail.lua           # Rail system
│   └── ...
├── server/
│   ├── server.lua         # Main server script
│   ├── lobby.lua          # Lobby management
│   ├── mission.lua        # Mission system
│   └── ...
├── locales/
│   ├── en.lua             # English
│   ├── tr.lua             # Turkish
│   ├── de.lua             # German
│   └── ...
├── html/                  # UI files
├── ITEM/                  # Item images & definitions
└── fxmanifest.lua
```

***

## Troubleshooting

### Script Won't Start

1. Check resource name is exactly `tw-scrapyard` (case-sensitive on Linux)
2. Verify all dependencies are started before the script
3. Check for syntax errors in config files

### Missing Props / Invisible Location

1. Make sure `tw_scrapyard_stream` is in your resources folder
2. Verify it's started in your `server.cfg`
3. Check the server console for streaming errors
4. The stream folder must contain `.ydr`, `.yft`, and `.ytd` files

### Database Errors

1. Verify database connection string in `server.cfg`
2. Check that your database resource is starting properly
3. Ensure `Config.SQL` matches your database resource

### Framework Not Detected

1. Make sure `Config.Framework` matches your framework
2. Verify framework resource is starting before tw-scrapyard
3. Check framework resource name matches expected names

### Items Not Working

1. Verify items are added to your inventory system
2. Check item names match exactly (case-sensitive)
3. Restart both the inventory resource and tw-scrapyard

***

## Need Help?

{% hint style="info" %}
Having installation issues? Join our [Discord server](https://discord.gg/tworst) and open a support ticket with:

* Server console errors
* Your `Config.Framework` and `Config.SQL` settings
* Screenshots of any issues
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tworst.com/scripts/scrapyard-job/installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
