> For the complete documentation index, see [llms.txt](https://documentation.jaksam-scripts.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.jaksam-scripts.com/vehicles-keys/fix-hotwiring-bought-car.md).

# Fix hotwiring bought car

## Generic script

If after you purchase a vehicle you have to hotwire it, you only have to add [this simple line of code ](/vehicles-keys/client/refresh-self-owned-vehicles.md)in your script code, after you know that the vehicle is added in `owned_vehicles` / `player_vehicles` table (depending on the framework)

You may want to add a `Citizen.Wait(2000)` before that line in case the vehicle wasn't yet in the table in the moment you triggered the event

## esx\_vehicleshop

### First step

Go to `esx_vehicleshop/server/main.lua` and search for the following code:

<figure><img src="/files/Wod7ejt7BM36SaHfGjHC" alt=""><figcaption></figcaption></figure>

And add this line

```lua
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(playerId)
```

<figure><img src="/files/0KshslyMa2ebxNM7KBRg" alt=""><figcaption></figcaption></figure>

### Second step

Go to `esx_vehicleshop/server/main.lua` (the same file as before) and search for the following code:

<figure><img src="/files/8ANYg9mnJwXwSKXYdibY" alt=""><figcaption></figcaption></figure>

And add this line

```lua
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(source)
```

<figure><img src="/files/eJtyCtIeSv4NGBpReC7h" alt=""><figcaption></figcaption></figure>

## esx\_advancedvehicleshop

Go to `esx_advancedvehicleshop/server/main.lua` and search for the following code:

<figure><img src="/files/yL3edol0x9cPV8Z4bFtn" alt=""><figcaption></figcaption></figure>

And add this line

```lua
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(source)
```

<figure><img src="/files/r66Bd35RDx3CRLqVmPn8" alt=""><figcaption></figcaption></figure>

## qb-vehicleshop

### First step

Go to `qb-vehicleshop/server.lua` and you will have to add the following code after **all** `exports.oxmysql:insert`

In the example, it will be shown only one time, but you have to add it multiple times

<figure><img src="/files/4Q012bFsmwp0U8DTXibL" alt=""><figcaption></figcaption></figure>

And add the following code

```lua
SetTimeout(1000, function() 
    exports["vehicles_keys"]:refreshPlayerOwnedVehicles( pData.PlayerData.source )
end)
```

In certain parts, you will have to replace `pData` with something else, here it will show where to add the code and on what `pData` depends

<figure><img src="/files/Nb8Fy9JgCo6RdYNUvjvc" alt=""><figcaption></figcaption></figure>

**Note**: the green circles showed in the screenshot must match, so if the first one is for example `targetPlayer`, the second one must be `targetPlayer` as well

### Second step

Go to `qb-vehicleshop/server.lua` (the same file as before) and replace all these events (they are at the bottom of the file)

```lua
TriggerClientEvent('vehiclekeys:client:SetOwner', buyerId, plate)
```

with the following code

```lua
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(buyerId)
```

## okokVehicleShop

Go to `okokVehicleShop/sv_utils.lua` and search for the following code:

<figure><img src="/files/4RMdxBJJemxHyyGm99xc" alt=""><figcaption></figcaption></figure>

And add this line

```lua
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(_source)
```

<figure><img src="/files/JL7DPmUtyQ3JSwuwxByW" alt=""><figcaption></figcaption></figure>

## s4-vehicleshop

Go to `s4-vehicleshop/server.lua` and search for the following code:

<figure><img src="/files/Q6CTpHFuLowTGS6PFjgR" alt=""><figcaption></figcaption></figure>

And add the following code:

```lua
SetTimeout(1000, function() 
    exports["vehicles_keys"]:refreshPlayerOwnedVehicles(src)
end)
```

<figure><img src="/files/5DoZYk2zox98dx08F1gt" alt=""><figcaption></figcaption></figure>

**Note:** this code will work for both *oxmysql* and *ghmattimysql* versions

## t1ger\_dealerships

### First step

Go to `t1ger_dealerships/server/main.lua` and add the following line below **all codes** (more than one) like as shown in the example

```lua
exports['t1ger_keys']:UpdateKeysToDatabase(props.plate, true)
```

<figure><img src="/files/YgjdKPXIMzf1V3fhNfYd" alt=""><figcaption></figcaption></figure>

And add the following line

```lua
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(xPlayer.source)
```

<figure><img src="/files/0uSChPXwJTfSK4sNIq7o" alt=""><figcaption></figcaption></figure>

### Second step

Go to `t1ger_dealerships/server/main.lua` (same file as before) and search for the following code:

<figure><img src="/files/GD4ASFrL7WmM9q6R22QM" alt=""><figcaption></figcaption></figure>

And add the following line

```lua
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(xPlayer.source)
```

<figure><img src="/files/i0KXtRwoHih7lt3LL1bF" alt=""><figcaption></figcaption></figure>
