# Garages

## qb-garages/server.lua

Search this:

```lua
QBCore.Functions.CreateCallback('qb-garage:server:spawnvehicle', function (source, cb, vehInfo, coords, warp)
    local plate = vehInfo.plate
    local veh = QBCore.Functions.SpawnVehicle(source, vehInfo.vehicle, coords, warp)
    SetEntityHeading(veh, coords.w)
    SetVehicleNumberPlateText(veh, plate)
    local vehProps = {}
    local result = MySQL.query.await('SELECT mods FROM player_vehicles WHERE plate = ?', {plate})
    if result[1] then vehProps = json.decode(result[1].mods) end
    local netId = NetworkGetNetworkIdFromEntity(veh)
    OutsideVehicles[plate] = {netID = netId, entity = veh}
    cb(netId, vehProps)
end)
```

Replace with:

```lua
QBCore.Functions.CreateCallback('qb-garage:server:spawnvehicle', function (source, cb, vehInfo, coords, warp)
    local plate = vehInfo.plate
    if exports['m-Impound_QB']:isVehicleSeized(plate) then
        TriggerClientEvent('QBCore:Notify', source, "Your vehicle is seized!", 'error')
        return
    else
        local veh = QBCore.Functions.SpawnVehicle(source, vehInfo.vehicle, coords, warp)
        SetEntityHeading(veh, coords.w)
        SetVehicleNumberPlateText(veh, plate)
        local vehProps = {}
        local result = MySQL.query.await('SELECT mods FROM player_vehicles WHERE plate = ?', {plate})
        if result[1] then vehProps = json.decode(result[1].mods) end
        local netId = NetworkGetNetworkIdFromEntity(veh)
        OutsideVehicles[plate] = {netID = netId, entity = veh}
        cb(netId, vehProps)
    end
end)
```

## okokGarage/sv\_utils.lua

Search this:

```lua
function takeOutVehicle(db, _source, vehicle_plate, vehicle_id, index, vehicle_name, garageName, isSociety)
    if db ~= nil and db.stored == 1 then
        local vehicle = db.mods
        local tyreCondition = db.tyrecondition
        local doorCondition = db.doorcondition
        local windowCondition = db.windowcondition
        MySQLexecute('UPDATE player_vehicles SET `state` = @state, `garage` = @stategarage WHERE plate = @plate', {
            ['@state'] = 0,
            ['@stategarage'] = garageName,
            ['@plate'] = vehicle_plate,
        }, function (rowsChanged)
            if rowsChanged > 0 then
                TriggerClientEvent(Config.EventPrefix..":takeOut", _source, vehicle, vehicle_plate, vehicle_id, tyreCondition, doorCondition, windowCondition, index)
                local xPlayer = QBCore.Functions.GetPlayer(_source)
                giveKeysToPlayer(_source, xPlayer.PlayerData.citizenid, vehicle_plate, vehicle_name, isSociety)
                if Webhook ~= "" then
                    data = {
                        playerid = _source,
                        type = "takeout-vehicle",
                        info = vehicle_plate:match( "^%s*(.-)%s*$" ),
                    }

                    discordWebhook(data)
                end
            end
        end)
    elseif db ~= nil and db.stored == 0 then
        TriggerClientEvent(Config.EventPrefix..":takeOutsideVehicle", _source, vehicle_plate)
        TriggerClientEvent(Config.EventPrefix..':notification', _source, _L('vehicle_isnt_stored').title, _L('vehicle_isnt_stored').text, _L('vehicle_isnt_stored').time, _L('vehicle_isnt_stored').type)
    elseif db ~= nil and db.stored == 2 then
        TriggerClientEvent(Config.EventPrefix..':notification', _source, _L('vehicle_is_impounded').title, _L('vehicle_is_impounded').text, _L('vehicle_is_impounded').time, _L('vehicle_is_impounded').type)
    elseif db ~= nil and db.stored == 3 then
        TriggerClientEvent(Config.EventPrefix..':notification', _source, _L('vehicle_is_stolen').title, _L('vehicle_is_stolen').text, _L('vehicle_is_stolen').time, _L('vehicle_is_stolen').type)
    end
end
```

Replace with this:

```lua
function takeOutVehicle(db, _source, vehicle_plate, vehicle_id, index, vehicle_name, garageName, isSociety)
    if exports['m-Impound_QB']:isVehicleSeized(plate) then
        TriggerClientEvent(Config.EventPrefix..':notification', _source, _L('vehicle_isnt_stored').title, "That vehicle has been seized!", 5000, "error")
        return
    else
        if db ~= nil and db.stored == 1 then
            local vehicle = db.mods
            local tyreCondition = db.tyrecondition
            local doorCondition = db.doorcondition
            local windowCondition = db.windowcondition
            MySQLexecute('UPDATE player_vehicles SET `state` = @state, `garage` = @stategarage WHERE plate = @plate', {
                ['@state'] = 0,
                ['@stategarage'] = garageName,
                ['@plate'] = vehicle_plate,
            }, function (rowsChanged)
                if rowsChanged > 0 then
                    TriggerClientEvent(Config.EventPrefix..":takeOut", _source, vehicle, vehicle_plate, vehicle_id, tyreCondition, doorCondition, windowCondition, index)
                    local xPlayer = QBCore.Functions.GetPlayer(_source)
                    giveKeysToPlayer(_source, xPlayer.PlayerData.citizenid, vehicle_plate, vehicle_name, isSociety)
                    if Webhook ~= "" then
                        data = {
                            playerid = _source,
                            type = "takeout-vehicle",
                            info = vehicle_plate:match( "^%s*(.-)%s*$" ),
                        }

                        discordWebhook(data)
                    end
                end
            end)
        elseif db ~= nil and db.stored == 0 then
            TriggerClientEvent(Config.EventPrefix..":takeOutsideVehicle", _source, vehicle_plate)
            TriggerClientEvent(Config.EventPrefix..':notification', _source, _L('vehicle_isnt_stored').title, _L('vehicle_isnt_stored').text, _L('vehicle_isnt_stored').time, _L('vehicle_isnt_stored').type)
        elseif db ~= nil and db.stored == 2 then
            TriggerClientEvent(Config.EventPrefix..':notification', _source, _L('vehicle_is_impounded').title, _L('vehicle_is_impounded').text, _L('vehicle_is_impounded').time, _L('vehicle_is_impounded').type)
        elseif db ~= nil and db.stored == 3 then
            TriggerClientEvent(Config.EventPrefix..':notification', _source, _L('vehicle_is_stolen').title, _L('vehicle_is_stolen').text, _L('vehicle_is_stolen').time, _L('vehicle_is_stolen').type)
        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://mscripts.gitbook.io/docs/qbcore/jobs/qb-impound/garages.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.
