# Installation & Configuration & Integration

## <img src="/files/W1oatVHCMT6tBaAXr6T2" alt="" data-size="line">Step By Step Installation

**Install**

Login to your [keymaster](https://keymaster.fivem.net/asset-grants/) account, check Granted Assets section and download script you bought from us&#x20;

**IMPORTANT**

Replace your baseevents script with this one&#x20;

{% embed url="<https://github.com/lesimov/baseevents>" %}

**Script Start Order**

```
ensure baseevents # Install this one from https://github.com/lesimov/baseevents
ensure es_extended
ensure dusa_vehiclekeys
ensure dusa_lockpick
```

## <img src="/files/4JslPu1FspYQp1B97SK3" alt="" data-size="line">Configuration

#### **Set Framework**

```lua
Config.Framework = "esx" -- esx / oldesx
Config.CustomFramework = true
function CustomFrameworkExport() -- Add the export here, as in the following example.
    ESX = exports["es_extended"]:getSharedObject()
end

Config.PlayerLoadedExport = 'esx:playerLoaded'
```

**Dispatch Integration**

We leave default dispatch for you, but if you want to use your own dispatch just use your trigger code below -- exports\['ps-dispatch']:VehicleTheft(vehicle) code

If you using ps-dispatch just remove -- at the start of code

```
--- @param -- For customized dispatch, edit  AlertPolice function below here.
function AlertPolice(type, vehicle)
    if not AlertSend then
        local chance = Config.PoliceAlertChance
        if GetClockHours() >= 1 and GetClockHours() <= 6 then
            chance = Config.PoliceNightAlertChance
        end
        if math.random() <= chance then
            -- Integrate your own dispatch script here
            -- exports['ps-dispatch']:VehicleTheft(vehicle)
            
            -- Default
            TriggerServerEvent('dusa_vehiclekeys:server:policeAlert', Config.Language['info']["palert"] .. type)
        end
        AlertSend = true
        SetTimeout(Config.AlertCooldown, function()
            AlertSend = false
        end)
    end
end
```

#### **Translation**

You can edit these lines for all translations

```lua
----------------------------------------------------------------
----                       TRANSLATION                      ----
----------------------------------------------------------------
Config.Language = {
    ['notify'] = {
        ydhk = 'You don\'t have keys to this vehicle.',
        nonear = 'There is nobody nearby to hand keys to',
        vlock = 'Vehicle locked!',
        vunlock = 'Vehicle unlocked!',
        vlockpick = 'You managed to pick the door lock open!',
        fvlockpick = 'You fail to find the keys and get frustrated.',
        vgkeys = 'You hand over the keys.',
        vgetkeys = 'You get keys to the vehicle!',
        fpid = 'Fill out the player ID and Plate arguments',
        cjackfail = 'Carjacking failed!',
        vehclose = 'There\'s no close vehicle!',
        alertowner = 'Leave my car you idiot!',
        removedkey = 'Key removed successfully!',
    },
    ['progress'] = {
        takekeys = 'Taking keys from body...',
        hskeys = 'Searching for the car keys...',
        acjack = 'Attempting Carjacking...',
        stelingkeys = 'Stealing Keys..',
        hotwiring = 'Hotwiring..',
    },
    ['info'] = {
        skeys = '[H] - Hotwire',
        tlock = 'Toggle Vehicle Locks',
        palert = 'Vehicle theft in progress. Type: ',
        engine = 'Toggle Engine',
    },
    ['addcom'] = {
        givekeys = 'Hand over the keys to someone. If no ID, gives to closest person or everyone in the vehicle.',
        givekeys_id = 'id',
        givekeys_id_help = 'Player ID',
        addkeys = 'Adds keys to a vehicle for someone.',
        addkeys_id = 'id',
        addkeys_id_help = 'Player ID',
        addkeys_plate = 'plate',
        addkeys_plate_help = 'Plate',
        rkeys = 'Remove keys to a vehicle for someone.',
        rkeys_id = 'id',
        rkeys_id_help = 'Player ID',
        rkeys_plate = 'plate',
        rkeys_plate_help = 'Plate',
    }
}
```

## <img src="/files/uHFEZUQyna44iyxdS3Tu" alt="" data-size="line">Integrate Exports

**Default Integration (Suggested)**

Send vehicle plate in the parameter

<pre><code><strong>exports['dusa_vehiclekeys']:IntegrateKey(plate) 
</strong></code></pre>

**Dynamic Integration**

It will automatically get closest vehicle or the vehicle ped is using. If you trying to integrate key for not spawned vehicle,  this integration may be cause some issues

```
exports['dusa_vehiclekeys']:IntegrateDynamically()
```

**Add Key**

Give specified plate key for player

```
exports['dusa_vehiclekeys']:AddKey(plate)
```

**Remove Key**

Remove specified plate key from player

```
exports['dusa_vehiclekeys']:RemoveKey(plate)
```

**Has Keys**

Check if player has the key of defined plate

```
exports['dusa_vehiclekeys']:HasKeys(plate)
```


---

# 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://dusadev.gitbook.io/dusa-docs/esx/vehicle-keys/installation-and-configuration-and-integration.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.
