Project-Sloth / ps-housing
- четверг, 27 июля 2023 г. в 00:00:04
Advanced housing system for QBCore.
ps-housing is a resource that opens up a world of creative possibilities for housing. Its user-friendly interface lets you decorate any location to your heart's content. The best part? Not only is it completely free, but it's also reliable and functional, unlike many other housing systems available. Dive in and start transforming spaces with ps-housing today!
ps-housing owes its existence to the exceptional coding expertise of Xirvin#0985. His application of top-tier coding practices has been instrumental in creating this script. We at Project Sloth are thrilled that he has joined our team and utilized our platform to deliver this incredible, much-anticipated resource. Our sincere appreciation goes out to Xirvin#0985 for his outstanding contribution!
bl-realtor
and the realtor jobPlayers must have the realtor job to create new properties. Additionally if the realtor has a high enough grade level, they can also help players move to new apartments. All properties must be manually configured for sale by the realtor job, giving you full control over all aspects of properties, and bringing another avenue of roleplay to your server.
/housing
to open the housing menuOnce inside the property, the player can furnish and decorate the property to their liking. They can also invite other players to their property, and give them access to the property. Open the furniture store by pressing Z
.
This will open a furniture store complete with all of the props. Select an item from the catalog and place it into the property. You can use the placement gizmo to position the item to your liking as well as use the UI tools for fine tune control over the placement. Once you are happy with the positioning, make sure you press Add to Cart
before moving on. Continue to add as many items as you want to your cart. Once you are done, go to the Checkout
and purchase the items.
Note: The place on ground button sometimes does not work properly depending on where the native detects the ground to be.
Players need to place their stash and wardrobe or else they wont have one. Check Config for more information.
This entire README is meant for compatibility with default QBCore scripts. If you have different scripts, you'll need to adjust them for compatibility yourself. Refrain from asking us how to circumvent paid scripts that can't be adjusted for ps-housing support. Instead, request their support for ps-housing - this script is fully open source for that reason. Any inquiries related to this be ignored.
qb-multicharacter
and change in server/main.lua event to:qb-multicharacter > server > main.lua
RegisterNetEvent('qb-multicharacter:server:loadUserData', function(cData)
local src = source
if QBCore.Player.Login(src, cData.citizenid) then
repeat
Wait(10)
until hasDonePreloading[src]
print('^2[qb-core]^7 '..GetPlayerName(src)..' (Citizen ID: '..cData.citizenid..') has succesfully loaded!')
QBCore.Commands.Refresh(src)
TriggerClientEvent('ps-housing:client:setupSpawnUI', src, cData)
TriggerEvent("qb-log:server:CreateLog", "joinleave", "Loaded", "green", "**".. GetPlayerName(src) .. "** (<@"..(QBCore.Functions.GetIdentifier(src, 'discord'):gsub("discord:", "") or "unknown").."> | ||" ..(QBCore.Functions.GetIdentifier(src, 'ip') or 'undefined') .. "|| | " ..(QBCore.Functions.GetIdentifier(src, 'license') or 'undefined') .." | " ..cData.citizenid.." | "..src..") loaded..")
end
end)
qb-multicharacter > server > main.lua
RegisterNetEvent('qb-multicharacter:server:createCharacter', function(data)
local src = source
local newData = {}
newData.cid = data.cid
newData.charinfo = data
if QBCore.Player.Login(src, false, newData) then
repeat
Wait(10)
until hasDonePreloading[src]
print('^2[qb-core]^7 '..GetPlayerName(src)..' has succesfully loaded!')
QBCore.Commands.Refresh(src)
TriggerClientEvent("qb-multicharacter:client:closeNUI", src)
newData.citizenid = QBCore.Functions.GetPlayer(src).PlayerData.citizenid
TriggerClientEvent('ps-housing:client:setupSpawnUI', src, newData)
GiveStarterItems(src)
end
end)
qb-spawn
and change in client/client.lua event to:qb-spawn > client.lua > line 51 > 'qb-spawn:client:setupSpawns' event
RegisterNetEvent('qb-spawn:client:setupSpawns', function(cData, new, apps)
if not new then
QBCore.Functions.TriggerCallback('qb-spawn:server:getOwnedHouses', function(houses)
local myHouses = {}
if houses ~= nil then
for i = 1, (#houses), 1 do
local house = houses[i]
myHouses[#myHouses+1] = {
house = house,
label = (house.apartment or house.street) .. " " .. house.property_id,
}
end
end
Wait(500)
SendNUIMessage({
action = "setupLocations",
locations = QB.Spawns,
houses = myHouses,
isNew = new
})
end, cData.citizenid)
elseif new then
SendNUIMessage({
action = "setupAppartements",
locations = apps,
isNew = new
})
end
end)
qb-spawn > client.lua > line 134 > 'chooseAppa' NUI Callback
RegisterNUICallback('chooseAppa', function(data, cb)
local ped = PlayerPedId()
local appaYeet = data.appType
SetDisplay(false)
DoScreenFadeOut(500)
Wait(100)
FreezeEntityPosition(ped, false)
RenderScriptCams(false, true, 0, true, true)
SetCamActive(cam, false)
DestroyCam(cam, true)
SetCamActive(cam2, false)
DestroyCam(cam2, true)
SetEntityVisible(ped, true)
Wait(500)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
Wait(100)
TriggerServerEvent("ps-housing:server:createNewApartment", appaYeet)
cb('ok')
end)
qb-spawn > client > client.lua > line 169 'spawnplayer' NUI Callback
RegisterNUICallback('spawnplayer', function(data, cb)
local location = tostring(data.spawnloc)
local type = tostring(data.typeLoc)
local ped = PlayerPedId()
local PlayerData = QBCore.Functions.GetPlayerData()
local insideMeta = PlayerData.metadata["inside"]
if type == "current" then
PreSpawnPlayer()
QBCore.Functions.GetPlayerData(function(pd)
ped = PlayerPedId()
SetEntityCoords(ped, pd.position.x, pd.position.y, pd.position.z)
SetEntityHeading(ped, pd.position.a)
FreezeEntityPosition(ped, false)
end)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
if insideMeta.property_id ~= nil then
local property_id = insideMeta.property_id
TriggerServerEvent('ps-housing:server:enterProperty', tostring(property_id))
end
PostSpawnPlayer()
elseif type == "house" then
PreSpawnPlayer()
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
local property_id = data.spawnloc.property_id
TriggerServerEvent('ps-housing:server:enterProperty', tostring(property_id))
PostSpawnPlayer()
elseif type == "normal" then
local pos = QB.Spawns[location].coords
PreSpawnPlayer()
SetEntityCoords(ped, pos.x, pos.y, pos.z)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
TriggerServerEvent('ps-housing:server:resetMetaData')
SetEntityCoords(ped, pos.x, pos.y, pos.z)
SetEntityHeading(ped, pos.w)
PostSpawnPlayer()
end
cb('ok')
end)
qb-spawn > server.lua > line 3
QBCore.Functions.CreateCallback('qb-spawn:server:getOwnedHouses', function(_, cb, cid)
if cid ~= nil then
local houses = MySQL.query.await('SELECT * FROM properties WHERE owner_citizenid = ?', {cid})
if houses[1] ~= nil then
cb(houses)
else
cb({})
end
else
cb({})
end
end)
qb-garages
and change:
qb-garages > server > main.lua > around line 120
on event qb-garage:server:checkOwnership
Replace
local hasHouseKey = exports['qb-houses']:hasKey(result[1].license, result[1].citizenid, house)
With
local hasHouseKey = exports['ps-housing']:IsOwner(src, house)
qb-garages > client > main.lua > around line 451
under event qb-garages:client:addHouseGarage
RegisterNetEvent('qb-garages:client:removeHouseGarage', function(house)
Config.HouseGarages[house] = nil
end)
Run the properties.sql
file, but be cautious. If a table named properties
already exists in your database, this operation will drop it, resulting in the loss of all its data.
Delete default qb-apartments
Delete default qb-houses
Delete qb-apartments/config.lua
references in qb-spawn
, qb-multicharacter
and qb-phone
fxmanifest.lua (and any other scripts that may reference it).
Ensure bl-realtor above ps-housing.
In your server.cfg, add ensure ox_lib
above all other resources
Install the dependencies below.
bl-realtor
, fivem-freecam
, ox_lib
, ps-core
, ps-housing
inside the folder.ensure ox_lib
ensure bl-realtor
ensure ps-housing
ensure fivem-freecam