forked from Simnation/Main
ed
This commit is contained in:
parent
0156a8765f
commit
e4adefe73d
2 changed files with 37 additions and 6 deletions
|
@ -17,12 +17,19 @@ CreateThread(function()
|
|||
end
|
||||
end)
|
||||
|
||||
-- Hook für Item Usage (Client-seitig)
|
||||
RegisterNetEvent('tgiann-inventory:client:UseItem', function(itemName, itemData)
|
||||
-- Registriere Event für Item-Nutzung (wichtig: das ist der korrekte Event für tgiann-inventory)
|
||||
RegisterNetEvent('inventory:client:UseItem')
|
||||
AddEventHandler('inventory:client:UseItem', function(item)
|
||||
local itemName = item.name
|
||||
|
||||
-- Prüfe ob das verwendete Item Pfand generiert
|
||||
if Config.ConsumableItems[itemName] then
|
||||
-- Informiere den Server über die Item-Nutzung
|
||||
TriggerServerEvent('qb-pfandsystem:server:itemConsumed', itemName)
|
||||
|
||||
if Config.Debug then
|
||||
print('[Pfandsystem] Item verwendet: ' .. itemName)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
|
@ -12,7 +12,10 @@ RegisterNetEvent('qb-pfandsystem:server:itemConsumed', function(itemName)
|
|||
local consumableConfig = Config.ConsumableItems[itemName]
|
||||
local pfandItem = consumableConfig.pfandItem
|
||||
|
||||
-- Verwende Player.Functions.AddItem statt tgiann-inventory
|
||||
-- Warte kurz damit das originale Item erst konsumiert wird
|
||||
Wait(500)
|
||||
|
||||
-- Verwende Player.Functions.AddItem
|
||||
local success = Player.Functions.AddItem(pfandItem, 1)
|
||||
|
||||
if success then
|
||||
|
@ -136,9 +139,11 @@ QBCore.Functions.CreateCallback('qb-pfandsystem:server:getPfandItems', function(
|
|||
cb(pfandItems)
|
||||
end)
|
||||
|
||||
-- Event-Handler für Item-Nutzung
|
||||
RegisterNetEvent('tgiann-inventory:itemUsed')
|
||||
AddEventHandler('tgiann-inventory:itemUsed', function(source, itemName, itemData)
|
||||
-- Zusätzliche Event-Handler für verschiedene Inventarsysteme
|
||||
RegisterNetEvent('inventory:server:UseItem')
|
||||
AddEventHandler('inventory:server:UseItem', function(source, item)
|
||||
local itemName = type(item) == "table" and item.name or item
|
||||
|
||||
if Config.ConsumableItems[itemName] then
|
||||
SetTimeout(100, function()
|
||||
TriggerEvent('qb-pfandsystem:server:itemConsumed', itemName)
|
||||
|
@ -146,6 +151,25 @@ AddEventHandler('tgiann-inventory:itemUsed', function(source, itemName, itemData
|
|||
end
|
||||
end)
|
||||
|
||||
-- Für tgiann-inventory
|
||||
RegisterNetEvent('tgiann-inventory:itemUsed')
|
||||
AddEventHandler('tgiann-inventory:itemUsed', function(source, itemName)
|
||||
if Config.ConsumableItems[itemName] then
|
||||
SetTimeout(100, function()
|
||||
TriggerEvent('qb-pfandsystem:server:itemConsumed', itemName)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Debug-Befehl zum manuellen Auslösen
|
||||
RegisterCommand('pfanditem', function(source, args)
|
||||
if Config.Debug then
|
||||
if args[1] and source > 0 then
|
||||
TriggerEvent('qb-pfandsystem:server:itemConsumed', args[1])
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Export für andere Scripts
|
||||
exports('ConsumePfandItem', function(source, itemName)
|
||||
TriggerEvent('qb-pfandsystem:server:itemConsumed', itemName)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue