πŸ“¦Placing Crafting Stations from an Item

This guide explains how to make a usable item that lets players place a crafting station in the world across three frameworks: OX (ox_inventory / ox_core), ESX, and QBCore.

OX (ox_inventory / ox_core)

Item definition (ox_inventory/data/items.lua)

['weaponcrafting'] = {
  label = 'Weapon Crafting',
  weight = 10,
  craftingType = 'weapon_crafting',
  server = {
    export = 'koja-crafting.place_crafting' -- see bridge below
  }
},

ESX

In ESX, you register the item as usable:

-- server.lua
ESX.RegisterUsableItem('weaponcrafting', function(playerId)
  local xPlayer = ESX.GetPlayerFromId(playerId)
  if not xPlayer then return end

  -- optional: remove item after use
  xPlayer.removeInventoryItem('weaponcrafting', 1)

  -- place crafting station
  exports['koja-crafting']:place_crafting({
    src = xPlayer.source,
    type = 'weapon_crafting',
  })
end)

QBCore

In QB, create a useable item:

Last updated