Skip to content

Commands, Exports & Events ​

Commands ​

CommandWhoPurpose
/housingadminAdmin.GroupOpens the admin panel. Name set by Admin.Command.
/apartment [give, take, info, tp]Apartments.Admin.GroupTower flats. See Apartment Towers.
/realtorRealtors, or anyone with Realtor.AnywhereOpens the realtor page. Name set by Realtor.Command.
/decorateWhoever may decorate the property they stand inOpens and closes decorate mode. Name set by Decor.Command.
/shellcreatorAdmins, the sd_housing.creator ace, Creator.JobsOpens the Shell Creator. Name set by Interiors.Creator.Command.
/propertyEveryoneOpens the property page. Only exists when Properties.Manage.Command is set. It is false by default.
sdh_walkin_importServer consoleImports the walk-in houses.
sdh_shells ...Server consoleManages Shell Creator shells. See Console.

Server Exports ​

A property is named by its id or its key. A walk-in house's key is its pack name, for example 'sdwi_mirr_04_0'. Every export that changes something returns true, or false and a reason.

GetProperty ​

What a property is, owner included. Returns nil if there is none.

lua
local property = exports['sd-housing']:GetProperty(idOrKey)
-- { id, key, label, kind, parent, price, forSale, owner, ownerName, entrance, doors }

GetOwnedProperties ​

Every property a character owns.

lua
local list = exports['sd-housing']:GetOwnedProperties(citizenid)
-- { { id, key, label, kind }, ... }

GetAccess ​

What a player may do at a property: 'owner', 'key' or nil.

lua
local access = exports['sd-housing']:GetAccess(source, idOrKey)

HasPermission ​

Whether a player may do something at a property. The owner may do everything, a keyholder what their key opens.

lua
local allowed = exports['sd-housing']:HasPermission(source, idOrKey, perm)
ParameterTypeDescription
sourceintegerThe player's server id
idOrKeyinteger or stringProperty id or key
permstring'doors', 'stash', 'wardrobe', 'garage' or 'decorate'

CanUseGarageDoor ​

Whether a player may open a walk-in garage door. sd-housing-interiors asks this before it moves one. A house this resource does not manage is anyone's to open.

lua
local allowed = exports['sd-housing']:CanUseGarageDoor(source, house)

SetLocked ​

Lock or unlock one door of a property, or every door of it and its garages when doorId is nil.

lua
local ok, why = exports['sd-housing']:SetLocked(idOrKey, doorId, locked)
-- why: 'unknown_property' | 'unknown_door'

ResetHomePanel ​

Take a house's home panel down. It is put up again by its front door the next time somebody is inside.

lua
local ok, why = exports['sd-housing']:ResetHomePanel(idOrKey)

SendMail ​

Deliver mail to a house's mailbox from another resource: a letter, and a parcel when it brings items.

lua
local ok, why = exports['sd-housing']:SendMail(idOrKey, {
    from = 'Post Office',
    subject = 'Your order',
    body = 'Your parcel has arrived.',
    items = { { name = 'water', count = 2 } },
})
FieldTypeDescription
fromstringThe sender shown on the letter
subjectstring?The subject
bodystring?The text
itemstable?A list of { name, count, metadata? }. Parcels need ox_inventory.

Apartments ​

lua
-- A character's flat, or nil:
-- { id, key, label, number, floor, unit, tower, towerLabel, price, area, inside, entrance }
local flat = exports['sd-housing']:GetApartment(citizenid)

-- Give a character a flat for free: that one, or a vacant one. Returns ok, and the flat or why not.
local ok, flatOrWhy = exports['sd-housing']:GiveApartment(citizenid, flat)

-- Take a character's flat back. Nothing is refunded. Returns ok, message.
local ok, message = exports['sd-housing']:TakeApartment(citizenid)

Client Exports ​

The client exports report on the local player and open pages. Use the server exports to act.

ExportReturnsDescription
GetAccess(id)'owner', 'key' or nilWhat this player may do at a property.
GetMyProperties(){ { id, key, label, kind, access }, ... }Every property this player owns or holds a key to.
HasPermission(id, perm)booleanWhether this player may do this at a property.
IsDoorLocked(id, doorId)booleanWhether a door of a property is locked.
OpenPropertyMenu(id?)boolean openedOpens the property page: on that property, else the one the player is at, else their first. false when there is nothing to show or another page has the mouse.
ClosePropertyMenu()Closes the property page.
IsPropertyMenuOpen()booleanWhether the property page is up.
OpenHomePanel(id?)boolean openedUses the home panel the player is standing at. false when there is none within reach or it is not theirs to use.
IsHomePanelOpen()booleanWhether the home panel is up.
OpenRealtor(id?)boolean openedOpens the realtor: the agent page for a realtor, or the listings for anyone with Realtor.Anywhere. With an id it opens on that listing.
CloseRealtor()Closes the realtor.
GetMyApartment(){ id, label, number, floor, unit, tower } or nilThis player's flat.
GetApartmentFloor()The floor the lift should show as yours.
OpenApartmentDesk()Opens the front desk's menu.
Peephole()Looks through the peephole of the flat the player is in.

The client ids are property ids, not keys.

Radial Menu Examples ​

lua
-- ox_lib radial (or set Properties.Manage.Radial = true and sd-housing adds it itself)
lib.addRadialItem({
    id = 'property',
    icon = 'house',
    label = 'Property',
    onSelect = function()
        exports['sd-housing']:OpenPropertyMenu()
    end,
})

For a radial menu that triggers events instead of exports, such as qb-radialmenu:

lua
{ type = 'client', event = 'sd-housing:client:openPropertyMenu' }

Events ​

Client events ​

Trigger these on the local client from a radial menu or a keybind.

EventDoes
sd-housing:client:openPropertyMenuThe same as OpenPropertyMenu.
sd-housing:client:openHomePanelThe same as OpenHomePanel.
sd-housing:client:openRealtorThe same as OpenRealtor.

sd-housing:server:realtorSale ​

A server event raised when a client buys a house from a player realtor. Use it for a society's books.

lua
AddEventHandler('sd-housing:server:realtorSale', function(sale)
    -- sale.property    property id
    -- sale.label       property name
    -- sale.price       what the client paid
    -- sale.buyer       the buyer's server id
    -- sale.agent       the realtor's server id
    -- sale.commission  what the realtor was paid
    -- sale.society     the amount paid into the job's society account
end)

Bridges ​

bridge/ ships open. To support another resource, edit the matching file:

FileHandles
bridge/shared/framework.luaFramework detection
bridge/client/target.luaox_target, qb-target, qtarget
bridge/server/phone.lua, bridge/client/phone.luaHousehold alerts on the phone
bridge/server/dispatch.luaPolice calls
bridge/server/voice.luaIntercom voice calls
bridge/server/inventory.lua, bridge/client/inventory.luaCounting and removing break-in items. ox_inventory when started, else the framework's inventory.
bridge/server/money.lua, bridge/server/society.luaPayments and society accounts
bridge/server/notify.lua, bridge/client/notify.luaNotifications

Internal network events and NUI callbacks are implementation details and may change between beta versions. Use the exports above.