# Add VIN Generation

To enable the automatic generation of Vehicle Identification Numbers (VINs) for vehicles in your vehicleshop, some modifications to the vehicleshop system are required.

***

## ESX Vehicleshop

### Modified esx\_vehicleshop

{% file src="<https://3701050178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6y0J5nnTjSyc65fbCvIU%2Fuploads%2F12bAAKn7y4bIiRlJQqR0%2Fesx_vehicleshop-main.zip?alt=media&token=47a8a0ac-c943-4164-826c-23584d77bae5>" %}

### List of modifications in esx\_vehicleshop

<figure><img src="https://3701050178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6y0J5nnTjSyc65fbCvIU%2Fuploads%2FvUeKvT3xA8EEgsqYA479%2Fesx_vehicleshop1.png?alt=media&#x26;token=6c885316-42c6-4cc0-badc-d7b892aea5fa" alt=""><figcaption><p>esx_vehicleshop/server/server.lua - <code>esx_vehicleshop:setVehicleOwnedPlayerId</code></p></figcaption></figure>

<figure><img src="https://3701050178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6y0J5nnTjSyc65fbCvIU%2Fuploads%2FcRXrCgnEKKU6ylPgva8j%2Fesx_vehicleshop2.png?alt=media&#x26;token=ac4227f1-dfda-4e26-9c46-3a342958812f" alt=""><figcaption><p>esx_vehicleshop/server/server.lua - <code>esx_vehicleshop:buyVehicle</code></p></figcaption></figure>

***

## QB Vehicleshop

### Modified qb-vehicleshop

{% file src="<https://3701050178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6y0J5nnTjSyc65fbCvIU%2Fuploads%2FeEJlZoyTTOaCrhJWhSfq%2Fqb-vehicleshop-main.zip?alt=media&token=2d621fee-3685-48e0-9120-c807294db4fe>" %}

### List of modifications in qb-vehicleshop

<figure><img src="https://3701050178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6y0J5nnTjSyc65fbCvIU%2Fuploads%2Fq7D0Zy1wp9IcSQGhDGeV%2Fqb-vehicleshop1.png?alt=media&#x26;token=6c40f3fc-767b-49de-a6e6-dd8d3d27c712" alt=""><figcaption><p>qb-vehicleshop/server.lua - <code>qb-vehicleshop:server:buyShowroomVehicle</code></p></figcaption></figure>

<figure><img src="https://3701050178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6y0J5nnTjSyc65fbCvIU%2Fuploads%2F0sWIRWN8ch1WB3EYDzJG%2Fqb-vehicleshop2.png?alt=media&#x26;token=82a98bd7-2f6f-4a7a-8bb8-f8188bd2ca9c" alt=""><figcaption><p>qb-vehicleshop/server.lua - <code>qb-vehicleshop:server:financeVehicle</code></p></figcaption></figure>

<figure><img src="https://3701050178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6y0J5nnTjSyc65fbCvIU%2Fuploads%2FcnrHwvMUUFyTi1akQMgH%2Fqb-vehicleshop3.png?alt=media&#x26;token=df9811ab-0ef2-4d42-bb6c-7b5ce2bceec9" alt=""><figcaption><p>qb-vehicleshop/server.lua - <code>qb-vehicleshop:server:sellShowroomVehicle</code></p></figcaption></figure>

<figure><img src="https://3701050178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6y0J5nnTjSyc65fbCvIU%2Fuploads%2FfBZCvn9yf05aZ7tsJHag%2Fqb-vehicleshop4.png?alt=media&#x26;token=0e0b7645-5740-4615-8f6a-a4435cc0a482" alt=""><figcaption><p>qb-vehicleshop/server.lua - <code>qb-vehicleshop:server:sellfinanceVehicle</code></p></figcaption></figure>

***

## Custom Vehicleshop

{% hint style="warning" %}
If your vehicleshop does not have an open file that allows you to make changes to the parameters entered into the database when buying a vehicle, and you do not have any available function that is executed on the server side after the purchase, it means that you do not have the ability to enter the generation of the VIN number.

In this case, it is recommended to contact the author of your vehicleshop with a request to allow the introduction of a new parameter or an update that will introduce compatibility.
{% endhint %}

If you have access to the file where the sql execute is located, make modifications based on esx\_vehicleshop or qb-vehicleshop.

However, if you do not have this option, but you have access to the function that is run after the purchase of the vehicle, you can enter an execute query that updates the VIN number for the vehicle, remember that you must have a reference to the database, for example, the license plate parameter

<details>

<summary>Custom locked vehicleshop</summary>

**Remember that this function must be after server-side.**

```lua
function YOUR_EXAMPLE_FUNCTION(plate)
    local vin = exports['vms_cityhall']:GenerateVIN()
    MySQL.Async.execute('UPDATE owned_vehicles SET vin = @vin WHERE plate = @plate', {
        ['@vin'] = vin,
        ['@plate'] = plate
    })
end
```

</details>
