> For the complete documentation index, see [llms.txt](https://documentation.rcore.cz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.rcore.cz/paid-resources/rcore_housing/api/server.md).

# Server

Server-side exports exposed by `rcore_housing`. Call them from other resources running on the server.

## 🏠 Properties

<details>

<summary>GetProperty</summary>

Returns the full property data for a given property id.

```lua
---@param propertyId number
---@return Property|nil property
local property = exports.rcore_housing:GetProperty(propertyId)
```

Returns `nil` if no property exists with that id.

**Type: `Property`**

```lua
---@class Property
---@field id number
---@field name string
---@field address string
---@field region string
---@field property_type string              -- "HOUSE" | "APARTMENT" | "BUSINESS"
---@field interior_type string              -- "SHELL" | "IPL" | "MLO"
---@field state string                      -- "FOR_SALE" | "FOR_RENT" | "RENTED" | "OWNED"
---@field price number
---@field rent_price number
---@field lock boolean
---@field is_hidden boolean
---@field is_building boolean
---@field is_starter_template boolean
---@field is_business_property boolean
---@field interior_id number
---@field coords Vector3
---@field zones Vector3[]
---@field interior Interior
---@field shell_interior ShellInterior
---@field points Point[]
---@field players string[]
---@field furniture table[]
---@field doors table[]
---@field dirt DirtItem[]
---@field metadata { size: number }

---@class Vector3
---@field x number
---@field y number
---@field z number

---@class Vector4 : Vector3
---@field w number

---@class Interior
---@field id number
---@field label string
---@field model string
---@field rot number
---@field shell_pos Vector3
---@field offsets InteriorOffsets

---@class InteriorOffsets
---@field management Vector4
---@field doors Vector4
---@field wardrobe Vector4
---@field storage Vector4

---@class ShellInterior
---@field model string
---@field rot number
---@field pos Vector3
---@field offset InteriorOffsets

---@class Point
---@field type string                       -- "entry" | "exit" | "management" | "storage" | "wardrobe" | "furniture_delivery_outside"
---@field coords Vector3
---@field heading? number

---@class DirtItem
---@field id number
---@field label string
---@field model string
---@field isInterior boolean
---@field locationType string               -- "yard_point" | "interior_point"
---@field coords Vector3
```

**Example Usage:**

```lua
local property = exports.rcore_housing:GetProperty(7)
if property then
  -- Basic property info
  print(property.name)              -- "RCore Housing"
  print(property.address)           -- "Senora Way"
  print(property.price)             -- 1000
  print(property.property_type)     -- "HOUSE"
  
  -- Location data
  print(property.coords.x)          -- 2719.2
  print(property.coords.y)          -- 1344.9
  print(property.coords.z)          -- 24.52

  -- Interaction points
  print(#property.points)           -- 7 interaction points
  for _, point in ipairs(property.points) do
    print(point.type, point.coords.x, point.coords.y)
  end
  
  -- Cleanup items
  print(#property.dirt)             -- 9 dirt items
  for _, dirt in ipairs(property.dirt) do
    print(dirt.label, dirt.model)   -- "Litter", "prop_rub_litter_06"
  end
  
  -- Zone coverage
  print(#property.zones)            -- 4 zone points
end
```

</details>

<details>

<summary>GetAllProperties</summary>

Returns every property currently registered on the server.

```lua
---@return table properties
local properties = exports.rcore_housing:GetAllProperties()
```

</details>

<details>

<summary>GetPlayerProperties</summary>

Returns properties owned or rented by a given player.

Accepts either a player server id (`number`) or an identifier (`string`).

```lua
---@param identifier number|string Player Server ID or Player Identifier
---@return Property[] properties
local properties = exports.rcore_housing:GetPlayerProperties(identifier)
```

Returns an array of `Property` objects. See [GetProperty](#getproperty) for the `Property` type structure.

**Example:**

```lua
local byId         = exports.rcore_housing:GetPlayerProperties(source)
local byIdentifier = exports.rcore_housing:GetPlayerProperties('char1:abc123')

if #byId > 0 then
  for _, property in ipairs(byId) do
    print(property.name, property.property_type)
  end
end
```

</details>

<details>

<summary>GetPlayerCurrentProperty</summary>

Returns the id of the property the player is currently inside, or `nil`.

```lua
---@param src number Player server id
---@return number|nil propertyId
local propertyId = exports.rcore_housing:GetPlayerCurrentProperty(src)
```

</details>

<details>

<summary>IsPlayerInProperty</summary>

Returns whether the player is currently inside a specific property.

```lua
---@param src number Player server id
---@param propertyId number
---@return boolean inside
local inside = exports.rcore_housing:IsPlayerInProperty(src, propertyId)
```

</details>

## 🗝️ Keys & Permissions

<details>

<summary>HasKeys</summary>

Returns whether the player has access to a property - covers ownership, tenant status, shared access, and physical key items.

```lua
---@param src number Player server id
---@param propertyId number
---@param doorIndex number|nil nil = master / entry access
---@return boolean hasAccess
local ok = exports.rcore_housing:HasKeys(src, propertyId, doorIndex)
```

Example:

```lua
if not exports.rcore_housing:HasKeys(src, propertyId) then
    -- block the interaction
end
```

</details>

<details>

<summary>HasAnyPermission</summary>

Binary access check - whether the player is owner, tenant, has shared access, or business-synthesized access on a property.

```lua
---@param src number Player server id
---@param propertyId number
---@return boolean hasAccess
local ok = exports.rcore_housing:HasAnyPermission(src, propertyId)
```

</details>

<details>

<summary>HasPermission</summary>

Granular permission check. `permissionKey` is a `PERMISSIONS` constant value, e.g. `property:security:manage`.

```lua
---@param src number Player server id
---@param permissionKey string Permission key (PERMISSIONS constant value)
---@param propertyId number
---@return boolean hasPermission
local ok = exports.rcore_housing:HasPermission(src, 'property:security:manage', propertyId)
```

You may pass the raw string value directly, or use the `PERMISSIONS` constant (recommended) which resolves to the same value.

**Property permissions**

| Constant                                        | Value                               |
| ----------------------------------------------- | ----------------------------------- |
| `PERMISSIONS.PROPERTY_DASHBOARD_VIEW`           | `property:dashboard:view`           |
| `PERMISSIONS.PROPERTY_CAMERAS_VIEW`             | `property:cameras:view`             |
| `PERMISSIONS.PROPERTY_CAMERAS_MANAGE`           | `property:cameras:manage`           |
| `PERMISSIONS.PROPERTY_CAMERAS_DELETE`           | `property:cameras:delete`           |
| `PERMISSIONS.PROPERTY_LIGHTS_VIEW`              | `property:lights:view`              |
| `PERMISSIONS.PROPERTY_LIGHTS_MANAGE`            | `property:lights:manage`            |
| `PERMISSIONS.PROPERTY_KEYS_VIEW`                | `property:keys:view`                |
| `PERMISSIONS.PROPERTY_KEYS_MANAGE`              | `property:keys:manage`              |
| `PERMISSIONS.PROPERTY_ACCESS_VIEW`              | `property:access:view`              |
| `PERMISSIONS.PROPERTY_ACCESS_MANAGE`            | `property:access:manage`            |
| `PERMISSIONS.PROPERTY_UPGRADES_VIEW`            | `property:upgrades:view`            |
| `PERMISSIONS.PROPERTY_UPGRADES_BUY`             | `property:upgrades:buy`             |
| `PERMISSIONS.PROPERTY_DOORS_VIEW`               | `property:doors:view`               |
| `PERMISSIONS.PROPERTY_DOORS_MANAGE`             | `property:doors:manage`             |
| `PERMISSIONS.PROPERTY_INTERACTIONS_VIEW`        | `property:interactions:view`        |
| `PERMISSIONS.PROPERTY_INTERACTIONS_MANAGE`      | `property:interactions:manage`      |
| `PERMISSIONS.PROPERTY_BILLS_VIEW`               | `property:bills:view`               |
| `PERMISSIONS.PROPERTY_BILLS_PAY`                | `property:bills:pay`                |
| `PERMISSIONS.PROPERTY_FURNITURE_STORAGE_VIEW`   | `property:furniture_storage:view`   |
| `PERMISSIONS.PROPERTY_FURNITURE_STORAGE_MANAGE` | `property:furniture_storage:manage` |
| `PERMISSIONS.PROPERTY_FURNITURE_EDITOR_VIEW`    | `property:furniture_editor:view`    |
| `PERMISSIONS.PROPERTY_FURNITURE_EDITOR_USE`     | `property:furniture_editor:use`     |
| `PERMISSIONS.PROPERTY_FURNITURE_ORDER_VIEW`     | `property:furniture_order:view`     |
| `PERMISSIONS.PROPERTY_FURNITURE_ORDER_CREATE`   | `property:furniture_order:create`   |
| `PERMISSIONS.PROPERTY_OWNERSHIP_RENT`           | `property:ownership:rent`           |
| `PERMISSIONS.PROPERTY_OWNERSHIP_SELL`           | `property:ownership:sell`           |
| `PERMISSIONS.PROPERTY_OWNERSHIP_TRANSFER`       | `property:ownership:transfer`       |
| `PERMISSIONS.PROPERTY_SECURITY_VIEW`            | `property:security:view`            |
| `PERMISSIONS.PROPERTY_SECURITY_MANAGE`          | `property:security:manage`          |

**Zone permissions**

| Constant                                             | Value                                     |
| ---------------------------------------------------- | ----------------------------------------- |
| `PERMISSIONS.ZONE_STORAGE_ACCESS`                    | `zones:storage:access`                    |
| `PERMISSIONS.ZONE_WARDROBE_ACCESS`                   | `zones:wardrobe:access`                   |
| `PERMISSIONS.ZONE_GARAGE_ACCESS`                     | `zones:garage:access`                     |
| `PERMISSIONS.ZONE_MANAGEMENT_ACCESS`                 | `zones:management:access`                 |
| `PERMISSIONS.ZONE_FURNITURE_DELIVERY_INSIDE_ACCESS`  | `zones:furniture_delivery_inside:access`  |
| `PERMISSIONS.ZONE_FURNITURE_DELIVERY_OUTSIDE_ACCESS` | `zones:furniture_delivery_outside:access` |

See [Access and Permissions](/paid-resources/rcore_housing/features/access-and-permissions.md) for more on how permissions are applied.

</details>

## 🚪 Property Actions

<details>

<summary>EnterProperty</summary>

Requests entry into a property for the player.

```lua
---@param src number Player server id
---@param propertyId number
exports.rcore_housing:EnterProperty(src, propertyId)
```

</details>

<details>

<summary>GiveProperty</summary>

Gives a property to an identifier.

```lua
---@param identifier string Player identifier
---@param propertyId number
---@return boolean success
---@return string|nil error
local ok, err = exports.rcore_housing:GiveProperty(identifier, propertyId)
```

Returns `false, "Property not found"` if the property does not exist.

</details>

<details>

<summary>DeleteProperty</summary>

Deletes a property entirely.

```lua
---@param propertyId number
---@return boolean success
local ok = exports.rcore_housing:DeleteProperty(propertyId)
```

</details>

<details>

<summary>WipeProperty</summary>

Wipes a property - optionally removing ownership as well.

```lua
---@param propertyId number
---@param removeOwnership boolean|nil
---@return boolean success
---@return string|nil error
local ok, err = exports.rcore_housing:WipeProperty(propertyId, removeOwnership)
```

Returns `false, "Property not found"` if the property does not exist.

</details>

<details>

<summary>KickPlayerFromProperty</summary>

Kicks the player out of the property they are currently inside.

```lua
---@param src number Player server id
---@return boolean success
local ok = exports.rcore_housing:KickPlayerFromProperty(src)
```

Returns `false` if the player is not inside any property.

</details>

<details>

<summary>ResetPlayerProperties</summary>

Resets all properties belonging to an identifier.

```lua
---@param identifier string Player identifier
local result = exports.rcore_housing:ResetPlayerProperties(identifier)
```

</details>

## ⭐ Starter Apartments

<details>

<summary>AddStarterApartment</summary>

Assigns a starter apartment to a player identifier.

```lua
---@param identifier string Player identifier
---@return boolean success
local ok = exports.rcore_housing:AddStarterApartment(identifier)
```

Returns `true` if the starter apartment was successfully assigned, `false` otherwise.

**Example Usage:**

```lua
local success = exports.rcore_housing:AddStarterApartment('char1:abc123')
if success then
  print('Starter apartment assigned successfully')
else
  print('Failed to assign starter apartment')
end
```

</details>

<details>

<summary>HasStarterApartment</summary>

Checks whether a player has a starter apartment assigned.

```lua
---@param identifier string Player identifier
---@return boolean hasStarterApartment
local has = exports.rcore_housing:HasStarterApartment(identifier)
```

Returns `true` if the player has a starter apartment, `false` otherwise.

**Example Usage:**

```lua
if exports.rcore_housing:HasStarterApartment('char1:abc123') then
  print('Player already has a starter apartment')
else
  print('Player does not have a starter apartment')
end
```

</details>
