# qb-phone support

1. Navigate to **qb-phone/fxmanifest.lua** and replace:

```lua
shared_scripts {
    'config.lua',
    '@qb-apartments/config.lua',
    '@qb-garages/config.lua',
}
```

With:

```lua
shared_scripts {
    'config.lua',
    '@qb-apartments/config.lua',
}
```

2. Then, on **qb-phone/server/main.lua,** around the line **230,** replace:

```lua
if garageresult[1] ~= nil then
    for _, v in pairs(garageresult) do
        local vehicleModel = v.vehicle
        if (QBCore.Shared.Vehicles[vehicleModel] ~= nil) and (Config.Garages[v.garage] ~= nil) then
            v.garage = Config.Garages[v.garage].label
            v.vehicle = QBCore.Shared.Vehicles[vehicleModel].name
            v.brand = QBCore.Shared.Vehicles[vehicleModel].brand
        end

    end
    PhoneData.Garage = garageresult
end
```

With:

```lua
if garageresult[1] ~= nil then
    for _, v in pairs(garageresult) do
        local vehicleModel = v.vehicle
        if (QBCore.Shared.Vehicles[vehicleModel] ~= nil) then
            v.garage = v.garage
            v.vehicle = QBCore.Shared.Vehicles[vehicleModel].name
            v.brand = QBCore.Shared.Vehicles[vehicleModel].brand
        end

    end
    PhoneData.Garage = garageresult
end
```

3. Now, go to **qb-phone/client/main.lua** and replace the code around the line **302**:

```lua
QBCore.Functions.TriggerCallback('qb-garage:server:GetPlayerVehicles', function(vehicles)
```

With:

```lua
QBCore.Functions.TriggerCallback('okokGarage:GetPlayerVehicles', function(vehicles)
```

4. Then, on **okokGarage/sv\_utils.lua,** around the line **348**, before the `function tablelength(T)` add:

```lua
QBCore.Functions.CreateCallback('okokGarage:GetPlayerVehicles', function(source, cb)
    local Player = QBCore.Functions.GetPlayer(source)
    local Vehicles = {}

    MySQL.query('SELECT * FROM player_vehicles WHERE citizenid = ?', {Player.PlayerData.citizenid}, function(result)
        if result[1] then
            for _, v in pairs(result) do
                local VehicleData = QBCore.Shared.Vehicles[v.vehicle]
                local VehicleGarage = "No garage"
                local garageConfig = nil
                
                for _, garage in pairs(Config.Garages) do
                    if garage.id == v.garage then
                        garageConfig = garage
                        break
                    end
                end
                
                if garageConfig ~= nil then
                    VehicleGarage = garageConfig.name
                else
                    VehicleGarage = "Unknown"
                end

                if v.state == 0 then
                    v.state = "Outside"
                elseif v.state == 1 then
                    v.state = "Garaged"
                elseif v.state == 2 then
                    v.state = "Impounded"
                end

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


---

# 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.okokscripts.io/scripts/okokgarage/qb-phone-support.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.
