# Crafting Stations Settings

***

## 🏗️ Station Configuration

### Basic Structure

Crafting stations are configured in `shared/config.lua` under `Config.Craftings`:

```lua
Config.Craftings = {
    {
        id = 'unique_station_id',
        coords = vector4(x, y, z, heading),
        blip = { ... },
        title = 'STATION TITLE',
        desc = 'Station description',
        prop = 'prop_name',
        categories = { ... },
        items = { ... },
        blueprints = { ... }
    },
    -- Add more stations...
}
```

***

### Station Properties

| Property     | Type    | Required   | Description                                 |
| ------------ | ------- | ---------- | ------------------------------------------- |
| `id`         | String  | ✅ Yes      | Unique identifier for the station           |
| `coords`     | Vector4 | ✅ Yes      | Location (x, y, z, heading)                 |
| `blip`       | Table   | ✅ Yes      | Map blip configuration                      |
| `title`      | String  | ✅ Yes      | Display title in UI (uppercase recommended) |
| `desc`       | String  | ✅ Yes      | Short description shown in UI               |
| `prop`       | String  | ✅ Yes      | Object model to spawn at location           |
| `categories` | Table   | ✅ Yes      | List of item categories                     |
| `items`      | Table   | ✅ Yes      | Craftable items list                        |
| `blueprints` | Table   | ⭕ Optional | Special blueprint-locked items              |

***

## 🆕 Adding New Stations

{% stepper %}
{% step %}

### Find Coordinates

Get your position in-game via `/tx` command or your other script that supports it.
{% endstep %}

{% step %}

### Add Station Configuration

```lua
Config.Craftings = {
    -- Existing stations...
    
    -- Your new station
    {
        id = 'my_custom_station',
        coords = vector4(123.45, -678.90, 28.50, 180.0),
        blip = {
            name = 'My Crafting Station',
            sprite = 478,
            colour = 2,
            scale = 0.7,
            visible = true,
        },
        title = 'CUSTOM CRAFTING',
        desc = 'Craft custom items here',
        prop = 'prop_tool_bench02',
        categories = {
            {
                id = 'custom_category',
                label = 'Custom Items'
            }
        },
        items = {
            {
                respname = 'custom_item',
                name = 'Custom Item',
                category = 'custom_category',
                image = './images/custom.webp',
                craftingTime = 30,
                requiredLevel = 1,
                resources = {
                    { name = 'iron', amount = 5 }
                },
                exp = 25
            }
        },
        blueprints = {}
    }
}
```

{% endstep %}

{% step %}

### Test and Adjust

* Restart resource: `restart koja-crafting`
* Go to coordinates in-game
* Verify prop spawns correctly
* Test crafting interaction
* Adjust position/heading if needed
  {% endstep %}
  {% endstepper %}

***

## 📑 Categories

### Purpose

Categories organize items in the crafting menu for better navigation.

### Structure

```lua
categories = {
    {
        id = 'category_unique_id',
        label = 'Display Label'
    },
    -- More categories...
}
```

### Example - Multiple Categories

```lua
categories = {
    {
        id = 'medical',
        label = 'Medical Items'
    },
    {
        id = 'tools',
        label = 'Tools & Equipment'
    },
    {
        id = 'weapons',
        label = 'Weapons'
    },
    {
        id = 'food',
        label = 'Food & Drink'
    },
    {
        id = 'materials',
        label = 'Raw Materials'
    }
}
```

## 🎨 Items Configuration

### Basic Item Structure

```lua
items = {
    {
        respname = 'item_id',           -- Item name in inventory
        name = 'Display Name',          -- Name shown in UI
        category = 'category_id',       -- Category it belongs to
        image = './images/item.webp',   -- Image path
        craftingTime = 30,              -- Seconds to craft
        craftingAmount = 1,             -- Amount crafted per operation
        requiredLevel = 1,              -- Minimum level needed
        resources = { ... },            -- Required materials
        exp = 25                        -- XP gained on completion
    }
}
```

***

### Item Properties Explained

#### respname (Required)

```lua
respname = 'bandage'
```

* Must match your inventory item name exactly (case-sensitive)
* Used to give item to player on completion
* Examples: `'bandage'`, `'weapon_pistol'`, `'lockpick'`

***

#### name (Required)

```lua
name = 'Bandage'
```

* Display name shown in crafting UI
* Can include spaces and special characters
* Doesn't need to match inventory name

***

#### category (Required)

```lua
category = 'medical'
```

* Must match a `category.id` from categories table
* Determines which tab item appears in
* Case-sensitive

***

#### image (Required)

```lua
-- Option 1: Local image (starts with ./)
image = './images/bandage.webp'

-- Option 2: Inventory image (no ./)
image = 'bandage.png'

-- Option 3: Full path
image = 'nui://ox_inventory/web/images/bandage.png'
```

