Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for apartments not being able to have a stash #232

Merged
merged 11 commits into from
Sep 23, 2024
2 changes: 1 addition & 1 deletion README - INSTALL INSTRUCTIONS/QBCore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ RegisterNUICallback('spawnplayer', function(data, cb)
TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
TriggerEvent('QBCore:Client:OnPlayerLoaded')
local property_id = data.spawnloc.property_id
TriggerServerEvent('ps-housing:server:enterProperty', tostring(property_id))
TriggerServerEvent('ps-housing:server:enterProperty', tostring(property_id), 'spawn')
PostSpawnPlayer()
elseif type == "normal" then
local pos = QB.Spawns[location].coords
Expand Down
2 changes: 1 addition & 1 deletion README - INSTALL INSTRUCTIONS/QBOX/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ local function inputHandler()

local spawnData = spawns[currentButtonID]
if spawnData.propertyId then
TriggerServerEvent('ps-housing:server:enterProperty', tostring(spawnData.propertyId))
TriggerServerEvent('ps-housing:server:enterProperty', tostring(spawnData.propertyId), 'spawn')
else
SetEntityCoords(cache.ped, spawnData.coords.x, spawnData.coords.y, spawnData.coords.z, false, false, false, false)
SetEntityHeading(cache.ped, spawnData.coords.w or 0.0)
Expand Down
11 changes: 9 additions & 2 deletions client/cl_property.lua
Original file line number Diff line number Diff line change
Expand Up @@ -909,9 +909,16 @@ function Property.Get(property_id)
return PropertiesTable[tostring(property_id)]
end

RegisterNetEvent("ps-housing:client:enterProperty", function(property_id)
RegisterNetEvent("ps-housing:client:enterProperty", function(property_id, spawn)
local property = Property.Get(property_id)
property:EnterShell()
if spawn == 'spawn' then
local data = lib.callback.await("ps-housing:cb:getMainMloDoor", false, property_id, 1)
if not data then property:EnterShell() return end
SetEntityCoords(PlayerPedId(), data.objCoords.x, data.objCoords.y, data.objCoords.z)
return
else
property:EnterShell()
end
end)

RegisterNetEvent("ps-housing:client:updateDoorbellPool", function(property_id, data)
Expand Down
19 changes: 13 additions & 6 deletions server/sv_property.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function Property:PlayerEnter(src)
if not isMlo then
TriggerClientEvent('qb-weathersync:client:DisableSync', src)
end

TriggerClientEvent('ps-housing:client:enterProperty', src, self.property_id)
print(src, self.property_id)
TriggerClientEvent('ps-housing:client:enterProperty', src, self.property_id, isMlo, self.propertyData)

if next(self.playersDoorbell) then
TriggerClientEvent("ps-housing:client:updateDoorbellPool", src, self.property_id, self.playersDoorbell)
Expand Down Expand Up @@ -565,12 +565,11 @@ RegisterNetEvent('ps-housing:server:enterGarden', function (property_id)
property.playersInGarden[tostring(src)] = true
end)

RegisterNetEvent('ps-housing:server:enterProperty', function (property_id)
RegisterNetEvent('ps-housing:server:enterProperty', function (property_id, spawn)
local src = source
Debug("Player is trying to enter property", property_id)

local property = Property.Get(property_id)

if not property then
Debug("Properties returned", json.encode(PropertiesTable, {indent = true}))
return
Expand All @@ -580,7 +579,11 @@ RegisterNetEvent('ps-housing:server:enterProperty', function (property_id)

if property:CheckForAccess(citizenid) then
Debug("Player has access to property")
property:PlayerEnter(src)
if spawn == 'spawn' then
TriggerClientEvent("ps-housing:client:enterProperty", src, property_id, spawn)
else
property:PlayerEnter(src)
end
Debug("Player entered property")
return
end
Expand Down Expand Up @@ -796,7 +799,11 @@ RegisterNetEvent("ps-housing:server:buyFurniture", function(property_id, items,
if item.type == 'storage' then
local stashName = ("property_%s"):format(propertyData.property_id)
local stashConfig = Config.Shells[propertyData.shell].stash
Framework[Config.Inventory].RegisterInventory(firstStorage and stashName or stashName..item.id, 'Property: ' .. propertyData.street .. ' #'.. propertyData.property_id or propertyData.apartment or stashName, stashConfig)
if not propertyData.apartment then
Framework[Config.Inventory].RegisterInventory(firstStorage and stashName or stashName .. item.id, 'Property: ' .. propertyData.street .. '#' .. propertyData.property_id, stashConfig)
else
Framework[Config.Inventory].RegisterInventory(firstStorage and stashName or stashName .. item.id, 'Property: ' .. propertyData.apartment .. '#' .. propertyData.property_id, stashConfig)
end
end
numFurnitures = numFurnitures + 1
propertyData.furnitures[numFurnitures] = item
Expand Down
2 changes: 1 addition & 1 deletion shared/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Config = {}
Config.Target = "qb" -- "ox" or "qb"
Config.Notify = "qb" -- "ox" or "qb"
Config.Radial = "qb" -- "ox" or "qb"
Config.Inventory = "ox" -- "ox" or "qb"
Config.Inventory = "qb" -- "ox" or "qb"
Config.Logs = "qb" -- "qb"

-- Anyone provided with keys to a property has the ability to modify its furnishings.
Expand Down