> ## Documentation Index
> Fetch the complete documentation index at: https://docs.awokenlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Exports

> Programmatic access from other resources.

Awoken Apartments exposes a small set of server-side exports for cross-resource integration (typically MDT / dispatch / housing UI scripts).

<Note>
  There are no client-side exports.
</Note>

## Server exports

### `getPlayerRoom`

Returns the apartment a given player is currently assigned to.

```lua theme={"dark"}
local room = exports['awoken_apartments']:getPlayerRoom(src)
-- {
--     slotId     = 12,
--     groupId    = 'pink_cage',
--     groupLabel = 'Pink Cage Motel',
--     roomLabel  = 'Room 12',
-- }
-- OR nil if the player has no slot assigned
```

<ParamField path="src" type="number" required>
  Player server ID.
</ParamField>

<ResponseField name="slotId" type="number">
  The internal apartment slot index.
</ResponseField>

<ResponseField name="groupId" type="string">
  Motel group ID (matches a key in `Config.MotelGroups`). May be `nil` if the room isn't in a group.
</ResponseField>

<ResponseField name="groupLabel" type="string">
  Human-readable motel name (e.g., "Pink Cage Motel").
</ResponseField>

<ResponseField name="roomLabel" type="string">
  Human-readable room label (e.g., "Room 12").
</ResponseField>

***

### `GetAddress`

Look up an apartment address by player identifier.

```lua theme={"dark"}
local addr = exports['awoken_apartments']:GetAddress('license:abc123...')
-- {
--     slotId    = 12,
--     label     = 'Room 12',
--     citizenid = 'ABC1234',
-- }
-- OR nil
```

<ParamField path="identifier" type="string" required>
  Per-player identifier - license on ESX, license on qbox/qbcore.
</ParamField>

***

### `GetAddressByCitizenId`

Look up an address by citizenid (qbox/qbcore character ID).

```lua theme={"dark"}
local addr = exports['awoken_apartments']:GetAddressByCitizenId('ABC1234')
-- {
--     identifier = 'license:abc123...',
--     slotId     = 12,
--     label      = 'Room 12',
-- }
-- OR nil
```

<ParamField path="citizenid" type="string" required>
  Character ID (qbox/qbcore).
</ParamField>

***

### `GetAllAddresses`

Return the entire address registry as a table keyed by identifier.

```lua theme={"dark"}
local all = exports['awoken_apartments']:GetAllAddresses()
-- {
--     ['license:abc...'] = { slotId = 12, label = 'Room 12', citizenid = 'ABC1234' },
--     ['license:def...'] = { slotId = 47, label = 'Lodge 3',  citizenid = 'DEF5678' },
--     ...
-- }
```

Use this for MDT bulk lookups, server-status dashboards, etc.

## Common integration recipes

<AccordionGroup>
  <Accordion title="MDT - show resident's apartment in their profile">
    ```lua theme={"dark"}
    -- in your MDT server-side, when looking up a player:
    local addr = exports['awoken_apartments']:GetAddressByCitizenId(playerCitizenId)
    if addr then
        profile.address = addr.label
    end
    ```
  </Accordion>

  <Accordion title="Dispatch - display apartment as call location">
    ```lua theme={"dark"}
    -- when generating a call for a player:
    local room = exports['awoken_apartments']:getPlayerRoom(callerSrc)
    if room then
        call.location = ('%s - %s'):format(room.groupLabel, room.roomLabel)
    end
    ```
  </Accordion>

  <Accordion title="Job UI - list all residents of a motel">
    ```lua theme={"dark"}
    local all = exports['awoken_apartments']:GetAllAddresses()
    local pinkCageResidents = {}
    for identifier, addr in pairs(all) do
        -- filter by label substring or load Config.Apartments to check the group
        if addr.label:find('Pink Cage') then
            pinkCageResidents[#pinkCageResidents + 1] = addr
        end
    end
    ```
  </Accordion>
</AccordionGroup>
