[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

ox_inventory\modules\crafting\server.lua

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 

ox_inventory\modules\crafting\server.lua

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)

ox_inventory\client.lua

ox_inventory\client.lua

ox_inventory\data\crafting.lua (this are just examples of 3 crafting tables)

In HRS_base_building

hrs_base_building\config.lua

  • EXAMPLE

Last updated