# qs-smartphone

{% stepper %}
{% step %}

### Navigate to server editable garages folder

Create new file named: `op-garages.lua`
{% endstep %}

{% step %}

### Insert this data to the file:

```lua
if Config.Garage ~= 'op-garages' then
    return
end

RegisterNetEvent('phone:setVehicleToOutSide', function(plate)
    local str = [[
        UPDATE owned_vehicles
        SET stored = 1
        WHERE plate = ?
    ]]
    if Config.Framework == 'qb' then
        str = [[
            UPDATE player_vehicles
            SET state = 1
            WHERE plate = ?
        ]]
    end

    MySQL.Sync.execute(str, { plate })
end)

function getGarageData(identifier, plate)
    local str = [[
        SELECT * FROM owned_vehicles WHERE owner = ? AND (type = 'vehicle' OR type = 'car')
    ]]
    if Config.Framework == 'qb' then
        str = [[
            SELECT * FROM player_vehicles WHERE citizenid = ?
        ]]
    end
    if plate then
        str = str .. ([[
            AND plate = "%s"
        ]]):format(plate)
    end
    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 inGarage = true
            local garageId = v.vehicleGarage

            if v.state == 1 then
                inGarage = false
            end

            local garageObject = exports['op-garages']:getGarageByIndex(tostring(garageId))

            if garageObject then
                garageId = garageObject.Label
            end

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

            if v.stored == 1 then
                inGarage = false
            end

            local garageObject = exports['op-garages']:getGarageByIndex(tostring(garageId))

            if garageObject then
                garageId = garageObject.Label
            end

            if inGarage then
                table.insert(data, {
                    name = vehicle.model,
                    plate = v.plate,
                    inGarage = inGarage,
                    fuel = v.fuel * 10 or 1000,
                    engine = vehicle.engine or 1000,
                    body = vehicle.body or 1000,
                    vehicle = json.decode(v.vehicle),
                    garage = garageId,
                })
            end
        end
    end
    return data
end

```

{% endstep %}

{% step %}

### Restart Your server.

{% 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.otherplanet.dev/scripts/op-garages-v2/script-integrations/qs-smartphone.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.
