🔑 Vehicle Keys

Access a comprehensive guide that includes a detailed installation process, examples of code, previews of configurations.

INSTALLATION GUIDE

Step 0 - First Steps

Download is_vehiclekeys from CFX Portal and install is_bridge & is_lib.

Step 1 - Adding Lock Pick Item

Navigate to the following file and paste our code.

Overextended Inventory (QBox, ESX):

ox_inventory/data/items.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

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"},

Step 2 - Configure Resources

You must read and configure the config.lua file in is_vehiclekeys to meet your needs.

Adding Custom Vehicle

UGo to config.lua and find cfg.Custom. Here, you just need to create an object with the vehicle brand, model, and its logo.

  • vehicle: object

    • make?: string

    • model?: string

    • img?: string("images/yourimg.png" or Direct URL)

Example

[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"},
},

Adding Key for Vehicle Class

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.

Example

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
}

Adding Custom Key

Go to config.lua and find cfg.Custom. Here, you just need to create an object with a specified key.

  • keys: string

Example

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

Adding Custom Settings for Vehicle

Go to config.lua and find cfg.Custom. Here, you just need to create an object with the specified data.

  • 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

[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,
    },
},

Last updated