forked from Simnation/Main
23 lines
967 B
Lua
23 lines
967 B
Lua
-- modules/pfandsystem/init.lua
|
|
|
|
local QBCore = exports['qb-core']:GetCoreObject()
|
|
|
|
-- Überwache den Moment, wenn ein Item verbraucht wird
|
|
AddEventHandler('pickle_consumables:itemConsumed', function(source, itemName, itemData)
|
|
local src = source
|
|
local Player = QBCore.Functions.GetPlayer(src)
|
|
|
|
if not Player then return end
|
|
|
|
-- Prüfe ob das Item ein Pfand-Item generiert
|
|
if itemData and itemData.pfandItem and Config.PfandItems[itemData.pfandItem] then
|
|
-- Gebe Pfand-Item
|
|
Player.Functions.AddItem(itemData.pfandItem, 1)
|
|
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[itemData.pfandItem], "add", 1)
|
|
|
|
if Config.PfandSystem and Config.PfandSystem.showNotification then
|
|
local pfandLabel = Config.PfandItems[itemData.pfandItem].label
|
|
TriggerClientEvent('QBCore:Notify', src, 'Du hast ' .. pfandLabel .. ' erhalten!', "success")
|
|
end
|
|
end
|
|
end)
|