πŸ”¨Craft Menu

🌐 Translations

You can edit all menu translations in html/translate.js (languages included: fr, en, de, it, es, pt). System messages and tooltips can be configured in config.lua under the Config.Txt table.


πŸ—„οΈ Database

No setup needed! Just run the scriptβ€”the required table will be created automatically in your database. No manual database action required.


πŸšͺ Opening the Crafting Menu

There are two ways to open the crafting menu:

  1. For the player’s current job:

    TriggerServerEvent("bt_craft:openCraftMenu")
  2. For a specific job (e.g. β€œpolice”):

    TriggerServerEvent("bt_craft:openCraftMenu", "police")

You can server-side, for example, link an item to the opening of the craft menu for a specific job:

exports.vorp_inventory:registerUsableItem("smuggler_book", function(data)
    TriggerEvent("bt_craft:openCraftMenu", "smuggler", data.source)
end, GetCurrentResourceName())

βž• Adding a New Craft Recipe

To add a new recipe, edit your Config.Crafts table in the server script.

Example for the "smuggler" job:

Config.Crafts["smuggler"] = {
    {
        itemcraft = "moonshine",   -- Item given to the player
        level = 2,                 -- Required job level to craft
        craftTime = 5,             -- Craft time (seconds per item)
        requires = {
            [1] = { {item="alcohol", quantity=2}, {item="corn", quantity=4} },  -- 2 alcohol OR 4 corn
            [2] = { {item="sugar", quantity=2}, {item="honey", quantity=1} },   -- 2 sugar OR 1 honey
            [3] = { {item="glassbottle", quantity=1} }                          -- 1 glassbottle (mandatory)
        }
    },
}

Field descriptions:

  • itemcraft: The item the player will receive after crafting.

  • level: The minimum job level required to unlock the recipe.

  • craftTime: The time (in seconds) to craft one item. This is multiplied by the chosen quantity.

  • requires: Ingredient groups. Each numbered group represents alternative ingredients. The player must provide one option per group.

Tip: You can add as many recipes as you want for each job, and as many alternative ingredients per step as needed.


πŸ”Œ Server Export: exports.bt_craft:GetPlayerCraftLevelXP

Retrieve a player's crafting level and XP for a given job, synchronously.

Usage:

local level, xp = exports.bt_craft:GetPlayerCraftLevelXP(playerId, jobName)
print("Level:", level)
print("XP:", xp)
  • playerId: The server ID of the player.

  • jobName: The job to check (e.g., "smuggler", "police").

Returns:

  • level (integer) β€” Player’s crafting level for the specified job.

  • xp (integer) β€” Player’s current XP for the specified job.

If the player/job does not exist yet, the function returns:

  • 1 for level

  • 0 for XP

Example:

local jobName = "smuggler"
local level, xp = exports.bt_craft:GetPlayerCraftLevelXP(source, jobName)
print(("Player %d - %s: Level %d, XP %d"):format(source, jobName, level, xp))

πŸ“Œ Notes

  • Flexible integration: Crafting can be opened for any job, or for the player's own job, and recipes are fully customizable.

  • No DB headaches: The database is auto-managed. Just start the script!

  • Fully configurable: All translations and messages are editable for easy localization.

  • Powerful API: Server exports for craft XP/levels let you build advanced features (e.g., UI, ranks).

Last updated