# QBCore

### qb-core

{% stepper %}
{% step %}

#### **Has Keys Check**

Vew the code on GitHub: [qb-core/client/events.lua](https://github.com/qbcore-framework/qb-core/blob/b6249c3783ccf9d18bf6487dad2bea0f87934f8e/client/events.lua#L165)

REPLACE the line’s of code exactly as seen in the screenshot below.

{% code title="qb-core/client/events.lua — line 165" %}

```lua
if GetResourceState('cd_garage') == 'started' and plate then
    hasKeys = exports['cd_garage']:DoesPlayerHaveKeys(plate)
end
```

{% endcode %}

<figure><img src="/files/k2G3gHtbUT6ue9r7pjX4" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Remove Persistent Vehicle

View the code on GitHub: [qb-core/client/functions.lua](https://github.com/qbcore-framework/qb-core/blob/b6249c3783ccf9d18bf6487dad2bea0f87934f8e/client/functions.lua#L385)

Add the line of code exactly as seen in the screenshot below.

{% code title="qb-core/client/functions.lua — line 385" %}

```lua
TriggerServerEvent('cd_garage:RemovePersistentVehicles', exports['cd_garage']:GetPlate(vehicle))
```

{% endcode %}

<figure><img src="/files/MMGdlNR4H7TFxBeNvbXk" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

***

### qb-vehicleshop

{% stepper %}
{% step %}
**Update Garage Type**

View the code on GitHub: [qb-vehicleshop/client/main.lua](https://github.com/qbcore-framework/qb-vehicleshop/blob/6fddc5bc25d6b52eaee29d233d0e1c6652b99490/client.lua#L657)

Add the line of code exactly as seen in the screenshot below.

{% code title="qb-vehicleshop/client/main.lua — line 657" %}

```lua
TriggerEvent('cd_garage:UpdateGarageType')
```

{% endcode %}

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

{% hint style="info" %}

#### **Do vehicles still respawn when deleting them?**

If vehicles still respawn when deleting them, most likely, one of your resources does not use the QBCore delete vehicle function, so you will need to refer to [#P](https://docs.codesign.pro/paid-scripts/garage#vehicle-keys)[ersistentVehicles](https://docs.codesign.pro/paid-scripts/garage#persistent-vehicles) and add the event to that resource.
{% endhint %}
{% endstep %}
{% endstepper %}

***

### qb-phone

{% stepper %}
{% step %}
**Garage App**

View the code on GitHub: [qb-phone/server/main.lua](https://github.com/qbcore-framework/qb-phone/blob/1ae3374f96971a5ae7df0665b59c445ebf18f6a3/server/main.lua#L234)

REPLACE the line’s of code exactly as seen in the screenshot below.

{% code title="qb-phone/server/main.lua — line 234" %}

```lua
v.garage = v.garage_id
```

{% endcode %}

<figure><img src="/files/fyr5t4XPcm1WYAnq1Jbl" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

***

### qb-phone (renewed)

{% stepper %}
{% step %}
**Garage App**

View the code on GitHub: [qb-phone/server/garage.lua](https://github.com/Renewed-Scripts/qb-phone/blob/7004231ac178a455de9d551bcd7215c14b337cbb/server/garage.lua#L45)

Replace this whole function.

{% code title="qb-phone/server/garage.lua — line 45" lineNumbers="true" %}

```lua
QBCore.Functions.CreateCallback('qb-phone:server:GetGarageVehicles', function(source, cb)
    local Player = QBCore.Functions.GetPlayer(source)
    local Vehicles = {}
    local vehdata
    local result = exports.oxmysql:executeSync('SELECT * FROM player_vehicles WHERE citizenid = ?', {Player.PlayerData.citizenid})
    if result[1] then
        for _, v in pairs(result) do
            local VehicleData = QBCore.Shared.Vehicles[v.vehicle]
            local VehicleGarage = "None"
            local enginePercent = round(v.engine / 10, 0)
            local bodyPercent = round(v.body / 10, 0)
            VehicleGarage = v.garage_id

            local VehicleState = "In"
            if v.in_garage ~= true then
                VehicleState = "Out"
            end
            if v.impound ~= 0 then
                VehicleState = "Impounded"
            end

            if VehicleData["brand"] then
                vehdata = {
                    fullname = VehicleData["brand"] .. " " .. VehicleData["name"],
                    brand = VehicleData["brand"],
                    model = VehicleData["name"],
                    plate = v.plate,
                    garage = VehicleGarage,
                    state = VehicleState,
                    fuel = v.fuel,
                    engine = enginePercent,
                    body = bodyPercent,
                    paymentsleft = v.paymentsleft
                }
            else
                vehdata = {
                    fullname = VehicleData["name"],
                    brand = VehicleData["name"],
                    model = VehicleData["name"],
                    plate = v.plate,
                    garage = VehicleGarage,
                    state = VehicleState,
                    fuel = v.fuel,
                    engine = enginePercent,
                    body = bodyPercent,
                    paymentsleft = v.paymentsleft
                }
            end
            Vehicles[#Vehicles+1] = vehdata
        end
        cb(Vehicles)
    else
        cb(nil)
    end
end)
```

{% endcode %}
{% endstep %}
{% endstepper %}


---

# 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://docs.codesign.pro/paid-scripts/garage/resource-integration/qbcore.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.
