[QB/ESX] Adding quasar inventory crafting in Base Building
This snippet will help you setup crafting from quasar inventory as events to use on other scripts like hrs_base_building
In qs-inventory
qs-inventory\(any open client file).lua
In this code I created 3 types of crafting tables as an example, you can create the ones you want and choose the craftings you want
Config.craftingType = {
['med_table'] = {
[1] = {
name = "weapon_carbinerifle",
amount = 1,
info = {},
costs = {
["tosti"] = 1,
},
type = "weapon",
slot = 1,
threshold = 0,
points = 1,
time = 5000,
rep = 'attachmentcraftingrep',
chance = 100
},
[2] = {
name = "tosti",
amount = 1,
info = {},
costs = {
["weapon_carbinerifle"] = 1,
},
type = "item",
slot = 2,
threshold = 0,
points = 1,
time = 5000,
rep = 'attachmentcraftingrep',
chance = 100
},
},
['weapon_table'] = {
[1] = {
name = "weapon_carbinerifle",
amount = 1,
info = {},
costs = {
["tosti"] = 1,
},
type = "weapon",
slot = 1,
threshold = 0,
points = 1,
time = 5000,
rep = 'attachmentcraftingrep',
chance = 100
},
[2] = {
name = "tosti",
amount = 1,
info = {},
costs = {
["weapon_carbinerifle"] = 1,
},
type = "item",
slot = 2,
threshold = 0,
points = 1,
time = 5000,
rep = 'attachmentcraftingrep',
chance = 100
},
},
['normal_table'] = {
[1] = {
name = "weapon_carbinerifle",
amount = 1,
info = {},
costs = {
["tosti"] = 1,
},
type = "weapon",
slot = 1,
threshold = 0,
points = 1,
time = 5000,
rep = 'attachmentcraftingrep',
chance = 100
},
[2] = {
name = "tosti",
amount = 1,
info = {},
costs = {
["weapon_carbinerifle"] = 1,
},
type = "item",
slot = 2,
threshold = 0,
points = 1,
time = 5000,
rep = 'attachmentcraftingrep',
chance = 100
},
},
}
function OpenCrafting(tab)
if Config.craftingType[tab] then
local crafting = {
label = 'Craft',
items = exports['qs-inventory']:SetUpCrafing(Config.craftingType[tab])
}
TriggerServerEvent('inventory:server:SetInventoryItems', Config.craftingType[tab])
TriggerServerEvent("inventory:server:OpenInventory", "customcrafting", crafting.label, crafting)
end
end
AddEventHandler('openCraftingTable',function(tab)
OpenCrafting(tab)
end)
In hrs_base_building
hrs_base_building\config.lua
["prop_tool_bench02_ld"] = {
item = "prop_tool_bench02_ld",
life = 10000.0,
type = "crafting",
subtype = "findGroud",
noFoundationNeed = true,
TriggerEvent = {
type = "client",
event = 'openCraftingTable',
args = {'normal_table'}, --- agrs in order
entityAsArg = "hrs_base_entity" --- in the arguments, this word will be replaced by the Entity
},
crafting = {
{name = "wood",count = 20}
}
},
["bkr_prop_meth_table01a"] = {
item = "bkr_prop_meth_table01a",
life = 20000.0,
type = "crafting",
subtype = "findGroud",
TriggerEvent = {
type = "client",
event = 'openCraftingTable',
args = {'med_table'}, --- agrs in order
},
crafting = {
{name = "wood",count = 20},
{name = "metalscrap",count = 20}
}
},
["gr_prop_gr_bench_02a"] = {
item = "gr_prop_gr_bench_02a",
life = 20000.0,
type = "crafting",
subtype = "findGroud",
TriggerEvent = {
type = "client",
event = 'openCraftingTable',
args = {'weapon_table'}, --- agrs in order
},
crafting = {
{name = "wood",count = 20},
{name = "metalscrap",count = 20}
}
},
Previous[QB] Adding qb-crafting crafting in Base BuildingNext[QB/ESX] Adding ox_inventory crafting in Base Building
Last updated