Custom Housing Scripts
LB Phone supports qb-houses (opens in a new tab), loaf_housing (opens in a new tab) and qs-housing (opens in a new tab) by default. If you are using one of these scripts, you can simply set Config.HouseScript to the one you are using. If you are using another housing script, set it to the script name and follow the instructions below.
housing-name
with the name of your housing scriptUpdate config
Set Config.HouseScript
to "housing-name"
in the LB Phone config.
Create files
Create a file called housing-name.lua
in lb-phone/client/apps/framework/home/
and lb-phone/server/apps/framework/home/
Check if enabled
Add the following to the top of both files:
if Config.HouseScript ~= "housing-name" then
return
end
local lib = exports.loaf_lib:GetLib()
Implement client callback
In the client-sided file, add the following code:
RegisterNUICallback("Home", function(data, cb)
local action, houseData = data.action, data.houseData
if action == "getHomes" then
cb({})
elseif action == "removeKeyholder" then
cb({})
elseif action == "addKeyholder" then
cb({})
elseif action == "toggleLocked" then
cb(locked == true)
elseif action == "setWaypoint" then
cb("ok")
end
end)
Implement client logic
Implement the logic for the callbacks in the client-sided file. Here are the expected responses:
getHomes
This is called when opening the app. It should return an array of houses. You can also add any other properties you want to the house object that will be included in houseData
in the NUI callback.
→ Return: house[]
house
table:
label: string
- The name of the houselocked: boolean
- Whether the house is locked or notkeyholders: keyholder[]
- An array of the keyholdersid: number
(optional) - The id of the house
keyholder
table:
identifier: string
- The identifier of the keyholder, this is not shown to the username: string
- The name of the keyholder, this is shown to the user
removeKeyholder
Called when the user attempts to remove a key from a player. data.identifier
is the identifier of the player to remove the key from. Return false if the keyholder could not be removed, otherwise an array of all updated keyholders.
→ Return: false | keyholder[]
addKeyholder
Called when the user attempts to add a key to a player. data.source
is the source of the player to add the key to. Use houseData
to know what house the key is being added to. Return false if the keyholder could not be added, otherwise an array of all updated keyholders.
→ Return: false | keyholder[]
toggleLocked
Called when the user toggles the lock of the house. Return true if the house is now locked, otherwise false.
→ Return: boolean
locked
setWaypoint
Triggered when the user attempts to set a waypoint to a house. Use houseData
to know what house the waypoint is being set to.
→ Return: "ok"