> For the complete documentation index, see [llms.txt](https://meadow-development.gitbook.io/meadow-development-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://meadow-development.gitbook.io/meadow-development-docs/skripte/it_licenseplate/vehicleshop-verbinden.md).

# VehicleShop verbinden

## Fahrgestellnummer vergeben

<mark style="color:$danger;">**Wichtig: Es gibt Dateien an den du Einstellen kannst, wie/welche Kennzeichen neue Autos bekommen sollen!**</mark>

Es muss nur ein Export für die Fahrgestellnummer eingesetzt werden, damit alles ohne Probleme funktioniert.

**Ist dein Fahrzeughändler nicht dabei? Mach einfach ein Support-Ticket auf und frage nach!**

{% tabs %}
{% tab title="esx\_vehicleshop" %}
Link zum Fahrzeughändler: [esx\_vehicleshop](https://github.com/esx-overextended/esx_vehicleshop/tree/main)

Gehe in folgende Datei:

```lua
esx_vehicleshop/client/utils.lua
```

Gehe in folgende Funktion:

```lua
function GeneratePlate()
	math.randomseed(GetGameTimer())

	local generatedPlate = string.upper(GetRandomLetter(Config.PlateLetters) .. (Config.PlateUseSpace and ' ' or '') .. GetRandomNumber(Config.PlateNumbers))

	local isTaken = IsPlateTaken(generatedPlate)
	if isTaken then 
		return GeneratePlate()
	end

	return generatedPlate
end
```

Und folgendes muss da eingetragen werden:

```lua
local vin = exports["IT_Licenseplate"]:GenerateRandomVIN()
```

So ist das Ergebnis:

<pre class="language-lua"><code class="lang-lua">function GeneratePlate()
	math.randomseed(GetGameTimer())

<strong>	local generatedPlate = exports["IT_Licenseplate"]:GenerateRandomVIN()
</strong>	return generatedPlate
end
</code></pre>

{% endtab %}

{% tab title="vms\_vehicleshopv2" %}
Link zum Fahrzeughändler: [vms\_vehicleshopv2](https://www.vames-store.com/package/6153182)

Gehe in folgende Datei:

```lua
vms_vehicleshopv2/config/config.server.lua
```

Gehe in folgende Funktion:

{% code expandable="true" %}

```lua
SV.addPlayerVehicle = function(xPlayer, price, model, vehicleType, licensePlate, properties, vehId, netId, spawnOnPurchase, cb)
    local myIdentifier = SV.getIdentifier(xPlayer);
    local characterName = SV.getCharacterName(xPlayer);

    -- Garages:
    local vmsGaragesV2 = GetResourceState('vms_garagesv2') == 'started'
    local qsAdvancedGarages = GetResourceState('qs-advancedgarages') == 'started'

    -- Externals:
    local mInsurance = GetResourceState('m-Insurance') == 'started'
    local vmsCityhall = GetResourceState('vms_cityhall') == 'started'

    if Config.Core == "ESX" then
        if vmsGaragesV2 then
            local query = "INSERT INTO owned_vehicles (`owner`, `plate`, `vehicle`, `vin`, `netid`, `type`, `garage`) VALUES (@owner, @plate, @vehicle, @vin, @netid, @type, @garage)"
            if vmsCityhall then
                query = "INSERT INTO owned_vehicles (`owner`, `owner_history`, `plate`, `vehicle`, `vin`, `netid`, `type`, `garage`) VALUES (@owner, @owner_history, @plate, @vehicle, @vin, @netid, @type, @garage)"
            end

            MySQL.Async.execute(query, {
                ['@owner'] = myIdentifier, 
                ['@plate'] = licensePlate, 
                ['@owner_history'] = json.encode({{name=characterName, from=tostring(os.time()), to="current", price = price}}), 
                ['@vin'] = SV.createVIN(),
                ['@netid'] = netId,
                ['@vehicle'] = json.encode(properties), 
                ['@type'] = vehicleType,
                ['@garage'] = not spawnOnPurchase and 'Impound1' or nil,
            })
        elseif qsAdvancedGarages then
            local query = "INSERT INTO owned_vehicles (`owner`, `plate`, `vehicle`, `type`, `garage`, `stored`) VALUES (@owner, @plate, @vehicle, @type, @garage, @stored)"
            if vmsCityhall then
                query = "INSERT INTO owned_vehicles (`owner`, `plate`, `owner_history`, `vin`, `vehicle`, `type`, `garage`, `stored`) VALUES (@owner, @plate, @owner_history, @vin, @vehicle, @type, @garage, @stored)"
            end

            MySQL.Async.execute(query, {
                ['@owner'] = myIdentifier, 
                ['@plate'] = licensePlate, 
                ['@owner_history'] = json.encode({{name=characterName, from=tostring(os.time()), to="current", price = price}}), 
                ['@vin'] = vmsCityhall and SV.createVIN() or nil,
                ['@vehicle'] = json.encode(properties), 
                ['@type'] = vehicleType,
                ['@garage'] = not spawnOnPurchase and 'Impound1' or nil,
                ['@stored'] = not spawnOnPurchase and 1 or 0,
            })
        else
            local query = 'INSERT INTO owned_vehicles (`owner`, `plate`, `vehicle`, `type`, `stored`) VALUES (@owner, @plate, @vehicle, @type, @stored)'
            if vmsCityhall then
                query = "INSERT INTO owned_vehicles (`owner`, `plate`, `owner_history`, `vin`, `vehicle`, `type`, `stored`) VALUES (@owner, @plate, @owner_history, @vin, @vehicle, @type, @stored)"
            end
            
            MySQL.Async.execute(query, {
                ['@owner'] = myIdentifier, 
                ['@plate'] = licensePlate, 
                ['@owner_history'] = json.encode({{name=characterName, from=tostring(os.time()), to="current", price = price}}), 
                ['@vin'] = vmsCityhall and SV.createVIN() or nil,
                ['@vehicle'] = json.encode(properties), 
                ['@type'] = vehicleType,
                ['@stored'] = not spawnOnPurchase and 1 or 0,
            })
        end

        if mInsurance then
            MySQL.Async.execute('INSERT INTO m_insurance_registration (plate, model, registration, identifier) VALUES (?, ?, ?, ?)', {licensePlate, model, 1, myIdentifier})
        end

        cb(true)
    elseif Config.Core == "QB-Core" then
        if vmsGaragesV2 then
            local query = 'INSERT INTO player_vehicles (`license`, `citizenid`, `vehicle`, `hash`, `mods`, `plate`, `vin`, `netid`, `garage`, `type`) VALUES (@license, @citizenid, @vehicle, @hash, @mods, @plate, @vin, @netid, @garage, @type)'
            if vmsCityhall then
                query = "INSERT INTO player_vehicles (`license`, `citizenid`, `owner_history`, `vehicle`, `hash`, `mods`, `plate`, `vin`, `netid`, `garage`, `type`) VALUES (@license, @citizenid, @owner_history, @vehicle, @hash, @mods, @plate, @vin, @netid, @garage, @type)"
            end
            
            MySQL.Async.execute(query, {
                ['@license'] = xPlayer.PlayerData.license,
                ['@citizenid'] = myIdentifier,
                ['@owner_history'] = json.encode({{name=characterName, from=tostring(os.time()), to="current", price = price}}), 
                ['@vehicle'] = model,
                ['@hash'] = properties.model,
                ['@mods'] = json.encode(properties),
                ['@plate'] = licensePlate,
                ['@vin'] = SV.createVIN(),
                ['@netid'] = netId,
                ['@garage'] = not spawnOnPurchase and 'Impound1' or nil,
                ['@type'] = vehicleType,
            })
        elseif qsAdvancedGarages then
            local query = 'INSERT INTO player_vehicles (`license`, `citizenid`, `vehicle`, `hash`, `mods`, `plate`, `garage`, `type`) VALUES (@license, @citizenid, @vehicle, @hash, @mods, @plate, @garage, @type)'
            if vmsCityhall then
                query = "INSERT INTO player_vehicles (`license`, `citizenid`, `owner_history`, `vin`, `vehicle`, `hash`, `mods`, `plate`, `garage`, `type`) VALUES (@license, @citizenid, @owner_history, @vin, @vehicle, @hash, @mods, @plate, @garage, @type)"
            end
            
            MySQL.Async.execute(query, {
                ['@license'] = xPlayer.PlayerData.license,
                ['@citizenid'] = myIdentifier,
                ['@owner_history'] = json.encode({{name=characterName, from=tostring(os.time()), to="current", price = price}}), 
                ['@vin'] = vmsCityhall and SV.createVIN() or nil,
                ['@vehicle'] = model,
                ['@hash'] = properties.model,
                ['@mods'] = json.encode(properties),
                ['@plate'] = licensePlate,
                ['@garage'] = spawnOnPurchase and 'OUT' or '',
                ['@type'] = vehicleType,
            })
        else
            local query = 'INSERT INTO player_vehicles (`license`, `citizenid`, `vehicle`, `hash`, `mods`, `plate`, `garage`, `state`) VALUES (@license, @citizenid, @vehicle, @hash, @mods, @plate, @garage, @state)'
            if vmsCityhall then
                query = "INSERT INTO player_vehicles (`license`, `citizenid`, `owner_history`, `vin`, `vehicle`, `hash`, `mods`, `plate`, `garage`, `state`) VALUES (@license, @citizenid, @owner_history, @vin, @vehicle, @hash, @mods, @plate, @garage, @state)"
            end

            MySQL.Async.execute(query, {
                ['@license'] = xPlayer.PlayerData.license,
                ['@citizenid'] = myIdentifier,
                ['@owner_history'] = json.encode({{name=characterName, from=tostring(os.time()), to="current", price = price}}), 
                ['@vin'] = vmsCityhall and SV.createVIN() or nil,
                ['@vehicle'] = model,
                ['@hash'] = properties.model,
                ['@mods'] = json.encode(properties),
                ['@plate'] = licensePlate,
                ['@garage'] = spawnOnPurchase and 'OUT' or '',
                ['@state'] = not spawnOnPurchase and 1 or 0,
            })
        end

        if mInsurance then
            MySQL.Async.execute('INSERT INTO m_insurance_registration (plate, model, registration, identifier) VALUES (?, ?, ?, ?)', {licensePlate, model, 1, myIdentifier})
        end

        cb(true)
    end
end

SV.onVehicleSpawned = function(xPlayer, networkId)
    local networkId = networkId
    local vehicleId = NetworkGetEntityFromNetworkId(networkId)
    
    if GetResourceState('qs-advancedgarages') == 'started' then
        exports['qs-advancedgarages']:setVehicleToPersistent(networkId)
        
    end
end
```

{% endcode %}

Und folgendes muss da eingetragen werden:

```lua
local vin = exports["IT_Licenseplate"]:GenerateRandomVIN()
```

So ist das Ergebnis:

<pre class="language-lua" data-expandable="true"><code class="lang-lua">SV.addPlayerVehicle = function(xPlayer, price, model, vehicleType, licensePlate, properties, vehId, netId, spawnOnPurchase, cb)
    local myIdentifier = SV.getIdentifier(xPlayer);
    local characterName = SV.getCharacterName(xPlayer);
    
<strong>    local it_vin_plate = exports["IT_Licenseplate"]:GenerateRandomVIN()
</strong>
    -- Garages:
    local vmsGaragesV2 = GetResourceState('vms_garagesv2') == 'started'
    local qsAdvancedGarages = GetResourceState('qs-advancedgarages') == 'started'

    -- Externals:
    local mInsurance = GetResourceState('m-Insurance') == 'started'
    local vmsCityhall = GetResourceState('vms_cityhall') == 'started'
    
<strong>    properties.plate = it_vin_plate
</strong>
    if Config.Core == "ESX" then
        if vmsGaragesV2 then
            local query = "INSERT INTO owned_vehicles (`owner`, `plate`, `vehicle`, `vin`, `netid`, `type`, `garage`) VALUES (@owner, @plate, @vehicle, @vin, @netid, @type, @garage)"
            if vmsCityhall then
                query = "INSERT INTO owned_vehicles (`owner`, `owner_history`, `plate`, `vehicle`, `vin`, `netid`, `type`, `garage`) VALUES (@owner, @owner_history, @plate, @vehicle, @vin, @netid, @type, @garage)"
            end

            MySQL.Async.execute(query, {
                ['@owner'] = myIdentifier, 
<strong>                ['@plate'] = it_vin_plate, 
</strong>                ['@owner_history'] = json.encode({{name=characterName, from=tostring(os.time()), to="current", price = price}}), 
                ['@vin'] = SV.createVIN(),
                ['@netid'] = netId,
                ['@vehicle'] = json.encode(properties), 
                ['@type'] = vehicleType,
                ['@garage'] = not spawnOnPurchase and 'Impound1' or nil,
            })
        elseif qsAdvancedGarages then
            local query = "INSERT INTO owned_vehicles (`owner`, `plate`, `vehicle`, `type`, `garage`, `stored`) VALUES (@owner, @plate, @vehicle, @type, @garage, @stored)"
            if vmsCityhall then
                query = "INSERT INTO owned_vehicles (`owner`, `plate`, `owner_history`, `vin`, `vehicle`, `type`, `garage`, `stored`) VALUES (@owner, @plate, @owner_history, @vin, @vehicle, @type, @garage, @stored)"
            end

            MySQL.Async.execute(query, {
                ['@owner'] = myIdentifier, 
<strong>                ['@plate'] = it_vin_plate, 
</strong>                ['@owner_history'] = json.encode({{name=characterName, from=tostring(os.time()), to="current", price = price}}), 
                ['@vin'] = vmsCityhall and SV.createVIN() or nil,
                ['@vehicle'] = json.encode(properties), 
                ['@type'] = vehicleType,
                ['@garage'] = not spawnOnPurchase and 'Impound1' or nil,
                ['@stored'] = not spawnOnPurchase and 1 or 0,
            })
        else
            local query = 'INSERT INTO owned_vehicles (`owner`, `plate`, `vehicle`, `type`, `stored`) VALUES (@owner, @plate, @vehicle, @type, @stored)'
            if vmsCityhall then
                query = "INSERT INTO owned_vehicles (`owner`, `plate`, `owner_history`, `vin`, `vehicle`, `type`, `stored`) VALUES (@owner, @plate, @owner_history, @vin, @vehicle, @type, @stored)"
            end
            
            MySQL.Async.execute(query, {
                ['@owner'] = myIdentifier, 
<strong>                ['@plate'] = it_vin_plate, 
</strong>                ['@owner_history'] = json.encode({{name=characterName, from=tostring(os.time()), to="current", price = price}}), 
                ['@vin'] = vmsCityhall and SV.createVIN() or nil,
                ['@vehicle'] = json.encode(properties), 
                ['@type'] = vehicleType,
                ['@stored'] = not spawnOnPurchase and 1 or 0,
            })
        end

        if mInsurance then
            MySQL.Async.execute('INSERT INTO m_insurance_registration (plate, model, registration, identifier) VALUES (?, ?, ?, ?)', {licensePlate, model, 1, myIdentifier})
        end

        cb(true)
    elseif Config.Core == "QB-Core" then
        if vmsGaragesV2 then
            local query = 'INSERT INTO player_vehicles (`license`, `citizenid`, `vehicle`, `hash`, `mods`, `plate`, `vin`, `netid`, `garage`, `type`) VALUES (@license, @citizenid, @vehicle, @hash, @mods, @plate, @vin, @netid, @garage, @type)'
            if vmsCityhall then
                query = "INSERT INTO player_vehicles (`license`, `citizenid`, `owner_history`, `vehicle`, `hash`, `mods`, `plate`, `vin`, `netid`, `garage`, `type`) VALUES (@license, @citizenid, @owner_history, @vehicle, @hash, @mods, @plate, @vin, @netid, @garage, @type)"
            end
            
            MySQL.Async.execute(query, {
                ['@license'] = xPlayer.PlayerData.license,
                ['@citizenid'] = myIdentifier,
                ['@owner_history'] = json.encode({{name=characterName, from=tostring(os.time()), to="current", price = price}}), 
                ['@vehicle'] = model,
                ['@hash'] = properties.model,
                ['@mods'] = json.encode(properties),
<strong>                ['@plate'] = it_vin_plate,
</strong>                ['@vin'] = SV.createVIN(),
                ['@netid'] = netId,
                ['@garage'] = not spawnOnPurchase and 'Impound1' or nil,
                ['@type'] = vehicleType,
            })
        elseif qsAdvancedGarages then
            local query = 'INSERT INTO player_vehicles (`license`, `citizenid`, `vehicle`, `hash`, `mods`, `plate`, `garage`, `type`) VALUES (@license, @citizenid, @vehicle, @hash, @mods, @plate, @garage, @type)'
            if vmsCityhall then
                query = "INSERT INTO player_vehicles (`license`, `citizenid`, `owner_history`, `vin`, `vehicle`, `hash`, `mods`, `plate`, `garage`, `type`) VALUES (@license, @citizenid, @owner_history, @vin, @vehicle, @hash, @mods, @plate, @garage, @type)"
            end
            
            MySQL.Async.execute(query, {
                ['@license'] = xPlayer.PlayerData.license,
                ['@citizenid'] = myIdentifier,
                ['@owner_history'] = json.encode({{name=characterName, from=tostring(os.time()), to="current", price = price}}), 
                ['@vin'] = vmsCityhall and SV.createVIN() or nil,
                ['@vehicle'] = model,
                ['@hash'] = properties.model,
                ['@mods'] = json.encode(properties),
<strong>                ['@plate'] = it_vin_plate,
</strong>                ['@garage'] = spawnOnPurchase and 'OUT' or '',
                ['@type'] = vehicleType,
            })
        else
            local query = 'INSERT INTO player_vehicles (`license`, `citizenid`, `vehicle`, `hash`, `mods`, `plate`, `garage`, `state`) VALUES (@license, @citizenid, @vehicle, @hash, @mods, @plate, @garage, @state)'
            if vmsCityhall then
                query = "INSERT INTO player_vehicles (`license`, `citizenid`, `owner_history`, `vin`, `vehicle`, `hash`, `mods`, `plate`, `garage`, `state`) VALUES (@license, @citizenid, @owner_history, @vin, @vehicle, @hash, @mods, @plate, @garage, @state)"
            end

            MySQL.Async.execute(query, {
                ['@license'] = xPlayer.PlayerData.license,
                ['@citizenid'] = myIdentifier,
                ['@owner_history'] = json.encode({{name=characterName, from=tostring(os.time()), to="current", price = price}}), 
                ['@vin'] = vmsCityhall and SV.createVIN() or nil,
                ['@vehicle'] = model,
                ['@hash'] = properties.model,
                ['@mods'] = json.encode(properties),
<strong>                ['@plate'] = it_vin_plate,
</strong>                ['@garage'] = spawnOnPurchase and 'OUT' or '',
                ['@state'] = not spawnOnPurchase and 1 or 0,
            })
        end

        if mInsurance then
            MySQL.Async.execute('INSERT INTO m_insurance_registration (plate, model, registration, identifier) VALUES (?, ?, ?, ?)', {licensePlate, model, 1, myIdentifier})
        end

        cb(true)
    end
end
</code></pre>

{% endtab %}

{% tab title="jg\_dealership" %}
Link zum Fahrzeughändler: [jg\_dealership](https://jgscripts.com/scripts/dealerships)

Gehe in folgende Datei:

```lua
JG_Dealership/framework/sv-functions.lua
```

Gehe in folgende Funktion:

```lua
function Framework.Server.VehicleGeneratePlate(seed, checkIfExists)
  seed = seed or "1AA111AA"

  local CHARSET_NUMBERS, CHARSET_LETTERS = "0123456789", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  local attempts = 0

  while attempts < 20 do
    local i, plate = 0, ""

    while i <= seed:len() do
      local char = seed:sub(i, i)

      if char == "A" then
        local randLetterPos = math.random(1, #CHARSET_LETTERS)
        local randLetter = CHARSET_LETTERS:sub(randLetterPos, randLetterPos)
        plate = plate .. randLetter
      elseif char == "1" then
        local randNumberPos = math.random(1, #CHARSET_NUMBERS)
        local randNumber = CHARSET_NUMBERS:sub(randNumberPos, randNumberPos)
        plate = plate .. randNumber
      elseif char == "^" then
        i = i + 1
        if i <= seed:len() then plate = plate .. seed:sub(i, i) end
      else
        plate = plate .. char
      end

      i = i + 1
    end

    plate = plate:upper()

    if plate:len() > 8 then
      error("^1[ERROR] You are generating a plate with more than 8 characters.")
      return false
    end

    if not checkIfExists then
      return plate
    end

    local result = MySQL.scalar.await("SELECT plate FROM " .. Framework.VehiclesTable .. " WHERE plate = ?", {plate})
    if not result then return plate end

    attempts = attempts + 1
  end

  return false
end
```

Ändere sie folgendermaßen ab:

<pre class="language-lua"><code class="lang-lua">function Framework.Server.VehicleGeneratePlate(seed, checkIfExists)
  seed = seed or "1AA111AA"

  local CHARSET_NUMBERS, CHARSET_LETTERS = "0123456789", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  local attempts = 0

  while attempts &#x3C; 20 do
    local i, plate = 0, ""

    while i &#x3C;= seed:len() do
      local char = seed:sub(i, i)

      if char == "A" then
        local randLetterPos = math.random(1, #CHARSET_LETTERS)
        local randLetter = CHARSET_LETTERS:sub(randLetterPos, randLetterPos)
        plate = plate .. randLetter
      elseif char == "1" then
        local randNumberPos = math.random(1, #CHARSET_NUMBERS)
        local randNumber = CHARSET_NUMBERS:sub(randNumberPos, randNumberPos)
        plate = plate .. randNumber
      elseif char == "^" then
        i = i + 1
        if i &#x3C;= seed:len() then plate = plate .. seed:sub(i, i) end
      else
        plate = plate .. char
      end

      i = i + 1
    end
<strong>    local vin = exports["IT_Licenseplate"]:GenerateRandomVIN()
</strong>
<strong>    plate = vin
</strong>
    if plate:len() > 8 then
      error("^1[ERROR] You are generating a plate with more than 8 characters.")
      return false
    end

    if not checkIfExists then
      return plate
    end

    local result = MySQL.scalar.await("SELECT plate FROM " .. Framework.VehiclesTable .. " WHERE plate = ?", {plate})
    if not result then return plate end

    attempts = attempts + 1
  end

  return false
end
</code></pre>

{% endtab %}
{% endtabs %}

## TÜV vergeben nach dem Kauf

Es gibt ein Export für Server- und Clientside, damit ein Fahrzeug direkt nach dem Kauf automatisch TÜV hat. Das ganze ist für Neuwagen gedacht.

```lua
exports["IT_TechnicalInspection"]:GiveTUEV(plate, {monthadd, yearsadd})
```

monthadd = number, yearadd = number, plate/VIN = GTA-Kennzeichen!

Es soll eine Nummer angegeben werden, um wie viele Monate oder Jahre der TÜV erstellt werden soll. Das System fügt das auf den aktuellen Tag hinzu.

Beispiel 1:&#x20;

Am 01.04.2026 wird das System so ausgefüllt:

```lua
exports["IT_TechnicalInspection"]:GiveTUEV(GH25NS21, {5, 1})
```

Dann hat das Auto TÜV bis zum 01.09.2027

Beispiel 2:

Am 15.04.2026 wird das System so ausgefüllt:

```lua
exports["IT_TechnicalInspection"]:GiveTUEV(GH25NS21, {10, 1})
```

Dann hat das Auto TÜV bis zum 01.02.2028


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://meadow-development.gitbook.io/meadow-development-docs/skripte/it_licenseplate/vehicleshop-verbinden.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
