if Config.HouseScript ~= "loaf_housing" then return end RegisterNuiCallback("gksphone:home:fetchHouseData", function(data, cb) local out = {} local seen = {} local owned = exports['loaf_housing']:GetOwnedHouses() if type(owned) == 'table' then for _, house in pairs(owned) do local id = house.id or house.property_id if id then seen[tostring(id)] = true out[#out + 1] = HouseEntry({ id = id, label = house.name or house.adress or house.address, price = house.price, garage = house.garage and true or false, canLocate = true, canTransfer = true, canGiveKey = true, canRemoveKey = true }) end end end local keys = exports['loaf_keysystem']:GetKeys() if type(keys) == 'table' then for _, key in pairs(keys) do local _, _, propertyId = tostring(key.key_id or ''):find("housing_key_(.-)_") if propertyId and not seen[propertyId] then seen[propertyId] = true out[#out + 1] = HouseEntry({ id = propertyId, label = key.key_data and key.key_data.name or nil, owned = false, canLocate = true }) end end end Debugprint('loaf_housing houses', out) cb(out) end) RegisterNUICallback('gksphone:home:transferHouse', function(data, cb) Debugprint('loaf_housing transfer', data) TriggerServerEvent('gksphone:server:loafhouseTransfer', data.id, data.phoneNumber) cb('ok') end) RegisterNetEvent('gksphone:client:transferHouse', function(playerId, propertyId) Debugprint('gksphone:client:transferHouse', playerId, propertyId) exports['loaf_housing']:TransferProperty(playerId, propertyId) exports["gksphone"]:ToastNotification( _T(LastItemData?.info?.phoneLang, "HouseAPP.APP_HOME_TRANSFERSUCCESS")) end) RegisterNUICallback('gksphone:home:houseLocation', function(data, cb) exports['loaf_housing']:MarkProperty(tonumber(data.id) or data.id) 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 local ok = exports['loaf_housing']:GiveKey(tonumber(data.id) or data.id, tonumber(target)) cb(ok and 'ok' or false) end, data.phoneNumber) end) RegisterNUICallback('gksphone:home:removeKey', function(data, cb) if not data.holderId then cb(false) return end local ok = exports['loaf_housing']:RemoveKeyHolder( tonumber(data.id) or data.id, data.holderId) cb(ok and 'ok' or false) end) RegisterNUICallback('gksphone:home:toggleLock', function(data, cb) cb(false) end)