2022-04-13 20:01:09 +01:00
|
|
|
local QBCore = exports['qb-core']:GetCoreObject()
|
|
|
|
|
|
2022-08-24 09:23:43 +01:00
|
|
|
for k, v in pairs(Config.Consumables) do
|
|
|
|
|
QBCore.Functions.CreateUseableItem(k, function(source, item) TriggerClientEvent('jim-consumables:Consume', source, item.name) end)
|
|
|
|
|
if not QBCore.Shared.Items[k] then print("Item check - '"..k.."' not found in the shared lua") end
|
|
|
|
|
if not Config.Emotes[v.emote] then print("Emote check - '"..k.."' requested emote '"..v.emote.."' - not found in config.lua") end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RegisterNetEvent('jim-consumables:server:toggleItem', function(give, item, amount)
|
|
|
|
|
local src = source
|
|
|
|
|
if give == 0 or give == false then
|
|
|
|
|
if QBCore.Functions.GetPlayer(src).Functions.RemoveItem(item, amount or 1) then
|
|
|
|
|
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "remove", amount or 1)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if QBCore.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then
|
|
|
|
|
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[item], "add", amount or 1)
|
|
|
|
|
end
|
2022-08-15 10:06:30 +01:00
|
|
|
end
|
2022-08-24 09:23:43 +01:00
|
|
|
end)
|