# qb-apartments

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

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

Property = {

  ---@param stateid string
  ---@return table A list of properties with keys: value, label, coords<optional>
  GetPlayerProperties = function(stateid)
    local result = MySQL.single.await(
      'SELECT apartment FROM players WHERE citizenid = ?',
      { stateid }
    )

    if not result or not result.apartment then
      prints.error('Apartment not found for stateid: %s', stateid)
      return {}
    end

    local apartmentId = result.apartment
    local apartmentData = Apartments.Locations[apartmentId]

    if not apartmentData then
      prints.error('Apartment data not found for apartment ID: %s', apartmentId)
      return {}
    end

    local coords = apartmentData.coords and apartmentData.coords.enter
    local coordsTable = coords and { x = coords.x, y = coords.y } or nil

    return {
      {
        value = apartmentId,
        label = apartmentData.label or apartmentId,
        coords = coordsTable
      }
    }
  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/property/qb-apartments.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.
