Skip to content

Commit 4db93dd

Browse files
committed
- fix ox compat
- fix getNearbyPlayers for qbx
1 parent 23b3dfd commit 4db93dd

4 files changed

Lines changed: 18 additions & 26 deletions

File tree

bridge/framework/qbx/server.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ function ps.getNearbyPlayers(source, distance)
237237
if not distance then distance = 10.0 end
238238
local players = {}
239239
for k, v in pairs(ps.getAllPlayers()) do
240-
local dist = #(GetEntityCoords(GetPlayerPed(v)) - GetEntityCoords(GetPlayerPed(source)))
240+
local dist = #(GetEntityCoords(GetPlayerPed(v.PlayerData.source)) - GetEntityCoords(GetPlayerPed(source)))
241241
if dist < 5.0 then
242242
table.insert(players, {
243-
value = ps.getIdentifier(v),
244-
label = ps.getPlayerName(v),
245-
source = v,
243+
value = ps.getIdentifier(v.PlayerData.source),
244+
label = ps.getPlayerName(v.PlayerData.source),
245+
source = v.PlayerData.source,
246246
distance = dist,
247247
})
248248
end
@@ -551,7 +551,7 @@ end
551551
function ps.getSharedJobGradeData(job, rank, data)
552552
local jobData = ps.getSharedJob(job)
553553
if not jobData then return nil end
554-
local gradeData = jobData.grades[tostring(rank)]
554+
local gradeData = jobData.grades[tonumber(rank)]
555555
if not gradeData then return nil end
556556
return gradeData[data] or nil
557557
end
@@ -569,9 +569,9 @@ function ps.getSharedGangData(gang, data)
569569
end
570570

571571
function ps.getSharedGangRankData(gang, rank, data)
572-
local gangData = QBCore.Shared.Gangs[gang]
572+
local gangData = exports.qbx_core:GetGangs()[gang]
573573
if not gangData then return nil end
574-
local gradeData = gangData.grades[tostring(rank)]
574+
local gradeData = gangData.grades[tonumber(rank)]
575575
if not gradeData then return nil end
576576
return gradeData[data] or nil
577577
end

bridge/inventory/ox/client/ox.lua

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ function ps.hasItems(items)
4747
end
4848

4949
RegisterNetEvent('ps_lib:client:createShop', function(shopData)
50-
if not shopData.name then shopData.name = 'Shop' end
51-
if not shopData.slots then shopData.slots = 50 end
52-
if not shopData.maxweight then shopData.maxweight = 100000 end
53-
exports.ox_inventory:RegisterShop(shopData.name, {
54-
name = shopData.name,
55-
slots = shopData.slots,
56-
maxweight = shopData.maxweight,
57-
items = shopData.items or {},
58-
})
50+
if not shopData then shopData.name = 'Shop' end
5951
exports.ox_inventory:openInventory('shop', { type = shopData, id = shopData })
6052
end)

bridge/inventory/ox/server/ox.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
function ps.CanCarryItem(source, item, amount)
33
if not source or not item then return end
44
if not amount then amount = 1 end
5-
return exports.ox_inventory:CanCarryItem(source, item, amount)
5+
local can = exports.ox_inventory:CanCarryItem(source, item, amount)
6+
return can
67
end
78

89
function ps.removeItem(identifier, item, amount, slot, reason)
@@ -86,15 +87,14 @@ function ps.createShop(source, shopData)
8687
end
8788

8889
function ps.verifyRecipe(source, recipe)
89-
if not source or not recipe then return false end
90-
local requiredItems = recipe.requiredItems or {}
91-
for item, amount in pairs(requiredItems) do
92-
if not ps.hasItem(source, item, amount) then
93-
ps.notify(source, 'You need ' .. amount .. ' ' .. ps.getLabel(item) .. ' to craft this.', 'error')
94-
return false
90+
local need, have = 0,0
91+
for k, v in pairs (recipe) do
92+
if ps.getItemCount(source, k) >= v then
93+
have = have + 1
9594
end
95+
need = need + 1
9696
end
97-
return true
97+
return have >= need
9898
end
9999

100100
function ps.craftItem(source, recipe)

fxmanifest.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description 'Project Sloth Library'
1010
author 'Project Sloth'
1111

1212
client_scripts {
13-
--'@qbx_core/modules/playerdata.lua',
13+
'@qbx_core/modules/playerdata.lua',
1414
'startFirst/client/**.lua',
1515
'modules/**/client/**.lua',
1616
'bridge/client.lua',
@@ -26,7 +26,7 @@ server_scripts {
2626
shared_scripts {
2727
'Config.lua',
2828
'startFirst/shared/**.lua',
29-
--'@ox_lib/init.lua',
29+
'@ox_lib/init.lua',
3030
'modules/**/shared/**.lua',
3131
'init.lua'
3232
}

0 commit comments

Comments
 (0)