See [Images Settings](https://docs.kojascripts.eu/new/crafting/configuration/broken-reference) for detailed image configuration.

***

#### craftingTime (Required)

```lua
craftingTime = 30
```

* Time in seconds to craft one batch
* Minimum: `1` second
* Recommendations:
  * Simple items: `5-20s`
  * Common items: `20-60s`
  * Rare items: `60-180s`
  * Epic items: `180-600s`

***

#### craftingAmount (Optional)

```lua
craftingAmount = 3
```

* How many items are crafted per operation
* Default: `1` if not specified

***

#### requiredLevel (Required)

```lua
requiredLevel = 1
```

* Minimum crafting level to unlock this item
* Range: `1` to max level in `Config.Levels`
* Shows as "Locked" in UI with level requirement

***

#### resources (Required)

```lua
resources = {
    { name = 'wood', label = 'Wood', amount = 5 },
    { name = 'iron', label = 'Iron Brick', image = './images/iron.webp', amount = 3 },
    { name = 'cloth', amount = 2 }
}
```

Resource properties:

* `name` (required): Inventory item name (must exist)
* `label` (optional): Label for the item in the UI
* `amount` (required): Quantity required
* `image` (optional): Custom image for this resource

***

#### exp (Required)

```lua
exp = 25
```

* Experience points gained on successful craft
* Typically scales with crafting difficulty/time
* Example balancing:
  * Simple 10s craft: `exp = 10`
  * Medium 30s craft: `exp = 30`
  * Complex 60s craft: `exp = 60`
  * Or use formula: `exp = craftingTime / 2`

See [Player Progression](https://docs.kojascripts.eu/new/crafting/configuration/broken-reference) for XP balancing.

***

### Complete Item Example

```lua
{
    respname = 'medikit',
    name = 'Medical Kit',
    category = 'medical',
    image = './images/medikit.webp',
    craftingTime = 45,
    craftingAmount = 1,
    requiredLevel = 3,
    resources = {
        { name = 'bandage', image = './images/bandage.webp', amount = 3 },
        { name = 'pills', amount = 2 },
        { name = 'syringe', amount = 1 }
    },
    exp = 50
}
```

***

## 🔐 Blueprints System

### What Are Blueprints?

Blueprints are special items that require:

* Finding/earning a blueprint item
* Admin giving blueprint with `/addblueprint` command
* Purchasing/unlocking through gameplay

Once unlocked, the item becomes available to craft (if level requirement met).

***

### Blueprint Structure

```lua
blueprints = {
    {
        respname = 'item_id',
        name = 'Display Name',
        category = 'category_id',
        image = './images/item.webp',
        blueprintItem = 'blueprint_item_name',  -- 🔑 KEY DIFFERENCE
        craftingTime = 60,
        requiredLevel = 3,
        resources = { ... },
        exp = 100
    }
}
```

Key property:

```lua
blueprintItem = 'parachute_blueprint'
```

* This is the "key" item that unlocks crafting
* Must be given via `/addblueprint` command
* Stored in player's database record
* Can be rare drop, quest reward, or admin gift

***

### Blueprint vs Regular Item

| Feature            | Regular Item         | Blueprint Item           |
| ------------------ | -------------------- | ------------------------ |
| Visible by default | ✅ Yes (if level met) | ❌ No                     |
| Unlock method      | Reach level          | Admin command or drop    |
| Config location    | `items = { ... }`    | `blueprints = { ... }`   |
| Special property   | None                 | `blueprintItem` required |

***

### Blueprint Example

```lua
blueprints = {
    {
        respname = 'parachute',
        name = 'Parachute',
        category = 'advanced',
        image = './images/parachute.webp',
        blueprintItem = 'parachute_blueprint',  -- Required blueprint
        craftingTime = 120,
        requiredLevel = 4,
        resources = {
            { name = 'cloth', amount = 10 },
            { name = 'rope', amount = 5 },
            { name = 'metal_frame', amount = 2 }
        },
        exp = 150
    },
    {
        respname = 'night_vision',
        name = 'Night Vision Goggles',
        category = 'advanced',
        image = './images/nvg.webp',
        blueprintItem = 'nvg_blueprint',
        craftingTime = 180,
        requiredLevel = 5,
        resources = {
            { name = 'electronics', amount = 15 },
            { name = 'glass', amount = 5 },
            { name = 'battery', amount = 3 }
        },
        exp = 200
    }
}
```

***

### Giving Blueprints

Admin command:

```bash
/addblueprint [playerID] [blueprintItem]

# Examples:
/addblueprint 1 parachute_blueprint
/addblueprint 5 nvg_blueprint
```

What happens:

1. Blueprint added to player's database record
2. Item appears in crafting menu (if level met)
3. Player can now craft the item
4. Blueprint persists through restarts/disconnects

See [Admin Permissions](https://docs.kojascripts.eu/new/crafting/configuration/broken-reference) for command details.

***

## 🗺️ Blip Configuration

### Blip Structure

```lua
blip = {
    name = 'Weapon Crafting',
    sprite = 89,
    colour = 1,
    scale = 0.7,
    visible = true,
}
```

***

### Blip Properties

| Property  | Type    | Description                   | Example                |
| --------- | ------- | ----------------------------- | ---------------------- |
| `name`    | String  | Text shown when hovering blip | `'Weapon Crafting'`    |
| `sprite`  | Number  | Icon sprite ID                | `89`, `478`, `402`     |
| `colour`  | Number  | Color ID (0-85)               | `1` (red), `2` (green) |
| `scale`   | Number  | Size (0.5-1.5)                | `0.7`, `0.8`, `1.0`    |
| `visible` | Boolean | Show on map                   | `true`, `false`        |

***

### Common Blip Sprites

| Sprite | Icon       | Use Case              |
| ------ | ---------- | --------------------- |
| `89`   | 🔫 Pistol  | Weapon crafting       |
| `478`  | 🔨 Hammer  | Tool/general crafting |
| `402`  | 💊 Pills   | Medical crafting      |
| `409`  | 🍔 Food    | Food/cooking          |
| `499`  | 🛠️ Repair | Repair station        |
| `566`  | 📦 Crate   | Materials             |
| `521`  | ⚙️ Gear    | Mechanical            |

Find more: <https://docs.fivem.net/docs/game-references/blips/>

***

### Blip Colors

| ID   | Color  | Hex     | Use Case        |
| ---- | ------ | ------- | --------------- |
| `0`  | White  | #FFFFFF | General         |
| `1`  | Red    | #E03232 | Weapons/Danger  |
| `2`  | Green  | #32E032 | Medical/Safe    |
| `3`  | Blue   | #3232E0 | Police/Official |
| `5`  | Yellow | #FFD700 | Gold/Premium    |
| `25` | Purple | #B432E0 | Special/Rare    |
| `27` | Orange | #FF8C00 | Warning/Tools   |

***

### Blip Examples

**Weapon Crafting** (Red pistol):

```lua
blip = {
    name = 'Weapon Crafting',
    sprite = 89,
    colour = 1,  -- Red
    scale = 0.8,
    visible = true
}
```

**Medical Crafting** (Green pills):

```lua
blip = {
    name = 'Medical Station',
    sprite = 402,
    colour = 2,  -- Green
    scale = 0.7,
    visible = true
}
```

***

## 🛠️ Props/Objects

### Common Crafting Props

| Prop Name                 | Description      | Best For         |
| ------------------------- | ---------------- | ---------------- |
| `prop_tool_bench02`       | Workbench        | General crafting |
| `prop_tool_bench01`       | Small bench      | Tool crafting    |
| `gr_prop_gr_bench_02a`    | Garage bench     | Vehicle work     |
| `prop_toolchest_01`       | Tool chest       | Small items      |
| `prop_ld_bench01`         | Long bench       | Large projects   |
| `bkr_prop_meth_table01a`  | Lab table        | Medical/chemical |
| `bkr_prop_weed_table_01b` | Processing table | Materials        |

***

## 🐛 Troubleshooting

<details>

<summary>Station Not Spawning</summary>

**Problem**: No prop appears at coordinates

**Solutions**:

1. Verify coordinates are correct (`/getcoords`)
2. Check prop model name is valid
3. Ensure resource is running
4. Try different prop model
5. Check console for errors

</details>

<details>

<summary>Items Not Showing</summary>

**Problem**: No items in crafting menu

**Solutions**:

1. Check category IDs match between `categories` and `items`
2. Verify items array is not empty
3. Check for syntax errors (missing commas, brackets)
4. Ensure `requiredLevel` is achievable
5. Check console for Lua errors

</details>

<details>

<summary>Can't Craft Item</summary>

**Problem**: Item visible but can't craft

**Solutions**:

1. Check player has required level
2. Verify player has all resources
3. Check resource names match inventory items exactly
4. Ensure resource amounts are not zero

</details>

<details>

<summary>Wrong Item Given</summary>

**Problem**: Crafting completes but wrong item given

**Solutions**:

1. Verify `respname` matches inventory item exactly
2. Check case sensitivity (`bandage` ≠ `Bandage`)
3. Ensure inventory item exists
4. Test giving item manually
5. Check framework's item database

</details>

<details>

<summary>Blueprint Not Appearing</summary>

**Problem**: Blueprint given but item not showing

**Solutions**:

1. Check player meets `requiredLevel`
2. Verify blueprint is in `blueprints` table, not `items`
3. Check `blueprintItem` name matches command
4. Query database to verify blueprint saved
5. Player may need to reopen menu

</details>

***

## 📚 Related Documentation

* For images configuration, see [Images Settings](https://docs.kojascripts.eu/new/crafting/configuration/broken-reference)
* For level requirements, see [Player Progression](https://docs.kojascripts.eu/new/crafting/configuration/broken-reference)
* For blueprint commands, see [Admin Permissions](https://docs.kojascripts.eu/new/crafting/configuration/broken-reference)
* For interaction setup, see [Interaction Settings](https://docs.kojascripts.eu/new/crafting/configuration/broken-reference)
