if Config.HouseScript ~= "ps-housing" then return end local function AddressOf(data) local street = data.street local region = data.region if street and region then return street .. ', ' .. region end return street or region or nil end local function Format() local properties = exports['ps-housing']:GetProperties() local out = {} if type(properties) ~= 'table' then return out end for _, property in pairs(properties) do local data = property.propertyData if data and (property.owner or property.has_access) then local door = data.door_data local hasDoor = type(door) == 'table' and door.x ~= nil out[#out + 1] = HouseEntry({ id = data.property_id or property.property_id, label = AddressOf(data), tag = data.apartment, apartment = data.apartment and true or false, owned = property.owner and true or false, price = data.price, garage = type(data.garage_data) == 'table' and data.garage_data.x ~= nil, coords = hasDoor and door or nil, canLocate = hasDoor, canTransfer = false, canGiveKey = property.owner and true or false, canRemoveKey = property.owner and true or false }) end end return out end RegisterNuiCallback("gksphone:home:fetchHouseData", function(data, cb) local houses = Format() Debugprint('ps-housing houses', houses) for i = 1, #houses do if houses[i].owned then local access = lib.callback.await( 'ps-housing:cb:getPlayersWithAccess', false, houses[i].id) houses[i].keyholders = HouseKeys(access, function(_, holder) return HouseKey(holder.citizenid, holder.name) end) end end cb(houses) end) RegisterNUICallback('gksphone:home:transferHouse', function(data, cb) cb(false) end) RegisterNUICallback('gksphone:home:houseLocation', function(data, cb) if not HouseWaypoint(data.coords) then exports["gksphone"]:ToastNotification( _T(LastItemData?.info?.phoneLang, "HouseAPP.APP_HOUSE_ERROR_NOTFOUND")) cb(false) return end exports["gksphone"]:ToastNotification( _T(LastItemData?.info?.phoneLang, "HouseAPP.APP_HOUSE_SETGPS")) cb('ok') end) RegisterNUICallback('gksphone:home:giveKey', function(data, cb) CallBackServerTrigger('gksphone:server:getCizitinIDSource', function(_, target) if not target then cb(false) return end TriggerServerEvent('ps-housing:server:addAccess', data.id, tonumber(target)) cb('ok') end, data.phoneNumber) end) RegisterNUICallback('gksphone:home:removeKey', function(data, cb) if not data.holderId then cb(false) return end TriggerServerEvent('ps-housing:server:removeAccess', data.id, data.holderId) cb('ok') end) RegisterNUICallback('gksphone:home:toggleLock', function(data, cb) cb(false) end)