[QB/ESX] Adding ox_inventory crafting in Base Building
This snippet will help you setup the crafting from ox-inventory as events to use on other scripts like hrs_base_building
In ox_inventory
lib.callback.register('ox_inventory:craftItem', function(source, id, index, recipeId, toSlot)
local left, bench = Inventory(source), CraftingBenches[id]
if bench then
local groups = bench.groups
-- DELETE THIS local coords = shared.target and bench.zones[index].coords or bench.points[index]
if groups and not server.hasGroup(left, groups) then return end
-- DELETE THIS if #(GetEntityCoords(GetPlayerPed(source)) - coords) > 10 then return end lib.callback.register('ox_inventory:openCraftingBench', function(source, id, index)
local left, bench = Inventory(source), CraftingBenches[id]
if not left then return end
if bench then
local groups = bench.groups
-- DELETE THIS local coords = getCraftingCoords(source, bench, index)
-- DELETE THIS if not coords then return end
if groups and not server.hasGroup(left, groups) then return end
-- DELETE THIS if #(GetEntityCoords(GetPlayerPed(source)) - coords) > 10 then return end
if left.open and left.open ~= source then
local inv = Inventory(left.open) --[[@as OxInventory]]
-- Why would the player inventory open with an invalid target? Can't repro but whatever.
if inv?.player then
inv:closeInventory()
end
end
left:openInventory(left)
end
return { label = left.label, type = left.type, slots = left.slots, weight = left.weight, maxWeight = left.maxWeight }
end)In HRS_base_building
Previous[QB/ESX] Adding quasar inventory crafting in Base BuildingNext[QB] Adding qb-inventory crafting in Base Building
Last updated