lb_phone
This integration is for lb_phone menu of waypoint, lock, and give/remove key.
V3​
lb_phone/client/custom/home/bcs_housing.lua
CreateThread(function()
if Config.HouseScript ~= "bcs_housing" then
return
end
RegisterNUICallback("Home", function(data, cb)
local action = data.action
if action == "getHomes" then
local ownedHouses = exports.bcs_housing:GetOwnedHomes()
local toSend = {}
for _, v in pairs(ownedHouses) do
if v then
toSend[#toSend + 1] = {
label = v.properties.name .. " (" .. v.identifier .. ")",
id = v.identifier,
uniqueId = v.identifier,
locked = exports.bcs_housing:isLocked(v.identifier),
keyholders = exports.bcs_housing:GetKeyHolders(v.identifier)
}
end
end
cb(toSend)
elseif action == "removeKeyholder" then
cb(exports.bcs_housing:RemoveKeyHolder(data.id, data.identifier))
elseif action == "addKeyholder" then
if exports.bcs_housing:AddKeyHolder(data.id, tonumber(data.source)) then
SetTimeout(500, function()
cb(exports.bcs_housing:GetKeyHolders(data.id))
end)
end
elseif action == "toggleLocked" then
exports.bcs_housing:LockHome(data.id)
SetTimeout(500, function()
cb(exports.bcs_housing:isLocked(data.id))
end)
elseif action == "setWaypoint" then
exports.bcs_housing:SetWaypoint(data.id)
end
end)
end)
V2​
Client​
lb_phone/client/custom/home/bcs_housing.lua
CreateThread(function()
if Config.HouseScript ~= "bcs_housing" then
return
end
RegisterNUICallback("Home", function(data, cb)
local action = data.action
if action == "getHomes" then
local ownedHouses = exports.bcs_housing:GetOwnedHomes()
local toSend = {}
for _, v in pairs(ownedHouses) do
if v then
toSend[#toSend + 1] = {
label = v.name .. " (" .. v.identifier .. ")",
id = v.identifier,
uniqueId = v.identifier,
locked = exports.bcs_housing:isLocked(v.identifier),
keyholders = exports.bcs_housing:GetKeyHolders(v.identifier)
}
end
end
cb(toSend)
elseif action == "removeKeyholder" then
cb(exports.bcs_housing:RemoveKey(data.id, data.identifier))
elseif action == "addKeyholder" then
if exports.bcs_housing:GiveKey(data.id, tonumber(data.source)) then
SetTimeout(500, function()
cb(exports.bcs_housing:GetKeyHolders(data.id))
end)
end
elseif action == "toggleLocked" then
exports.bcs_housing:LockHome(data.id)
SetTimeout(500, function()
cb(exports.bcs_housing:isLocked(data.id))
end)
elseif action == "setWaypoint" then
exports.bcs_housing:SetWaypoint(data.id)
end
end)
end)
Server​
lb-phone/server/custom/home/bcs_housing.lua
CreateThread(function()
if Config.HouseScript ~= "bcs_housing" then
return
end
local lib = exports.loaf_lib:GetLib()
lib.RegisterCallback("phone:home:toggleLocked", function(source, cb, id, uniqueId)
local hasKey = exports.bcs_housing:HasKey(id, source)
if not hasKey then
cb(false)
return
end
local locked = exports["bcs_housing"]:isLocked(id)
exports["bcs_housing"]:LockHome(id, not locked)
cb(not locked)
end)
end)