Skip to content

iLickPandas21/ps-housing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ps-housing

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!

Preview ps-housing

image image image image

Preview bl-realtor

image image image image

Usage

  • Players can decorate their houses and apartments with a full selection of furniture and decorations (included a wide variety of custom housing props)
  • Provides support for housing and apartments and is a full replacement for qb-apartments and qb-housing
    • When a player first spawns after enabling ps-housing, they will have to choose an apartment. Once they spawn in the stashitems from their previous qb-apartment will be migrated to their new apartment stash.
  • Allows players to purchase and list houses for sale through bl-realtor and the realtor job
  • Houses come with personal garages
  • Houses and apartments come with personal wardrobes and stashes
  • Players can share keys to their houses and apartments with other players

Creating a new property for sale

Players 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.

  • Pick the location where you want to create a new property
  • Use /housing to open the housing menu
  • Click on create new property
  • Fill out the details of the property (name, price, description, which shell to use, etc)
  • Choose the door location (this is where the person will enter the house)
    • Ensure that you place it up against a wall, since players will use target to enter the house
  • Choose the garage location
    • This point is used both for storing vehicles, as well as the location where the vehicle will spawn when taken out of the garage
  • Realtors can edit the details of the property by clicking on the property in the housing menu
  • Players can see the properties for sale through the /housing menu as well

Furnish and decorate a property

Once 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.

Dynamic Doors

Dynamic Doors will turn placed doors into actual working doors, Instead of them being static. (See videos below)

Preview

DynamicDoorsOff.mp4
DynamicDoorsOn.mp4

Setup

  • You will need to set the Config.DynamicDoors = true
  • You will have to add this convar into your server.cfg setr game_enableDynamicDoorCreation "true"

Note: The convar has to be in your server.cfg in order for the doors to be dynamic!

Shell Support

Important

  • 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.

Installation

PAY ATTENTION TO EACH STEP. DO NOT SKIP ANY.

  1. Find the following events in 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)
  1. Find the following events in 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)
  1. Find the following events in 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)
  1. 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.

  2. Delete default qb-apartments

  3. Delete default qb-houses

  4. Delete qb-apartments/config.lua references in qb-spawn, qb-multicharacter and qb-phone fxmanifest.lua (and any other scripts that may reference it).

  5. Ensure bl-realtor above ps-housing.

  6. In your server.cfg, add ensure ox_lib above all other resources

  7. Install the dependencies below.

Item Limits System

  1. Choose an item you want to limit under Config.Furniture in under shared/config.lua
  2. Add ["max"] = 3 or the number of your choice to the item (see example below)
{ ["object"] = "v_res_r_figcat", ["price"] = 300, ["max"] = 2, ["label"] = "Fig Cat" },

Logs System Setup

  1. Go to qb-smallresources/server/logs.lua and add this:
    ['pshousing'] = 'yourdiscordwebhookhere',
  1. Create a webhook for the channel you want the logs to show up in.
  2. Replace the placeholder with your webhook link.

This system only supports qb-core for now.

Dependency

  1. bl-realtor
  2. five-freecam
  3. ox_lib - Use the latest release. If you do not use the latest release, MAKE SURE TO BUILD THE UI. Find their docs here on how to build the UI.
  4. ox_target or qb-target - Change in Config, default is qb-target.

For reference your server.cfg should be ensured like below:

  • We highly recommend making a folder named [ps-housing] and add bl-realtor, fivem-freecam, ox_lib, ps-core, ps-housing inside the folder.
ensure ox_lib
ensure ps-housing
ensure bl-realtor
ensure fivem-freecam

To Do

  • Remake Realtor UI

Notes

  • If a player is in their apartment/house and an admin does a "Bring to me" function, they will not see the player nor will the player see anyone else. This is because the player is still in their own unique routing bucket. Workaround: To fix this, the player must go back into their apartment and leave on their own.
    • Likewise, if an admin tries to "Go to" or "Spectate" a player that is in their apartment/house, the admin will not be able to see the apartment or player because it is in a different routing bucket.

Credits

About

Advanced housing system for QBCore.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 84.1%
  • Svelte 11.8%
  • TypeScript 2.5%
  • Other 1.6%