Trusted Studios

ts_esx-VehicleCrafting

ts_esx-VehicleCrafting

€10.00

Add to Basket

ts_esx-VehicleCrafting

Vehicle crafting benches for ESX. Players interact with a location, select a vehicle recipe in the NUI, and assemble the car step-by-step until it becomes usable. Crafted vehicles are stored in `owned_vehicles`.

Features

- Multiple crafting benches with NPCs and optional blips.

- NUI recipe list with required items and craft time.

- Per-vehicle crafting time and randomized time support.

- Server-side item validation and vehicle creation.

- Automatic plate generation and vehicle storage.

Requirements

- FiveM server with `cerulean` fx_version.

- `es_extended` (ESX).

- `oxmysql` (for `owned_vehicles` insert).

- Trusted shared modules referenced in `fxmanifest.lua`:

  - `lib/modules/shared/*.lua`

  - `lib/modules/client/*.lua`

  - `lib/modules/server/*.lua`

- NUI build referenced in `fxmanifest.lua`:

  - `lib/web/dist/index.html`

  - `lib/web/dist/assets/index.css`

  - `lib/web/dist/js/index.js`

  - `lib/web/dist/images/*`

If the `lib/` files are missing, the resource will not load correctly.

Installation

1. Place `ts_esx-VehicleCrafting` in your resources folder (example: `resources/[custom]/ts_esx-VehicleCrafting`).

2. Ensure `es_extended` and `oxmysql` are running before this resource.

3. Add to `server.cfg`:

   ```

   ensure ts_esx-VehicleCrafting

   ```

4. Make sure the required recipe items exist in your ESX items database.

Configuration

Edit `config.lua`.

Plate generation

- `Config.PlateLetters`: Number of letters.

- `Config.PlateNumbers`: Number of numbers.

- `Config.PlateUseSpace`: Add a space between letters and numbers.

Crafting locations

`Config.VehiclesCrafting` defines the benches.

```lua

["Location 1"] = {

    coords = vec4(...),

    showblip = true,

    blip = { id = 524, scale = 0.8, color = 48 },

    label = "Autos Crafting",

    CraftVehicleCoords = vec4(...),

    vehicles = {

        ['Sentinel3'] = {

            label = 'Sentinel Sportwagen',

            craftingtime = 2000,

            spawn = "sentinel3",

            image = "images/test.png",

            required = { ["iron"] = 10, ["marijuana"] = 4 }

        }

    }

}

```

Vehicle recipe fields

- `label`: Display name in the UI.

- `craftingtime`: Time per door action in ms (total is approx. `craftingtime * 7` plus a small overhead).

- `spawn`: Model name to spawn.

- `image`: Path relative to `lib/web/dist/`.

- `required`: Items and counts required to craft.

Peds

`Config.Peds` lists the NPC models spawned at each bench.

Text and notifications

`Config.VehicleCraft*` and menu labels define the UI text. You can translate these strings directly in `config.lua`.

Gameplay flow

1. Go to a crafting bench.

2. Open the UI and select a vehicle recipe.

3. If items are available, a vehicle is spawned at `CraftVehicleCoords`.

4. Approach the vehicle and complete the build animation.

5. The crafted vehicle is stored and assigned a generated plate.

Events and callbacks

Server callbacks

- `Trusted:VehiclesCrafting:checkCrafting`

  - Validates required items; returns text + canCraft flag.

- `Trusted:VehiclesCrafting:giveCraftedVehicle`

  - Spawns the vehicle, inserts into `owned_vehicles`, and assigns plate.

Client events

- `Trusted:VehiclesCrafting:spawnCar`

  - Freezes vehicle and runs the build animation logic.

- `Trusted:VehiclesCrafting:setPlate`

  - Applies the generated plate to the crafted vehicle.

Troubleshooting

- No UI: verify `lib/web/dist` exists and matches the file list in `fxmanifest.lua`.

- No vehicle spawn: check `CraftVehicleCoords` and model names.

- Plate/owned vehicle not saved: ensure `oxmysql` is running and the `owned_vehicles` table exists.

Back to category