qb-garages

  1. Navigate to the qb-garages/client/main.lua

  2. Find the qb-garages:client:setHouseGarage event and replace:

RegisterNetEvent('qb-garages:client:setHouseGarage', function(house) -- event sent periodically from housing
    if not house then return end
    local formattedHouseName = string.gsub(string.lower(house), ' ', '')
    local zoneName = 'house_' .. formattedHouseName
    local hasKey = exports['vms_housing']:HasPermissions(house, 'garage')
    
    if Config.Garages[formattedHouseName] then
        if hasKey and not ZoneExists(zoneName) then
            CreateHouseZone(formattedHouseName, Config.Garages[formattedHouseName], 'house')
        elseif not hasKey and ZoneExists(zoneName) then
            RemoveHouseZone(zoneName)
        end
    else
        if not hasKey then
            return
        end
        local property = exports['vms_housing']:GetProperty(house)
        if not property or not property.metadata or not property.metadata.garage then return end
        local garageCoords = property.metadata.garage
        Config.Garages[formattedHouseName] = {
            houseName = house,
            takeVehicle = vector3(garageCoords.x, garageCoords.y, garageCoords.z),
            spawnPoint = {
                vector4(garageCoords.x, garageCoords.y, garageCoords.z, garageCoords.w)
            },
            label = property.name,
            type = 'house',
            category = Config.VehicleClass['all']
        }
        CreateHouseZone(formattedHouseName, Config.Garages[formattedHouseName], 'house')
    end
end)

  1. Navigate to the qb-garages/server/main.lua

  2. Find the qb-garages:server:getHouseGarage callback and replace:

QBCore.Functions.CreateCallback('qb-garages:server:getHouseGarage', function(_, cb, house)
    local property = exports['vms_housing']:GetProperty(house)
    cb(property)
end)

  1. Find the qb-garages:server:GetGarageVehicles callback and replace:

QBCore.Functions.CreateCallback('qb-garages:server:GetGarageVehicles', function(source, cb, garage, type, category)
    local Player = QBCore.Functions.GetPlayer(source)
    if not Player then return end
    local citizenId = Player.PlayerData.citizenid

    local vehicles
    if type == 'depot' then
        vehicles = MySQL.rawExecute.await('SELECT * FROM player_vehicles WHERE citizenid = ? AND depotprice > 0', { citizenId })
    elseif type == 'house' then
        vehicles = MySQL.rawExecute.await('SELECT * FROM player_vehicles WHERE garage = ?', { garage })
    elseif Config.SharedGarages then
        vehicles = MySQL.rawExecute.await('SELECT * FROM player_vehicles WHERE citizenid = ?', { citizenId })
    else
        vehicles = MySQL.rawExecute.await('SELECT * FROM player_vehicles WHERE citizenid = ? AND garage = ?', { citizenId, garage })
    end
    if #vehicles == 0 then
        cb(nil)
        return
    end
    if Config.ClassSystem then
        local filteredVehicles = filterVehiclesByCategory(vehicles, category)
        cb(filteredVehicles)
    else
        cb(vehicles)
    end
end)

  1. Find the qb-garages:server:canDeposit callback and replace:

QBCore.Functions.CreateCallback('qb-garages:server:canDeposit', function(source, cb, plate, type, garage, state, propertyId)
    local Player = QBCore.Functions.GetPlayer(source)
    local isOwned = MySQL.scalar.await('SELECT citizenid FROM player_vehicles WHERE plate = ? LIMIT 1', { plate })
    if isOwned ~= Player.PlayerData.citizenid and type ~= 'house' then
        cb(false)
        return
    end
    if state == 1 then
        MySQL.update('UPDATE player_vehicles SET state = ?, garage = ? WHERE plate = ?', { state, garage, plate })
        cb(true)
    else
        cb(false)
    end
end)

Last updated

Was this helpful?