Full View config.server.lua
Preview File Updated: v1.0.4 - 14.01.2024
getHousings = function(source, cb)
local xPlayer = Config.Core == "ESX" and ESX.GetPlayerFromId(source) or QBCore.Functions.GetPlayer(source)
local myIdentifier = Config.Core == "ESX" and xPlayer.identifier or xPlayer.PlayerData.citizenid
if GetResourceState('esx_property') == 'started' then
local propertiesList = LoadResourceFile('esx_property', 'properties.json')
if propertiesList then
local allHouses = json.decode(propertiesList)
local myHouses = {}
for k, v in pairs(allHouses) do
if v.Owner == myIdentifier then
myHouses[#myHouses + 1] = {
label = v.Name,
coords = v.Entrance
}
end
end
if myHouses[1] then
cb(true, myHouses)
else
cb(nil)
end
end
elseif GetResourceState('qs-housing') == 'started' then
local allHouses = MySQL.query.await('SELECT * FROM houselocations')
if allHouses[1] then
local listedHouses = {}
for k, v in pairs(allHouses) do
listedHouses[v.name] = {
label = v.label,
coords = json.decode(v.coords).enter
}
end
local myHouses = MySQL.query.await('SELECT * FROM player_houses WHERE identifier = ?', {myIdentifier})
if myHouses[1] ~= nil then
cb(listedHouses, myHouses)
else
cb(nil)
end
else
cb(nil)
end
elseif GetResourceState('qb-houses') == 'started' then
local allHouses = MySQL.query.await('SELECT * FROM houselocations')
if allHouses[1] then
local listedHouses = {}
for k, v in pairs(allHouses) do
listedHouses[v.name] = {
label = v.label,
coords = json.decode(v.coords).enter
}
end
local myHouses = MySQL.query.await('SELECT * FROM player_houses WHERE citizenid = ?', {myIdentifier})
if myHouses[1] ~= nil then
cb(listedHouses, myHouses)
else
cb(nil)
end
else
cb(nil)
end
end
end
Last updated