# installation

## Script Installation

Before starting, you must log in to the CFX portal to download the asset. You will be able to download it as many times as you want on the official CFX page. Just as you download it the first time, you will also download it multiple times in the future to get updates.

### Logging in to the CFX Portal

First, log in to the official CFX Portal by clicking here: <https://portal.cfx.re/assets/granted-assets>

### Find our Script

Once logged in, navigate to the Granted Assets section to access your purchased assets. You can download them by clicking the "Download" button. Find our script and download it.

### Install Script

After downloading script, open server resources folder and zip which you downloaded. Drag and drop into resources file, also make sure you starting script in your server.cfg:

```cfg
ensure ox_lib
ensure oxmysql
ensure ox_target
ensure sl-cardealer
```

### Dependencies

Make sure you have all required dependencies installed:

| Dependency | Required | Description                                           |
| ---------- | -------- | ----------------------------------------------------- |
| ox\_lib    | Yes      | Core library for zones, callbacks, notifications, DUI |
| oxmysql    | Yes      | Database operations for vehicle ownership             |
| ox\_target | Yes      | Interaction system for targets                        |

***

## Framework Configuration

The script comes pre-configured for ESX. To use with other frameworks, update the framework-specific client and server bridge files.

{% stepper %}
{% step %}

### Edit client bridge

Open `modules/editable_client.lua` and replace framework-specific code with your framework implementation.
{% endstep %}

{% step %}

### Edit server bridge

Open `modules/editable_server.lua` and replace framework-specific code with your framework implementation.
{% endstep %}
{% endstepper %}

See [Framework Bridge](https://scriptlock.gitbook.io/script-lock-docs/resources/car-dealer/broken-reference) for complete examples for:

* ESX (Default)
* QB-Core
* OX Core
* ND Framework

***

## Car Key Integration

The script supports popular vehicle key systems. Edit `modules/editable_client.lua` to configure:

```lua
Utils.AddCarKey = function(plate, model, vehicleData)
    -- qb-vehiclekeys
    TriggerEvent('vehiclekeys:client:SetOwner', plate)
    
    -- wasabi_carlock
    TriggerServerEvent('wasabi_carlock:GiveKey', plate)
    
    -- qs-vehiclekeys
    TriggerServerEvent('qs-vehiclekeys:server:GiveKey', plate)
    
    -- jaksam vehicle keys
    TriggerServerEvent('vehicle-keys:server:give-key', plate)
end
```

Supported key systems:

* qb-vehiclekeys
* wasabi\_carlock
* qs-vehiclekeys
* jaksam vehicle keys
* cd\_garage
* Custom implementations

***

## Script Configuration

At the end, go to `shared` folder and configure all config files:

* `config.lua` - Main dealer configuration
* `config.tuning.lua` - Tuning system configuration

***

## File Structure

```
sl-cardealer/
├── client.lua
├── server.lua
├── fxmanifest.lua
├── data/
│   ├── dealers/           # Vehicle data JSON files
│   │   ├── nova_imports.json
│   │   └── another_dealer.json
│   └── language/          # Translation files
│       ├── en.json
│       └── pl.json
├── modules/
│   ├── editable_client.lua   # Framework bridge (client)
│   ├── editable_server.lua   # Framework bridge (server)
│   └── client/
│       ├── camera.lua
│       ├── dui.lua
│       ├── testdrive.lua
│       └── tuning.lua
├── shared/
│   ├── config.lua            # Main configuration
│   ├── config.tuning.lua     # Tuning configuration
│   └── locale.lua
├── web/                       # Built NUI files (DUI)
└── dui/                       # Built DUI files
```

***

{% hint style="info" %}
Enjoy using our Script!

If you have any issues with installation or you find any error / bug, open a ticket on our Discord Server for Support: <https://discord.gg/zZj4bNMuf7>
{% endhint %}
