# qs-smartphone-pro

1. Navigate to the path **qs-smartphone-pro/config/config.lua**
2. Find the `Config.Garage` option and customize:

```lua
Config.Garage = "vms_garagesv2"
```

3. Navigate to the **qs-smartphone-pro/server/custom/garage/**
4. Create file **vms\_garagesv2.lua** inside **qs-smartphone-pro/server/custom/garage/**
5. Paste the following code into the **qs-smartphone-pro/server/custom/garage/vms\_garagesv2.lua** file

{% file src="/files/VdYsir9NhAwZXWEMncRN" %}
**qs-smartphone-pro/server/custom/garage/vms\_garagesv2.lua**
{% endfile %}

<details>

<summary><strong>qs-smartphone-pro/server/custom/garage/vms_garagesv2.lua</strong></summary>

```lua
if Config.Garage ~= 'vms_garagesv2' then
    return
end

RegisterNetEvent('phone:setVehicleToOutSide', function(plate)
    local plate = plate
    
    local queryVehicleData = 'SELECT garage, garageSpotID FROM owned_vehicles WHERE plate = ? AND impound_data IS NULL AND impound_date IS NULL'
    if Config.Framework == 'qb' then
        queryVehicleData = 'SELECT garage, garageSpotID FROM player_vehicles WHERE plate = ? AND impound_data IS NULL AND impound_date IS NULL'
    end
    local vehicleData = MySQL.query.await(queryVehicleData, { plate })

    if vehicleData and vehicleData[1] then
        TriggerEvent('vms_garagesv2:vehicleTakenByPhone', vehicleData[1].garage, vehicleData[1].garageSpotID)
    end

    Citizen.CreateThread(function()
        Citizen.Wait(3000)
        local foundNetId = nil

        local allVehicles = GetAllVehicles()
        for i = 1, #allVehicles do
            if DoesEntityExist(allVehicles[i]) then
                local vehPlate = GetVehicleNumberPlateText(allVehicles[i])
                local cleanedPlate = vehPlate:match("^%s*(.-)%s*$")
                if cleanedPlate == plate then
                    foundNetId = NetworkGetNetworkIdFromEntity(allVehicles[i])
                    break
                end
            end
        end

        local str = [[
            UPDATE owned_vehicles
            SET garage = NULL, garageSpotID = NULL
        ]]
        if Config.Framework == 'qb' then
            str = [[
                UPDATE player_vehicles
                SET garage = NULL, garageSpotID = NULL
            ]]
        end

        if foundNetId then
            str = str .. ', netid = ? WHERE plate = ?'
            MySQL.Sync.execute(str, { foundNetId, plate })
        else
            str = str .. ' WHERE plate = ?'
            MySQL.Sync.execute(str, { plate })
        end
    end)
end)

function getGarageData(identifier, plate)
    local str = [[
        SELECT * FROM owned_vehicles WHERE owner = ? AND (type = 'vehicle' OR type = 'car') AND impound_data IS NULL AND impound_date IS NULL
    ]]
    if Config.Framework == 'qb' then
        str = [[
            SELECT * FROM player_vehicles WHERE citizenid = ? AND (type = 'vehicle' OR type = 'car') AND impound_data IS NULL AND impound_date IS NULL
        ]]
    end
    if plate then
        str = str .. ([[
            AND plate = "%s"
        ]]):format(plate)
    end
    print(str)
    local result = MySQL.Sync.fetchAll(str, { identifier })
    if not result[1] then
        return false
    end
    
    local data = {}
    if Config.Framework == 'qb' then
        for k, v in pairs(result) do
            local mods = json.decode(v.mods)
            if not mods then
                return
            end
            
            local inGarage = false
            local garageId = 'OUT'
            if v.garage then
                local label, coords = exports["vms_garagesv2"]:getGarageInfo(v.garage)
                inGarage = true
                garageId = label
            elseif v.impound then
                garageId = 'IMPOUND'
            end

            table.insert(data, {
                name = mods.model,
                plate = v.plate,
                inGarage = inGarage,
                fuel = mods.fuel or 1000,
                engine = mods.engine or 1000,
                body = mods.body or 1000,
                vehicle = mods,
                garage = garageId,
            })
        end
    else
        for k, v in pairs(result) do
            local vehicle = json.decode(v.vehicle)
            if not vehicle then
                return
            end

            local inGarage = false
            local garageId = 'OUT'
            print(v.garage)
            if v.garage then
                local label, coords = exports["vms_garagesv2"]:getGarageInfo(v.garage)
                inGarage = true
                garageId = label
            elseif v.impound then
                garageId = 'IMPOUND'
            end
            
            table.insert(data, {
                name = vehicle.model,
                plate = v.plate,
                inGarage = inGarage,
                fuel = vehicle.fuel or 1000,
                engine = vehicle.engine or 1000,
                body = vehicle.body or 1000,
                vehicle = vehicle,
                garage = garageId,
            })
        end
    end
    return data
end
```

</details>


---

# 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.vames-store.com/assets/vms_garagesv2/compatibility/phones/qs-smartphone-pro.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.
