Skip to content

Commit 57cfdd2

Browse files
Merge pull request #124 from Mustachedom/main
Fix for new qb and new features
2 parents 02e3a06 + 5627adb commit 57cfdd2

File tree

4 files changed

+131
-91
lines changed

4 files changed

+131
-91
lines changed

client/main.lua

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,41 @@ local isHotbar = false
1515
local WeaponAttachments = {}
1616
local showBlur = true
1717

18+
local function Notify(text, type)
19+
if Config.Notify =='ox' then
20+
lib.notify({title = text, type = type})
21+
elseif Config.Notify == 'qb' then
22+
QBCore.Functions.Notify(text, type)
23+
end
24+
end
25+
1826
local function HasItem(items, amount)
1927
local isTable = type(items) == 'table'
2028
local isArray = isTable and table.type(items) == 'array' or false
2129
local totalItems = #items
2230
local count = 0
2331
local kvIndex = 2
24-
if isTable and not isArray then
32+
if isTable and not isArray then
2533
totalItems = 0
2634
for _ in pairs(items) do totalItems += 1 end
2735
kvIndex = 1
2836
end
29-
for _, itemData in pairs(PlayerData.items) do
30-
if isTable then
31-
for k, v in pairs(items) do
32-
local itemKV = {k, v}
33-
if itemData and itemData.name == itemKV[kvIndex] and ((amount and itemData.amount >= amount) or (not isArray and itemData.amount >= v) or (not amount and isArray)) then
34-
count += 1
37+
if next(PlayerData.items) and PlayerData.items ~= nil then
38+
for _, itemData in pairs(PlayerData.items) do
39+
if isTable then
40+
for k, v in pairs(items) do
41+
local itemKV = {k, v}
42+
if itemData and itemData.name == itemKV[kvIndex] and ((amount and itemData.amount >= amount) or (not isArray and itemData.amount >= v) or (not amount and isArray)) then
43+
count += 1
44+
end
45+
end
46+
if count == totalItems then
47+
return true
48+
end
49+
else
50+
if itemData and itemData.name == items and (not amount or (itemData and amount and itemData.amount >= amount)) then
51+
return true
3552
end
36-
end
37-
if count == totalItems then
38-
return true
39-
end
40-
else -- Single item as string
41-
if itemData and itemData.name == items and (not amount or (itemData and amount and itemData.amount >= amount)) then
42-
return true
4353
end
4454
end
4555
end
@@ -398,6 +408,16 @@ RegisterNetEvent('ps-inventory:client:CheckOpenState', function(type, id, label)
398408
end)
399409

400410
RegisterNetEvent('ps-inventory:client:ItemBox', function(itemData, type, amount)
411+
--amount = amount or 1
412+
--SendNUIMessage({
413+
-- action = "itemBox",
414+
-- item = itemData,
415+
-- type = type,
416+
-- itemAmount = amount
417+
--})
418+
end)
419+
420+
RegisterNetEvent('ps-inventory:client:ItemBox2', function(itemData, type, amount)
401421
amount = amount or 1
402422
SendNUIMessage({
403423
action = "itemBox",
@@ -538,7 +558,7 @@ RegisterNetEvent('ps-inventory:client:CraftItems', function(itemName, itemCosts,
538558
isCrafting = false
539559
end, function() -- Cancel
540560
StopAnimTask(ped, "mini@repair", "fixing_a_player", 1.0)
541-
QBCore.Functions.Notify("Failed", "error")
561+
Notify("Failed", "error")
542562
isCrafting = false
543563
end)
544564
end)
@@ -565,7 +585,7 @@ RegisterNetEvent('ps-inventory:client:CraftAttachment', function(itemName, itemC
565585
isCrafting = false
566586
end, function() -- Cancel
567587
StopAnimTask(ped, "mini@repair", "fixing_a_player", 1.0)
568-
QBCore.Functions.Notify("Failed", "error")
588+
Notify("Failed", "error")
569589
isCrafting = false
570590
end)
571591
end)
@@ -585,7 +605,7 @@ RegisterNetEvent('ps-inventory:client:PickupSnowballs', function()
585605
TriggerEvent('ps-inventory:client:ItemBox', QBCore.Shared.Items["snowball"], "add")
586606
end, function() -- Cancel
587607
ClearPedTasks(ped)
588-
QBCore.Functions.Notify("Canceled", "error")
608+
Notify("Canceled", "error")
589609
end)
590610
end)
591611

@@ -741,7 +761,7 @@ RegisterCommand('inventory', function()
741761
curVeh = vehicle
742762
CurrentGlovebox = nil
743763
else
744-
QBCore.Functions.Notify("Vehicle locked.", "error")
764+
Notify("Vehicle locked.", "error")
745765
return
746766
end
747767
else
@@ -829,7 +849,7 @@ RegisterNUICallback('RobMoney', function(data, cb)
829849
end)
830850

831851
RegisterNUICallback('Notify', function(data, cb)
832-
QBCore.Functions.Notify(data.message, data.type)
852+
Notify(data.message, data.type)
833853
cb('ok')
834854
end)
835855

@@ -937,7 +957,7 @@ RegisterNUICallback('combineWithAnim', function(data, cb)
937957
TriggerServerEvent('ps-inventory:server:combineItem', combineData.reward, data.requiredItem, data.usedItem)
938958
end, function() -- Cancel
939959
StopAnimTask(ped, aDict, aLib, 1.0)
940-
QBCore.Functions.Notify("Failed", "error")
960+
Notify("Failed", "error")
941961
end)
942962
cb('ok')
943963
end)
@@ -965,10 +985,10 @@ RegisterNUICallback("GiveItem", function(data, cb)
965985
SetCurrentPedWeapon(PlayerPedId(),'WEAPON_UNARMED',true)
966986
TriggerServerEvent("ps-inventory:server:GiveItem", playerId, data.item.name, data.amount, data.item.slot)
967987
else
968-
QBCore.Functions.Notify("You do not own this item!", "error")
988+
Notify("You do not own this item!", "error")
969989
end
970990
else
971-
QBCore.Functions.Notify("No one nearby!", "error")
991+
Notify("No one nearby!", "error")
972992
end
973993
cb('ok')
974994
end)

config.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ Config.MaxDropViewDistance = 12.5 -- The distance in GTA Units that a drop can b
1010
Config.UseItemDrop = false -- This will enable item object to spawn on drops instead of markers
1111
Config.ItemDropObject = `sf_prop_sf_backpack_01a` -- if Config.UseItemDrop is true, this will be the prop that spawns for the item
1212

13+
Config.Notify = 'qb' -- Notifications for either qb/ox
1314
Config.Progressbar = {
1415
Enable = false, -- True to Enable the progressbar while opening inventory
1516
minT = 350, -- Min Time for Inventory to open
1617
maxT = 500 -- Max Time for Inventory to open
1718
}
1819

20+
Config.Lang = {
21+
noaccess = "You Can Not Access This Inventory!",
22+
itemexist = "This Item Does Not Exist",
23+
}
24+
1925
Config.VendingObjects = {
2026
"prop_vend_soda_01",
2127
"prop_vend_soda_02",

fxmanifest.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ version '1.0.6'
66

77
shared_scripts {
88
'config.lua',
9-
'@qb-weapons/config.lua'
9+
'@qb-weapons/config.lua',
10+
'@ox_lib/init.lua',
1011
}
1112

1213
server_scripts {

0 commit comments

Comments
 (0)