-----------------For support, scripts, and more---------------- --------------- https://discord.gg/wasabiscripts ------------- --------------------------------------------------------------- local REQUIRED_MODULES = { 'bridge', 'config' } Modules.waitFor(REQUIRED_MODULES) local config = Modules.require('config') local bridge = Modules.require('bridge') local function dbExecute(query, params) if GetResourceState('oxmysql') ~= 'started' then return nil end local p = promise.new() exports.oxmysql:execute(query, params, function(result) p:resolve(result) end) return Citizen.Await(p) end lib.callback.register('wasabi_spawn:getPlayerHouses', function(source) if not config.houseScript then return {} end -- If houseScript is false, return empty table local citizenid = bridge.getIdentifer(source) if not citizenid then return {} end if config.houseScript == "rcore_housing" then local playerHouses = exports['rcore_housing']:GetPlayerProperties(citizenid) local houses = {} if playerHouses and next(playerHouses) then local function getCamCoords(coords) if coords.w then return vec3( coords.x - math.sin(math.rad(coords.w)) * 5.0, coords.y + math.cos(math.rad(coords.w)) * 5.0, coords.z + 0.8 ) end return vec3(coords.x - 5.0, coords.y, coords.z + 1.4) end for _, v in pairs(playerHouses) do houses[#houses + 1] = { id = tostring(v.id or #houses + 1), title = v.name or 'House', description = locale('house_description'), coords = { x = v.coords.x, y = v.coords.y, z = v.coords.z, w = v.coords.w or 0.0, }, cameraCoords = { x = getCamCoords(v.coords).x, y = getCamCoords(v.coords).y, z = getCamCoords(v.coords).z, }, } end return houses end end if config.houseScript == 'qb-houses' and (bridge.framework == 'qb' or bridge.framework == 'qbx') then local playerHouses = dbExecute('SELECT * FROM player_houses WHERE citizenid = ?', { citizenid }) if not playerHouses or #playerHouses == 0 then return {} end local houses = {} for _, house in ipairs(playerHouses) do local houseLocations = dbExecute('SELECT * FROM houselocations WHERE name = ?', { house.house }) if houseLocations and houseLocations[1] then local coords = json.decode(houseLocations[1].coords) if coords.cam then coords.cam.z = (coords.cam.z or 0) + 5.0 end houses[#houses + 1] = { id = (houseLocations[1].name or ''):gsub('%s+', ''), title = houseLocations[1].label or 'House', description = locale('house_description'), coords = { x = coords.enter.x, y = coords.enter.y, z = coords.enter.z, w = coords.enter.w or coords.enter.h or coords.enter.heading or 0.0, }, cameraCoords = coords.cam and { x = coords.cam.x, y = coords.cam.y, z = coords.cam.z, } or nil, } end end return houses end return {} -- If houseScript is not 'qb-houses' or defined above, return empty table end)