Commands and Exports — Crafting Creator | Quasar Store | Quasar Store
Documentation
Commands and Exports
Crafting Creator commands, server hooks and events for FiveM developers: modify crafts for skill and perk scripts, award XP on delivery, and read a player's crafting level.
Crafting Creator registers one command for staff. Players need none: benches are opened by walking up to them.
Command
Where
Description
/crafting_creator
In game
Opens the creator: the list of benches made in game, with create, edit and delete. Bound to F10 by default (Config.OpenCreatorKey). Needs admin or a job from Config.CreatorJobs.
The key is a FiveM key mapping, so each player can rebind it under . Changing only changes the default for players who have never had the mapping.
With Config.Debug = true, a few more client commands exist for tuning how a bench looks. None of them save anything — copy the values you like into config/main.lua.
With a bench open, moves the camera and the showcased item relative to the bench prop. The six numbers are the camera and object vectors of Config.ObjectOffsets.
/crafting:create_cam
Puts the showcase camera on the first bench of Config.CraftingTables.
/crafting:setLight r g b distance brightness hardness radius
Changes the spotlight over the bench.
/crafting:light_offset x y z · /crafting:light_forward_offset x y z
Moves the spotlight and the point it aims at.
/crafting:tint index
Previews a weapon tint on the showcased weapon.
Debug mode also registers developer test commands on the server that write directly into crafting_queue, and prints every action to the console. Use it on a test server, and keep Config.Debug = false in production.
Crafting Creator has no exports for gameplay; scripts plug into it from the server, through four hooks in server/custom/hooks.lua and the events further down. The hooks are where a skill or perk script changes a craft — a faster craft for a skilled player, a material saved, a bonus item — and the safe place to award its own XP. An error inside a hook is caught and printed; it never breaks the craft.
ModifyCraft — change duration, materials, output or XP
Runs every time a craft is about to start, and also when the recipe list is shown (data.preview = true), so the window displays the modified time and materials. Return a table with only what you want to change, or nil for the recipe as written.
lua
functionCraftingHooks.ModifyCraft(source, data)-- data.tableId, data.itemName, data.amount requested amount-- data.duration seconds per item-- data.ingredients TOTAL materials for this craft { iron = 20, ... }-- data.earn, data.price, data.level-- data.preview true while the list is shown, nothing taken yet-- data.mode 'queue' | 'proximity'-- your skill script's own exportlocal perk = exports['my-skills']:GetLevel(source, 'crafting') or0if perk < 5thenreturnendreturn {
duration = math.floor(data.duration * 0.8), -- 20% faster
ingredients = { -- one iron saved
iron = math.max(0, (data.ingredients.iron or0) - 1),
},
outputAmount = not data.preview and data.amount + 1ornil, -- one extra
}
end
Return field
Rule
duration
Seconds per item, whole number, 0 or more.
ingredients
Totals for the whole craft. Can only go down, never above the recipe; ingredients you leave out stay as they are.
outputAmount
Items delivered. Never below the amount requested. If the inventory has no room for the bonus, the requested amount is delivered instead.
earn
Crafting XP per item, 0 or more.
The limits are enforced after your hook runs, so a mistake can never make a craft cost more than the recipe or deliver less than was paid for.
OnCraftStarted
After the money and materials are taken and the craft is running.
Only after the item is in the player's inventory and the queue entry or proximity session is consumed. It never fires for a cancel, a refund, a failed delivery or a second click on the same item.
lua
functionCraftingHooks.OnCraftCollected(source, payload)-- payload.amount items delivered (with any bonus)-- payload.requestedAmount items the player asked for-- payload.earn crafting XP awarded
exports['pn-skills']:AddXp(source, 'crafting', payload.amount)
end
OnCraftCancelled
A proximity craft that ended without delivering. Never award XP here.
The same moments are also fired as server events, so another resource can listen without touching Crafting Creator's files:
Event
Arguments
When
qs-crafting:server:craftStarted
source, payload
A craft has started.
qs-crafting:server:craftCollected
source, payload
An item was delivered. The event to award XP from.
qs-crafting:server:craftCancelled
source, payload
A proximity craft was cancelled or refunded.
qs-crafting:server:modifyCraft
source, data, mods
A craft is being prepared, after ModifyCraft ran.
lua
-- server side of any resource
AddEventHandler('qs-crafting:server:craftCollected', function(source, payload)if payload.item == 'weapon_pistol'thenprint(('%s crafted %d pistol(s) at bench %s'):format(
GetPlayerName(source), payload.amount, payload.tableId))
endend)
Arguments passed to another resource are copies. Listening to modifyCraft from outside tells you what a craft will be, but changing mods there has no effect — to change a craft, use CraftingHooks.ModifyCraft.
Each player's level is kept in a replicated state bag, crafting_skill, readable from any resource on either side — useful for a job that only hires skilled crafters, or a shop that shows the level:
It is set when the player loads and updated every time they earn XP. Treat it as read-only: the level is saved from Crafting Creator's own XP, so writing to the state bag from another script is not stored.
payload.reason on craftCancelled says why a proximity craft did not deliver. In every case the refund in Config.CraftingProgression.CancelRefund has already been given.
Reason
Means
cancelled
The player cancelled the progress circle.
distance
They moved further than MaxDistance from the bench.
inventory
The craft finished but the item did not fit in their inventory.