# qb-core

```lua
if not GetResourceState('qb-core') == 'started' then return end

local QBCore = exports['qb-core']:GetCoreObject()

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 player = QBCore.Functions.GetPlayer(source)
    if not player then
      prints.error('Player not found for source: %s', source)
      return nil
    end

    local identifier = player.PlayerData.citizenid
    if not identifier then
      prints.error('Identifier not found for player: %s', player.PlayerData.citizenid)
      return nil
    end

    return identifier
  end,

  ---@param stateid string
  ---@return string
  getPlayerGender = function(stateid)
    local result = MySQL.single.await(
      [[
        SELECT
          JSON_UNQUOTE(JSON_EXTRACT(`charinfo`, '$.gender')) AS gender
        FROM
          `players`
        WHERE
          `citizenid` = ? 
      ]], { stateid }
    )

    if not result or not result.gender then
      prints.error('Gender not found for stateid: %s', stateid)
      return 'Unknown'
    end

    local gender = tonumber(result.gender)
    if gender == 0 then
      return 'Male'
    elseif gender == 1 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
          JSON_UNQUOTE(JSON_EXTRACT(`job`, '$.label')) AS label,
          JSON_UNQUOTE(JSON_EXTRACT(`job`, '$.grade.name')) AS value
        FROM
          `players`
        WHERE
          `citizenid` = ?
      ]], { stateid }
    )

    return { result }
  end
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.deltarix.store/paid-assets/mdt-v3/public/bridges/server/framework/qb-core.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
