Skip to main content

Client

Functions​

GetOwnedHomes​

Gets the player owned houses, excluding the key access to other player owned houses.

exports.bcs_housing:GetOwnedHomes()

Return:

GetRealestateHomes​

Gets all the houses created by a realestate

exports.bcs_housing:GetRealestateHomes(job)
  • job: string
    • The realestate job name

Return:

GetOwnedHomeKeys​

Gets the player owned houses including the key access to other player owned houses

exports.bcs_housing:GetOwnedHomeKeys()

Return:

GetHomes​

Gets all existing homes

local homes = exports.bcs_housing:GetHomes()
for identifier, v in pairs(homes) do
print(identifier, v.properties.name, v.properties.complex, v.properties.entry)
end

Return:

GetHome​

Get the house by the identifier

exports.bcs_housing:GetHome(homeId)
  • homeId: string
    • The house identifier

Return:

LockHome​

Locks or Unlocks the house, only for IPL or Shell type

exports.bcs_housing:LockHome(homeId)
  • homeId: string
    • The house identifier

isLocked​

Get the lock status of the house

local lock = exports.bcs_housing:isLocked(homeId)
  • homeId: string
    • The house identifier

Return:

  • boolean

GetKeyList​

Gets the house keys

local keys = exports.bcs_housing:GetKeyList(homeId)
for keyName, v in pairs(keys) do
--- v is a list of permission name
print(keyName, json.encode(v))
end
  • homeId: string
    • The house identifier

Return:

  • table: Array of key for the house

GetKeyHolders​

Gets the house key holders

local keyHolders = exports.bcs_housing:GetKeyHolders(homeId)
for identifier, v in pairs(keyHolders) do
print(identifier, v.name, v.key)
end
  • homeId: string
    • The house identifier

Return:

  • table: Array of key holder for the house

AddKeyHolder​

Add a key holder

exports.bcs_housing:AddKeyHolder(homeId, target, keyName)
  • homeId: string
    • The house identifier
  • target: number
  • keyName: string
    • the key name must exists within the key list

RemoveKeyHolder​

exports.bcs_housing:RemoveKeyHolder(homeId, identifier)
  • homeId: string
    • The house identifier
  • identifier: string
    • The target identifier / citizenid

HasKey​

Check if the player has a key to the house

local have = exports.bcs_housing:HasKey(homeId, permission)
  • homeId: string
  • permission?: string
    • optional to check a permission for example Garage, Storage, Door 1

SetWaypoint​

Sets a waypoint gps to the house

exports.bcs_housing:SetWaypoint(homeId)

GetPlayersInside​

local players = exports.bcs_housing:GetPlayersInside(homeId)
for _, id in pairs(players) do
print(id) -- number server id
end
  • homeId: string

Return

  • table<number>: Player server id

  • homeId: string

Statebags​

isInsideHome​

---@field isInside boolean
local isInside = LocalPlayer.state.isInsideHome

This state will check if a player is inside a home

isInsideArea​

---@field inArea boolean
local inArea = LocalPlayer.state.isInsideArea

This state will check if a player is inside an area like outside the house (frontyard) or in an MLO

interiorEntrance​

---@field entranceCoords vec3
local entranceCoords = LocalPlayer.state.interiorEntrance

This state will only be available when the player is inside a shell / IPL type house. This will return the house inside entrance coordinate in vec3.

CurrentHome​

---@field inArea homeObj
local home = LocalPlayer.state.CurrentHome

Returns a home object

Events​

Housing:client:SpawnFurnitures​

You can listen to this event for spawning furniture upon house furniture spawn for your custom spawning furniture

RegisterNetEvent('Housing:client:SpawnFurnitures', function(home, furnitures, center)
-- home is the Home Client Object (check docs)
-- furnitures is a table with index key that contains list of furnitures
-- center is vec3 coordinates for the base of the house this is where you can get the offset
-- round is my util function to round the number
local furncoords = GetEntityCoords(object)
offset = {
x = round(furncoords.x - home.x, 4),
y = round(furncoords.y - home.y, 4),
z = round(furncoords.z - home.z, 4),
}
-- you can then use the center + the offset to place the furniture
end)

Housing:client:DeleteFurnitures​

Delete the furniture that you spawned using the SpawnFurnitures event

RegisterNetEvent("Housing:client:DeleteFurnitures", function(home, furnitures, isArea)
-- here you can loop through the furniture that you spawned to delete it
-- isArea means it is either an mlo house or zone outside the shell or ipl (frontyard /setarea)
end)

Housing:client:EnterHome​

Client Side Event that you can trigger

TriggerEvent('Housing:client:EnterHome', homeId)

Housing:client:SetupSpawnUI​

client/misc.lua
RegisterNetEvent('Housing:client:SetupSpawnUI', function(cData)
local result = lib.callback.await('apartments:GetOwnedApartment', false, cData.citizenid)
if result then
TriggerEvent('qb-spawn:client:setupSpawns', cData, false, nil)
else
TriggerEvent('qb-spawn:client:setupSpawns', cData, true,
lib.callback.await('apartments:GetStarterApartment', false))
end
TriggerEvent('um-spawn:client:startSpawnUI', true)
end)

This is for multicharacter setup spawn starter, you can check example in qb-multichar