qbx_properties & nolag_properties
local function isResourceStarted(resourceName)
return GetResourceState(resourceName) == 'started'
end
Property = {
---@param stateid string
---@return table A list of properties with keys: value, label, coords<optional>
GetPlayerProperties = function(stateid)
local properties = {}
-- Check for qbx_properties
if isResourceStarted('qbx_properties') then
local result = MySQL.query.await(
[[
SELECT
id as value,
property_name as label,
coords
FROM
properties
WHERE
owner = ?
]], { stateid }
)
if result and #result > 0 then
for _, property in ipairs(result) do
local coords = json.decode(property.coords)
property.coords = { x = coords.x, y = coords.y }
table.insert(properties, property)
end
else
prints.error('No properties found in qbx_properties for stateid: %s', stateid)
end
end
-- Check for nolag_properties
if isResourceStarted('nolag_properties') then
local result = exports.nolag_properties:GetAllProperties(stateid, 'user', true)
if result and next(result) ~= nil then
for _, property in pairs(result) do
property.value = property.id
table.insert(properties, property)
end
else
prints.error('No properties found in nolag_properties for stateid: %s', stateid)
end
end
return properties
end
}
Last updated
Was this helpful?