diff --git a/resources/[inventory]/pickle_consumables/modules/pfandsystem/server.lua b/resources/[inventory]/pickle_consumables/modules/pfandsystem/server.lua index cbbb573dd..cb4dc999b 100644 --- a/resources/[inventory]/pickle_consumables/modules/pfandsystem/server.lua +++ b/resources/[inventory]/pickle_consumables/modules/pfandsystem/server.lua @@ -3,9 +3,6 @@ -- Pfand einlösen RegisterNetEvent('pickle_consumables:server:redeemPfand', function(selectedItems) local src = source - local Player = GetPlayer(src) - - if not Player then return end local totalPfand = 0 local totalItems = 0 @@ -14,10 +11,10 @@ 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 hasItem = HasItem(src, itemName, quantity) - if not hasItem then + -- Verwende Framework.HasItem statt HasItem + if not Framework.HasItem(src, itemName, quantity) then canRedeem = false - ShowNotification(src, 'Du hast nicht genug ' .. (Config.PfandItems[itemName].label or itemName), "error") + Framework.Notify(src, 'Du hast nicht genug ' .. (Config.PfandItems[itemName].label or itemName), "error") return end end @@ -27,7 +24,8 @@ 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 = RemoveItem(src, itemName, quantity) + -- 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 @@ -39,27 +37,27 @@ RegisterNetEvent('pickle_consumables:server:redeemPfand', function(selectedItems if totalPfand > 0 then -- Gebe Geld if Config.PfandSystem.currency == 'cash' then - AddMoney(src, 'cash', totalPfand) + Framework.AddMoney(src, 'cash', totalPfand) else - AddMoney(src, 'bank', totalPfand) + Framework.AddMoney(src, 'bank', totalPfand) end -- Formatiere Geld für Anzeige local moneyString = string.format("€%.2f", totalPfand / 100) - ShowNotification(src, string.format(_L('pfand_success'), moneyString, totalItems), "success") + Framework.Notify(src, string.format(_L('pfand_success'), moneyString, totalItems), "success") end end end) -- Hole verfügbare Pfand Items des Spielers --- Verwende lib.callback.register statt RegisterCallback lib.callback.register('pickle_consumables:server:getPfandItems', function(source) local src = source local pfandItems = {} for itemName, itemConfig in pairs(Config.PfandItems) do - local itemCount = GetItemCount(src, itemName) + -- Verwende Framework.GetItemCount statt GetItemCount + local itemCount = Framework.GetItemCount(src, itemName) if itemCount > 0 then pfandItems[itemName] = { @@ -80,11 +78,11 @@ AddEventHandler('pickle_consumables:itemUsed', function(source, itemName, itemDa local itemConfig = Config.Items[itemName] if itemConfig and itemConfig.pfandItem and Config.PfandItems[itemConfig.pfandItem] then -- Gebe Pfand-Item - AddItem(source, itemConfig.pfandItem, 1) + Framework.AddItem(source, itemConfig.pfandItem, 1) if Config.PfandSystem.showNotification then local pfandLabel = Config.PfandItems[itemConfig.pfandItem].label - ShowNotification(source, string.format(_L('pfand_received'), pfandLabel), "success") + Framework.Notify(source, string.format(_L('pfand_received'), pfandLabel), "success") end end end)