mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-16 22:16:02 +01:00
21 lines
1015 B
Lua
21 lines
1015 B
Lua
local QBCore = exports['qb-core']:GetCoreObject()
|
|
|
|
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
|
|
end
|
|
end) |