# Installation

Thank you for choosing **Kartik-Mechanic** — the complete, realistic vehicle simulation system for **FiveM**.

This guide walks you through the **installation**, **boot order**, and **initial configuration** required to launch Kartik-Mechanic on your server.

{% hint style="info" %}
**Need Help?** If you run into any issues during installation, please **open a ticket** on our [**Discord server**](https://discord.gg/T6AXd2eWdH). Our support team is ready to assist you!
{% endhint %}

***

## 📋 Dependencies

Ensure these resources are installed and running **before** starting Kartik-Mechanic:

| Dependency                 | Required | Purpose                                  |
| -------------------------- | -------- | ---------------------------------------- |
| **oxmysql**                | ✅ Yes    | Core database wrapper.                   |
| **ox\_lib**                | ✅ Yes    | UI, notifications, and shared utilities. |
| **Framework**              | ✅ Yes    | QBox, QBCore, or ESX (Legacy/1.2+).      |
| **kartik-mechanic-stream** | ✅ Yes    | Mandatory 3D models and sound assets.    |

***

## 📥 Asset Setup

1. Log in to [**Cfx.re Keymaster**](https://portal.cfx.re/assets/granted-assets).
2. Find **Kartik-Mechanic** in your granted assets.
3. Download the latest version and extract it into your server's `resources` folder.
4. **Important**: Ensure you also download and install `kartik-mechanic-stream` alongside it.

***

## 🚦 Boot Order (server.cfg)

The order in which resources start is critical. If Kartik-Mechanic starts before its dependencies, it will fail to load its bridge functions.

```bash
# 1. Core Utilities
ensure oxmysql
ensure ox_lib

# 2. Framework (Choose one)
ensure qb-core
# ensure qbx_core
# ensure es_extended

# 3. Inventory System
ensure ox_inventory

# 4. Kartik Mechanic Assets
ensure kartik-mechanic-stream
ensure kartik-mechanic
```

***

## 🛠️ Initial Configuration

1. **Items**: Kartik-Mechanic requires a wide range of items for parts and tools.
   * Copy the item definitions from [**Configuration > Items**](/docs/scripts/kartik-mechanic/configuration/items.md) into your inventory's data file.
2. **Database**: Kartik-Mechanic is a **drag-and-drop** script and does **not** include a separate `.sql` file. The script features an **auto-installer** that handles database setup automatically on the first launch.
   * **Crucial**: Before starting the script for the first time, ensure your database does not already contain tables starting with `mechanic_`, `vehicle_mileage`, or `handling_`.
   * Ensure your MySQL user has `CREATE` permissions.
3. **Bridges**: Head to `shared/general.lua` and ensure `Config.InteractionType` matches your server's preference (`radial`, `button`, or `target`).

***

## ⚡ Performance Tuning

If you notice performance issues on high-population servers, consider adjusting these values in `shared/general.lua`:

* **`Config.AutosaveInterval`**: Increase to `60` or `120` seconds to reduce database load.
* **`Config.BrakeGlow.UpdateInterval`**: Increase to `100` or `200`ms for a more lightweight visual effect.
* **`Config.WarningsInterval`**: Set to a high value (`9999`) to prevent repeated client-side calculations for worn parts.

***

## ❓ Common Issues

> \[!WARNING] **"Resource kartik-mechanic-stream not found"** This script depends on its stream folder to load 3D models (clips, dynos, lifts). Ensure the stream resource is named exactly `kartik-mechanic-stream` and is started **before** the main script.

> \[!NOTE] **"Attempt to call a nil value (export '...')"** This usually means a dependency (like `ox_lib`) started after Kartik-Mechanic. Check your `server.cfg` boot order carefully.


---

# 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://kartik-scripts.gitbook.io/docs/scripts/kartik-mechanic/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.
