qb-spawn
Integration for housing for qb-spawn
Client
Create variable apartment
local Apartments = {}
Comment this part
-- RegisterNetEvent('qb-houses:client:setHouseConfig', function(houseConfig)
-- Houses = houseConfig
-- end)
Find:
RegisterNetEvent('qb-spawn:client:setupSpawns', function(cData, new, apps)
if not new then
QBCore.Functions.TriggerCallback('qb-spawn:server:getOwnedHouses', function(houses)
local myHouses = {}
if houses ~= nil then
for i = 1, (#houses), 1 do
myHouses[#myHouses+1] = {
house = houses[i].house,
label = Houses[houses[i].house].adress,
}
end
end
Wait(500)
SendNUIMessage({
action = "setupLocations",
locations = QB.Spawns,
houses = myHouses,
isNew = new
})
end, cData.citizenid)
elseif new then
SendNUIMessage({
action = "setupAppartements",
locations = apps,
isNew = new
})
end
end)
Replace:
RegisterNetEvent('qb-spawn:client:setupSpawns', function(cData, new, apps)
if not new then
QBCore.Functions.TriggerCallback('qb-spawn:server:getOwnedHouses', function(houses)
local myHouses = {}
if houses ~= nil then
for i = 1, (#houses), 1 do
Houses[houses[i].identifier] = houses[i]
myHouses[#myHouses + 1] = {
house = houses[i].identifier,
label = houses[i].name,
}
end
end
for i = 1, #apps, 1 do
Houses[apps[i].identifier] = {
entry = apps[i].entry,
}
myHouses[#myHouses + 1] = {
house = apps[i].identifier,
label = apps[i].name,
}
end
Wait(500)
SendNUIMessage({
action = "setupLocations",
locations = QB.Spawns,
houses = myHouses,
isNew = new
})
end, cData.citizenid)
elseif new then
SendNUIMessage({
action = "setupAppartements",
locations = apps,
isNew = new
})
end
end)
Find: RegisterNUICallback('setCam', function(data,cb)
elseif type == "house" then
SetCam(Houses[location].coords.enter)
elseif type == "normal" then
SetCam(QB.Spawns[location].coords)
elseif type == "appartment" then
SetCam(Apartments.Locations[location].coords.enter)
Replace:
elseif type == "house" then
SetCam(Houses[location].entry)
elseif type == "normal" then
SetCam(QB.Spawns[location].coords)
elseif type == "appartment" then
if not Apartments[location] then
Apartments[location] = exports.bcs_housing:GetHome(location)
SetCam(Apartments[location].entry or Apartments[location].properties.entry)
else
SetCam(Apartments[location].entry or Apartments[location].properties.entry)
end
end
Find:
TriggerEvent('qb-houses:client:enterOwnedHouse', location)
Replace:
if Houses[location].type ~= 'mlo' then
TriggerEvent('Housing:client:EnterHome', location)
else
SetEntityCoords(ped, Houses[location].entry.x, Houses[location].entry.y, Houses[location].entry.z)
end
Find:
TriggerServerEvent("apartments:server:CreateApartment", appaYeet)
Replace:
TriggerServerEvent('Housing:server:CreateApartment', appaYeet)
Server
qb-spawn/server.lua
QBCore.Functions.CreateCallback('qb-spawn:server:getOwnedHouses', function(_, cb, cid)
if cid ~= nil then
local houses = exports['bcs_housing']:GetOwnedHomeKeys(cid)
if houses[1] ~= nil then
cb(houses)
else
cb({})
end
else
cb({})
end
end)
index.html
Replace
qb-spawn/html/index.html
click_location: function(type, name) {
if (type == "normal") {
axios.post('https://qb-spawn/setCam', {
posname: name,
type: type,
});
}
this.selectedValue = {type: type, name: name}
},
With
qb-spawn/html/index.html
click_location: function(type, name) {
if (type == "normal" || type == "house" || type == "appartment") {
axios.post('https://qb-spawn/setCam', {
posname: name,
type: type,
});
}
this.selectedValue = {type: type, name: name}
},