Skip to main content

🖥️ Instruction

A guide on how to use and customize the keep-crafting script for qbcore framework.
The keep-crafting script for the qbcore framework enables you to create and use workbenches for crafting items with different categories, recipes, materials, and success rates. In this guide, we will explain how to add a new workbench, category, and recipe.

How to add a new workbench

All workbenches are listed below Config.workbenches in config.lua. To add a new workbench, you need to enter the following information:

  • table_model: The model name of the workbench. If not specified, workbench_default_model is used.
  • coords: The vector3 coordinates where the workbench will spawn.
  • rotation: The vector3 rotation of the workbench.
  • item_show_case_offset: The vector3 offset to show the item prop when crafting. This may vary depending on the model.
  • job: A table that contains the job restrictions for using the workbench. It has two fields: allowed_list and allowed_grades. If you want to restrict by job name only, use allowed_list. If you want to restrict by job name and grade, use both fields and specify the grades as a table for each job name.
  • categories: A table that contains the categories of items that can be crafted at the workbench. You can use Config.categories or create your own categories.
  • recipes: A table that contains the recipes of items that can be crafted at the workbench. You can use existing recipes or create your own recipes.
  • radius: A number that specifies the interaction radius for using the workbench.

Here is an example of a workbench configuration:

{
table_model = 'gr_prop_gr_bench_03a', -- if not specified workbench_default_model is used
coords = vector3(-1838.76, 2909.63, 38.90), -- workbench spawn coord
rotation = vector3(0.0, 0.0, 150.0), -- workbench rotation,
item_show_case_offset = vector3(0.0, 0.0, 2.25), -- item show case offset to workbench (sometimes models have different offsets)
job = {
allowed_list = { 'police' }, -- only police can use this workbench
allowed_grades = { ['police'] = {2,3,4} } -- only police with grade 2, 3 or 4 can use this workbench
},
categories = { Config.categories.weapons }, -- only weapons category is available at this workbench
recipes = { weapons_recipe }, -- only weapons recipe is available at this workbench
radius = 3.0 -- interaction radius
}

How to add a new category

All categories are listed under Config.categories in config.lua. To add a new category, you need to provide the following information:

  • key: The unique identifier of the category. It must be the same as the table name.
  • label: The display name of the category.
  • icon: The fontawesome icon of the category.
  • jobs: A table that contains the job restrictions for accessing the category. This is reserved for future use and currently not implemented.
  • sub_categories: A table that contains the sub-categories of the category. Each sub-category has a label and optionally an icon.

Here is an example of a category configuration:

['weapons'] = {
key = 'weapons', -- must be same as table name
label = 'Weapons', -- category label
icon = 'fa-solid fa-gun', -- category icon
jobs = {}, -- reserved for future
sub_categories = {
['pistol'] = {
label = 'Pistol',
icon = 'fa-solid fa-pistol'
},
['smg'] = {
label = 'SMG',
icon = 'fa-solid fa-spray-gun'
},
}
},

How to add categories to workbenches

To add categories to workbenches, you need to specify them in the categories field of the workbench configuration. You can use existing categories from Config.categories or create your own categories.

For example, to add weapons and tools categories to a workbench, you can do this:

categories = { Config.categories.weapons, Config.categories.tools }

How to add a new recipe

All recipes are listed below Config.recipes in config.lua. To add a new recipe, you need to enter the following information:

  • key: The unique identifier of the recipe. It must be the same as the table name.
  • label: The display name of the recipe.
  • category: The category key of the recipe. It must match one of the categories defined in Config.categories.
  • sub_category: The sub-category key of the recipe. It must match one of the sub-categories defined in the category.
  • item: The item name of the recipe. It must match one of the items defined in qb-core/shared/items.lua.
  • materials: A table that contains the materials required for crafting the item. Each material has an item name and a quantity.
  • success_rate: A number between 0 and 100 that specifies the percentage chance of successfully crafting the item. If not specified, 100 is used by default.
  • time_to_craft: A number that specifies the time in seconds to craft the item. If not specified, 10 is used by default.

Here is an example of a recipe configuration:

['weapon_pistol'] = {
key = 'weapon_pistol', -- must be same as table name
label = 'Pistol', -- recipe label
category = 'weapons', -- category key
sub_category = 'pistol', -- sub-category key
item = 'weapon_pistol', -- item name
materials = { -- materials required for crafting
['steel'] = 10,
['plastic'] = 5,
['gunpowder'] = 2
},
success_rate = 80, -- success rate in percentage
time_to_craft = 15 -- time to craft in seconds
},