Commands, Exports & Events
Commands
| Command | Who | Purpose |
|---|---|---|
/housingadmin | Admin.Group | Opens the admin panel. Name set by Admin.Command. |
/apartment [give, take, info, tp] | Apartments.Admin.Group | Tower flats. See Apartment Towers. |
/realtor | Realtors, or anyone with Realtor.Anywhere | Opens the realtor page. Name set by Realtor.Command. |
/decorate | Whoever may decorate the property they stand in | Opens and closes decorate mode. Name set by Decor.Command. |
/shellcreator | Admins, the sd_housing.creator ace, Creator.Jobs | Opens the Shell Creator. Name set by Interiors.Creator.Command. |
/property | Everyone | Opens the property page. Only exists when Properties.Manage.Command is set. It is false by default. |
sdh_walkin_import | Server console | Imports the walk-in houses. |
sdh_shells ... | Server console | Manages 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.
local property = exports['sd-housing']:GetProperty(idOrKey)
-- { id, key, label, kind, parent, price, forSale, owner, ownerName, entrance, doors }GetOwnedProperties
Every property a character owns.
local list = exports['sd-housing']:GetOwnedProperties(citizenid)
-- { { id, key, label, kind }, ... }GetAccess
What a player may do at a property: 'owner', 'key' or nil.
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.
local allowed = exports['sd-housing']:HasPermission(source, idOrKey, perm)| Parameter | Type | Description |
|---|---|---|
source | integer | The player's server id |
idOrKey | integer or string | Property id or key |
perm | string | '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.
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.
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.
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.
local ok, why = exports['sd-housing']:SendMail(idOrKey, {
from = 'Post Office',
subject = 'Your order',
body = 'Your parcel has arrived.',
items = { { name = 'water', count = 2 } },
})| Field | Type | Description |
|---|---|---|
from | string | The sender shown on the letter |
subject | string? | The subject |
body | string? | The text |
items | table? | A list of { name, count, metadata? }. Parcels need ox_inventory. |
Apartments
-- 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.
| Export | Returns | Description |
|---|---|---|
GetAccess(id) | 'owner', 'key' or nil | What 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) | boolean | Whether this player may do this at a property. |
IsDoorLocked(id, doorId) | boolean | Whether a door of a property is locked. |
OpenPropertyMenu(id?) | boolean opened | Opens 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() | boolean | Whether the property page is up. |
OpenHomePanel(id?) | boolean opened | Uses the home panel the player is standing at. false when there is none within reach or it is not theirs to use. |
IsHomePanelOpen() | boolean | Whether the home panel is up. |
OpenRealtor(id?) | boolean opened | Opens 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 nil | This 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
-- 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:
{ type = 'client', event = 'sd-housing:client:openPropertyMenu' }Events
Client events
Trigger these on the local client from a radial menu or a keybind.
| Event | Does |
|---|---|
sd-housing:client:openPropertyMenu | The same as OpenPropertyMenu. |
sd-housing:client:openHomePanel | The same as OpenHomePanel. |
sd-housing:client:openRealtor | The 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.
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:
| File | Handles |
|---|---|
bridge/shared/framework.lua | Framework detection |
bridge/client/target.lua | ox_target, qb-target, qtarget |
bridge/server/phone.lua, bridge/client/phone.lua | Household alerts on the phone |
bridge/server/dispatch.lua | Police calls |
bridge/server/voice.lua | Intercom voice calls |
bridge/server/inventory.lua, bridge/client/inventory.lua | Counting and removing break-in items. ox_inventory when started, else the framework's inventory. |
bridge/server/money.lua, bridge/server/society.lua | Payments and society accounts |
bridge/server/notify.lua, bridge/client/notify.lua | Notifications |
Internal network events and NUI callbacks are implementation details and may change between beta versions. Use the exports above.
