# 🔑 Vehicle Keys

## INSTALLATION GUIDE

{% hint style="success" %}
The script has Backward Compatibility with qb-vehiclekeys and qbx\_vehiclekeys.
{% endhint %}

### <mark style="color:red;">Step 0 - First Steps</mark>

{% hint style="info" %}
Download [**is\_vehiclekeys**](https://portal.cfx.re/assets/granted-assets?page=1\&sort=asset.updated_at\&direction=asc) from CFX Portal and install [**is\_bridge & is\_lib**](/documentation/free-scripts/bridge-and-library/usage-and-installation.md).
{% endhint %}

### <mark style="color:red;">Step 1 - Adding Lock Pick Item</mark>

{% hint style="info" %}
Navigate to the following file and paste our code.
{% endhint %}

**Overextended Inventory (QBox, ESX):**

`ox_inventory/data/items.lua`

```lua
['carlockpick'] = {
    label = "Car Lockpick",
    weight = 1000,
    stack = true,
    close = true,
    description = "Perfect when you forget your keys... or have other plans",
    client = {
        image = "lockpick.png",
        event = "is_vehiclekeys:useLockPick",
    }
},
```

**QBCore:**

`qb-core/shared/items.lua`

```lua
carlockpick = {name = "carlockpick", label = "Car Lockpick", weight = 1000, type = "item", image = "lockpick.png", unique = false, usable = true, shoudClose = true, description = "Perfect when you forget your keys... or have other plans"},
```

### <mark style="color:red;">Step 2 - Configure Resources</mark>

{% hint style="info" %}
You must read and configure the `config.lua` file in **is\_vehiclekeys** to meet your needs.
{% endhint %}

### <mark style="color:red;">Adding Custom Vehicle</mark>

{% hint style="info" %}
UGo to `config.lua` and find `cfg.Custom`. Here, you just need to create an object with the vehicle brand, model, and its logo.
{% endhint %}

* vehicle: `object`
  * make?: `string`
  * model?: `string`
  * img?: `string("images/yourimg.png" or Direct URL)`

**Example**

```lua
[GetHashKey("comet6")] = {
    vehicle = {make = "Pfister", model = "Comet VI"},
},
[GetHashKey("bmx")] = {
    vehicle = {make = "Subrosa", model = "BMX", img = "images/subrosa.png"},
},
[GetHashKey("police")] = {
    vehicle = {make = "Vapid", img = "images/vapid.webp"},
},
```

### <mark style="color:red;">Adding Key for Vehicle Class</mark>

{% hint style="info" %}
Go to `config.lua` and find `cfg.VehicleKeysType`, where you can set the key type for each vehicle class. The available key types are: `new_car`, `old_car`, `universal`, and `bike`.
{% endhint %}

**Example**

```lua
cfg.VehicleKeysType = {
    [0] = "old_car", -- Compacts  
    [1] = "new_car", -- Sedans  
    [2] = "new_car", -- SUVs  
    [3] = "old_car", -- Coupes  
    [4] = "old_car", -- Muscle  
    [5] = "old_car", -- Sports Classics  
    [6] = "new_car", -- Sports  
    [7] = "new_car", -- Super  
    [8] = "universal", -- Motorcycles  
    [9] = "old_car", -- Off-road  
    [10] = "universal", -- Industrial  
    [11] = "universal", -- Utility  
    [12] = "old_car", -- Vans
    [13] = "bike", -- Cycles  
    [14] = "universal", -- Boats  
    [15] = "universal", -- Helicopters  
    [16] = "universal", -- Planes  
    [17] = "universal", -- Service  
    [18] = "old_car", -- Emergency  
    [19] = "universal", -- Military  
    [20] = "universal", -- Commercial  
    [21] = nil, -- Trains  
    [22] = "universal", -- Open Wheel
}
```

### <mark style="color:red;">Adding Custom Key</mark>

{% hint style="info" %}
Go to `config.lua` and find `cfg.Custom`. Here, you just need to create an object with a specified key.
{% endhint %}

* keys: `string`

**Example**

```lua
[GetHashKey("sadler2")] = {
    keys = "old_car",
},
```

### <mark style="color:red;">Adding Custom Settings for Vehicle</mark>

{% hint style="info" %}
Go to `config.lua` and find `cfg.Custom`. Here, you just need to create an object with the specified data.
{% endhint %}

* settings: `object`
  * alarm?: `object`
    * enabled: `boolean`
    * activeOnFailLockPick: `boolean`
    * activeOnSuccessLockPick: `boolean`
    * activeOnSearchingKeys: `boolean`
    * activeOnHotwiring: `boolean`
    * handlePull: `boolean`
    * toggleLockDeactivate: `boolean`
    * min: `number`
    * max: `number`
  * hotwiring?: `object`
    * successChance: `number(0-100)`
    * maxAttempts: `number`
    * min: `number`
    * max: `number`
  * keysearching?: `object`
    * successChance: `number(0-100)`
    * rewardChance: `number(0-100)`
    * rewards: `array of objects`
      * item: `boolean`
      * name: `string(item name or "cash"/"bank")`
      * label?: `string`
      * count: `object`
        * min: `number`
        * max: `number`
    * min: `number`
    * max: `number`
  * lockpick?: `object`
    * enabled: `boolean`
    * keyBreakOnSuccess: `number(0-100)`
    * keyBreakOnFail: `number(0-100)`
    * minigame: `function`
      * return: `boolean`
  * anim\_lock?: `function`
  * anim\_unlock?: `function`

**Example**

```lua
[GetHashKey("zentorno")] = {
    settings = {
        alarm = {
            enabled = true,
            activeOnFailLockPick = true,
            activeOnSuccessLockPick = true,
            activeOnSearchingKeys = true,
            activeOnHotwiring = true,
            handlePull = true,
            toggleLockDeactivate = true,
            min = 30000,
            max = 60000,
        },
        hotwiring = {
            successChance = 25, -- 0 - 100%
            maxAttempts = 4,
            min = 10000,
            max = 20000,
        },
        keysearching = {
            successChance = 10, -- 0 - 100%
            rewardChance = 75, -- 0 - 100%
            rewards = {
                {item = true, name = "carlockpick", label = "Lock Pick", count = {min = 1, max = 2}},
                {item = false, name = "cash", count = {min = 100, max = 1000}},
            },
            min = 10000,
            max = 20000,
        },
        lockpick = {
            enabled = true,
            keyBreakOnSucces = 50, -- 0 - 100%
            keyBreakOnFail = 75, -- 0 - 100%
            minigame = function()
                return lib.skillCheck("hard")
            end,
        },
        anim_lock = function(veh)
            lightAnim(veh, 3.0, true, {
                {duration = 125, gap = 25, fadeIn = true, fadeOut = false},
                {duration = 125, gap = 25, fadeIn = true, fadeOut = false},
                {duration = 5000, gap = 25, fadeIn = true, fadeOut = true},
            })

            local suspensionHeight = GetVehicleSuspensionHeight(veh)

            suspensionAnim(veh, {
                {duration = 500, gap = 100, height = suspensionHeight + 0.015},
                {duration = 500, gap = 100, height = suspensionHeight},
                {duration = 500, gap = 100, height = suspensionHeight + 0.015},
                {duration = 500, gap = 100, height = suspensionHeight},
            })

            hornAnim(veh, {
                {duration = 200, gap = 0},
            })
        end,
        anim_unlock = function(veh)
            lightAnim(veh, 3.0, true, {
                {duration = 125, gap = 25, fadeIn = true, fadeOut = false},
                {duration = 125, gap = 25, fadeIn = true, fadeOut = false},
                {duration = 125, gap = 25, fadeIn = true, fadeOut = false},
                {duration = 2500, gap = 25, fadeIn = true, fadeOut = true},
            })

            local suspensionHeight = GetVehicleSuspensionHeight(veh)

            suspensionAnim(veh, {
                {duration = 500, gap = 100, height = suspensionHeight + 0.015},
                {duration = 500, gap = 100, height = suspensionHeight},
                {duration = 500, gap = 100, height = suspensionHeight + 0.015},
                {duration = 500, gap = 100, height = suspensionHeight},
            })
        end,
    },
},
```


---

# 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://inside-scripts.gitbook.io/documentation/paid-scripts/vehicle-keys.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.
