@@ -15,31 +15,41 @@ local isHotbar = false
1515local WeaponAttachments = {}
1616local 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+
1826local 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)
398408end )
399409
400410RegisterNetEvent (' 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 )
544564end )
@@ -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 )
571591end )
@@ -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 )
590610end )
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)
829849end )
830850
831851RegisterNUICallback (' Notify' , function (data , cb )
832- QBCore . Functions . Notify (data .message , data .type )
852+ Notify (data .message , data .type )
833853 cb (' ok' )
834854end )
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' )
943963end )
@@ -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' )
974994end )
0 commit comments