es_extended
if not GetResourceState('es_extended') == 'started' then return end
Framework = {
---@param source number
---@return string|nil
getIdentifierBySource = function(source)
if not source or type(source) ~= 'number' or not GetPlayerName(source) then
prints.error('Invalid source provided')
return nil
end
local xPlayer = ESX.GetPlayerFromId(source)
if not xPlayer then
prints.error('Player not found for source: %s', source)
return nil
end
local identifier = xPlayer.getIdentifier()
if not identifier then
prints.error('Identifier not found for player: %s', source)
return nil
end
return identifier
end,
---@param stateid string
---@return string
getPlayerGender = function(stateid)
local result = MySQL.single.await(
[[
SELECT
sex
FROM
users
WHERE
identifier = ?
]], { stateid }
)
if not result or not result.sex then
prints.error('Gender not found for stateid: %s', stateid)
return 'Unknown'
end
local gender = result.sex
if gender == 'm' or gender == 'M' then
return 'Male'
elseif gender == 'f' or gender == 'F' then
return 'Female'
else
prints.error('Invalid gender value for stateid: %s', stateid)
return 'Unknown'
end
end,
---@param stateid string
---@return table A list of jobs with keys: label, value, coords<optional>
getPlayerEmployment = function(stateid)
local result = MySQL.single.await(
[[
SELECT
job,
job_grade
FROM
users
WHERE
identifier = ?
]], { stateid }
)
if not result or not result.job then
prints.error('Employment not found for stateid: %s', stateid)
return {}
end
local jobLabel = result.job
local jobGrade = result.job_grade
return {
{
label = jobLabel,
value = tostring(jobGrade)
}
}
end
}
Last updated
Was this helpful?