🎉 Driving School is released. Read more →
Paid Scripts
Housing
Integrations
Spawn Selector Scripts
Qbx Spawn

qbx_spawn

Integration for housing for qbx_spawn

Find: qbx_spawn:server:getProperties

lib.callback.register('qbx_spawn:server:getProperties', function(source)
    local player = exports.qbx_core:GetPlayer(source)
    local houseData = {}
    local properties = MySQL.query.await('SELECT id, property_name, coords FROM properties WHERE owner = ?', {player.PlayerData.citizenid})
    for i = 1, #properties do
        local property = properties[i]
        houseData[#houseData + 1] = {
            label = property.property_name,
            coords = json.decode(property.coords),
            propertyId = property.id,
        }
    end
 
    return houseData
end)

Replace:

lib.callback.register('qbx_spawn:server:getProperties', function(source)
    local player = exports.qbx_core:GetPlayer(source)
    local houseData = {}
    local playerHouses = exports.bcs_housing:GetOwnedHomeKeys(player.PlayerData.citizenid)
    for i = 1, #playerHouses do
        local house = playerHouses[i]
        local entry = house.entry
        houseData[#houseData + 1] = {
            label = house.name,
            coords = vec4(entry.x, entry.y, entry.z, entry.w),
            propertyId = house.identifier
        }
    end
    return houseData
end)

Find:

    if spawnData.propertyId then
        TriggerServerEvent('qbx_properties:server:enterProperty', { id = spawnData.propertyId, isSpawn = true })

Replace:

    if spawnData.propertyId then
        TriggerEvent('Housing:client:EnterHome', spawnData.propertyId)

Follow this to using Starter Apartment (opens in a new tab)

Delete qbx_properties, add provide 'qb-spawn' to qbx_spawn/fxmaniest.lua

Find: AddEventHandler('qb-spawn:client:setupSpawns', function()

    AddEventHandler('qb-spawn:client:setupSpawns', function()
        spawns = {}
 
        local lastCoords, lastPropertyId = lib.callback.await('qbx_spawn:server:getLastLocation')
            spawns[#spawns + 1] = {
            label = locale('last_location'),
            coords = lastCoords,
            propertyId = lastPropertyId
        }
 
        for i = 1, #config.spawns do
            spawns[#spawns + 1] = config.spawns[i]
        end
 
        local properties = lib.callback.await('qbx_spawn:server:getProperties')
        for i = 1, #properties do
            spawns[#spawns + 1] = properties[i]
        end
 
        Wait(400)
 
        managePlayer()
        setupCamera()
        setupMap()
 
        Wait(400)
 
        scaleformDetails(currentButtonID)
        inputHandler()
    end)

Replace:

AddEventHandler('qb-spawn:client:setupSpawns', function(_, new, appartments)
    spawns = {}
 
    if new then
        for k, v in pairs(appartments) do
            local home = exports.bcs_housing:GetHome(k)
            local entry = home.entry or home.properties.entry
            spawns[#spawns + 1] = {
                propertyId = k,
                label = v.name,
                coords = vec4(entry.x, entry.y, entry.z, entry.w),
                appartment = true
            }
        end
    else
        local lastCoords, lastPropertyId = lib.callback.await('qbx_spawn:server:getLastLocation')
        spawns[#spawns + 1] = {
            label = locale('last_location'),
            coords = lastCoords,
            propertyId = lastPropertyId
        }
 
        for i = 1, #config.spawns do
            spawns[#spawns + 1] = config.spawns[i]
        end
 
        local properties = lib.callback.await('qbx_spawn:server:getProperties')
        for i = 1, #properties do
            spawns[#spawns + 1] = properties[i]
        end
    end
 
    Wait(400)
 
    managePlayer()
    setupCamera()
    setupMap()
 
    Wait(400)
 
    scaleformDetails(currentButtonID)
    inputHandler()
end)

Find:

    if spawnData.propertyId then
        TriggerEvent('Housing:client:EnterHome', spawnData.propertyId)

Replace:

    if spawnData.propertyId then
        if spawnData.appartment then
            TriggerServerEvent('Housing:server:CreateApartment', spawnData.propertyId)
        else
            TriggerEvent('Housing:client:EnterHome', spawnData.propertyId)
        end

Find:

qbx_core/client/character.lua
    elseif GetResourceState('qbx_spawn'):find('start') then
        TriggerEvent('qb-spawn:client:setupSpawns', character.citizenid)
        TriggerEvent('qb-spawn:client:openUI', true)

Replace:

    elseif GetResourceState('qbx_spawn'):find('start') then
        TriggerEvent('Housing:client:SetupSpawnUI', character)