From ec9ff993e4211fecb16779607e83bf8e32bce196 Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Mon, 28 Jul 2025 23:34:19 +0200 Subject: [PATCH] 1 --- .../modules/pfandsystem/server.lua | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/resources/[inventory]/pickle_consumables/modules/pfandsystem/server.lua b/resources/[inventory]/pickle_consumables/modules/pfandsystem/server.lua index 47d7c7c8c..0d2b9637e 100644 --- a/resources/[inventory]/pickle_consumables/modules/pfandsystem/server.lua +++ b/resources/[inventory]/pickle_consumables/modules/pfandsystem/server.lua @@ -1,4 +1,4 @@ --- modules/pfandsystem/server.lua (mit direkten QBCore-Funktionen) +-- modules/pfandsystem/server.lua (mit direkten tgiann-inventory Funktionen) local QBCore = exports['qb-core']:GetCoreObject() @@ -16,8 +16,9 @@ RegisterNetEvent('pickle_consumables:server:redeemPfand', function(selectedItems -- Prüfe ob alle Items verfügbar sind for itemName, quantity in pairs(selectedItems) do if Config.PfandItems[itemName] then - local item = Player.Functions.GetItemByName(itemName) - if not item or item.amount < quantity then + -- Verwende tgiann-inventory Export + local item = exports['tgiann-inventory']:GetItem(src, itemName) + if not item or item.count < quantity then canRedeem = false TriggerClientEvent('QBCore:Notify', src, 'Du hast nicht genug ' .. (Config.PfandItems[itemName].label or itemName), "error") return @@ -29,10 +30,9 @@ RegisterNetEvent('pickle_consumables:server:redeemPfand', function(selectedItems -- Entferne Items und berechne Pfand for itemName, quantity in pairs(selectedItems) do if Config.PfandItems[itemName] then - local removed = Player.Functions.RemoveItem(itemName, quantity) + -- Verwende tgiann-inventory Export + local removed = exports['tgiann-inventory']:RemoveItem(src, itemName, quantity) if removed then - TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[itemName], "remove", quantity) - local pfandWert = Config.PfandItems[itemName].pfandwert * quantity totalPfand = totalPfand + pfandWert totalItems = totalItems + quantity @@ -59,20 +59,18 @@ end) -- Hole verfügbare Pfand Items des Spielers lib.callback.register('pickle_consumables:server:getPfandItems', function(source) local src = source - local Player = QBCore.Functions.GetPlayer(src) local pfandItems = {} - if not Player then return pfandItems end - for itemName, itemConfig in pairs(Config.PfandItems) do - local item = Player.Functions.GetItemByName(itemName) + -- Verwende tgiann-inventory Export + local item = exports['tgiann-inventory']:GetItem(src, itemName) - if item and item.amount > 0 then + if item and item.count > 0 then pfandItems[itemName] = { - count = item.amount, + count = item.count, label = itemConfig.label, pfandwert = itemConfig.pfandwert, - totalWert = itemConfig.pfandwert * item.amount + totalWert = itemConfig.pfandwert * item.count } end end @@ -85,12 +83,8 @@ AddEventHandler('pickle_consumables:itemUsed', function(source, itemName, itemDa -- Prüfe ob das Item ein Pfand-Item generiert local itemConfig = Config.Items[itemName] if itemConfig and itemConfig.pfandItem and Config.PfandItems[itemConfig.pfandItem] then - local Player = QBCore.Functions.GetPlayer(source) - if not Player then return end - - -- Gebe Pfand-Item - Player.Functions.AddItem(itemConfig.pfandItem, 1) - TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items[itemConfig.pfandItem], "add", 1) + -- Gebe Pfand-Item mit tgiann-inventory + exports['tgiann-inventory']:AddItem(source, itemConfig.pfandItem, 1) if Config.PfandSystem.showNotification then local pfandLabel = Config.PfandItems[itemConfig.pfandItem].label