> For the complete documentation index, see [llms.txt](https://docs.menanak47.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.menanak47.com/multi-framework/ak47_multicharacter/housing.md).

# Housing

**ak47\_multicharacter** supports `qb-houses`, `qb-apartments`, `ak47_housing`, and `snipe-motel` natively. If you are using a completely custom housing or motel script, you can easily integrate it by editing the `custom/client.lua` and `custom/server.lua` files.

### Client-Side Overrides (`custom/client.lua`)

Modify these functions to trigger your custom housing events.

#### 1. Initial Spawn (Apartments/Motels)

Handles spawning a player inside their starting apartment upon creating a new character or logging in.

```lua
function Custom_SpawnInsideApartment()
    -- Example for custom motel:
    -- exports["my_custom_motel"]:SpawnInsideApartment()
end
```

#### 2. Creating an Apartment

Triggered when a player finishes character creation and chooses an apartment.

```lua
function Custom_CreateApartment(appType, label)
    -- Example:
    -- TriggerServerEvent("my_apartments:server:CreateApartment", appType, label)
end
```

#### 3. Last Location Spawning

If a player logged out inside a property, these functions ensure they spawn back inside.

```lua
function Custom_SpawnLastLocationHouse(houseId)
    -- Example: TriggerEvent('my_housing:client:EnterHouse', houseId)
end

function Custom_SpawnLastLocationApartment(apartmentType, apartmentId)
    -- Example: TriggerEvent('my_apartments:client:EnterApartment', apartmentType, apartmentId)
end
```

#### 4. Entering Owned Houses (Spawn Menu)

Triggered when a player selects one of their properties from the "My Houses" tab in the UI.

```lua
function Custom_EnterOwnedHouse(location)
    -- Example: TriggerEvent('my_housing:client:EnterOwnedHouse', location)
end
```

### Server-Side Overrides (`custom/server.lua`)

#### 1. Loading House Configurations

This function should fetch all available house coordinates and send them to the client to populate the map/UI.

```lua
function Custom_LoadHouseData(source)
    local src = source
    -- Query your custom housing table and format the data
    -- Send data to client...
end
```

#### 2. Fetching Owned Houses for the UI

This function queries the database to populate the "My Houses" tab in the spawn selector. It must return a table containing the `house` ID and the display `label`.

```lua
function Custom_GetOwnedHouses(source, cid)
    local myHouses = {}
    
    -- Example custom query:
    local houses = MySQL.query.await('SELECT * FROM my_custom_houses WHERE owner = ?', {cid})
    
    if houses then
        for i = 1, #houses do
            myHouses[#myHouses+1] = {
                house = houses[i].house_id,
                label = "Property: " .. houses[i].house_name
            }
        end
    end
    
    return myHouses
end
```
