-- modules/pfandsystem/server.lua (korrigiert) -- Pfand einlösen RegisterNetEvent('pickle_consumables:server:redeemPfand', function(selectedItems) local src = source local totalPfand = 0 local totalItems = 0 local canRedeem = true -- Prüfe ob alle Items verfügbar sind for itemName, quantity in pairs(selectedItems) do if Config.PfandItems[itemName] then -- Verwende Framework.HasItem statt HasItem if not Framework.HasItem(src, itemName, quantity) then canRedeem = false Framework.Notify(src, 'Du hast nicht genug ' .. (Config.PfandItems[itemName].label or itemName), "error") return end end end if canRedeem then -- Entferne Items und berechne Pfand for itemName, quantity in pairs(selectedItems) do if Config.PfandItems[itemName] then -- Verwende Framework.RemoveItem statt RemoveItem local removed = Framework.RemoveItem(src, itemName, quantity) if removed then local pfandWert = Config.PfandItems[itemName].pfandwert * quantity totalPfand = totalPfand + pfandWert totalItems = totalItems + quantity end end end if totalPfand > 0 then -- Gebe Geld if Config.PfandSystem.currency == 'cash' then Framework.AddMoney(src, 'cash', totalPfand) else Framework.AddMoney(src, 'bank', totalPfand) end -- Formatiere Geld für Anzeige local moneyString = string.format("€%.2f", totalPfand / 100) Framework.Notify(src, string.format(_L('pfand_success'), moneyString, totalItems), "success") end end end) -- Hole verfügbare Pfand Items des Spielers lib.callback.register('pickle_consumables:server:getPfandItems', function(source) local src = source local pfandItems = {} for itemName, itemConfig in pairs(Config.PfandItems) do -- Verwende Framework.GetItemCount statt GetItemCount local itemCount = Framework.GetItemCount(src, itemName) if itemCount > 0 then pfandItems[itemName] = { count = itemCount, label = itemConfig.label, pfandwert = itemConfig.pfandwert, totalWert = itemConfig.pfandwert * itemCount } end end return pfandItems end) -- Hook für Item-Nutzung AddEventHandler('pickle_consumables:itemUsed', function(source, itemName, itemData, slot) -- 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 -- Gebe Pfand-Item Framework.AddItem(source, itemConfig.pfandItem, 1) if Config.PfandSystem.showNotification then local pfandLabel = Config.PfandItems[itemConfig.pfandItem].label Framework.Notify(source, string.format(_L('pfand_received'), pfandLabel), "success") end end end)