All resources

rsg-crafting – Docs (v3.2.0)#

Contents#

  1. Files
  2. How it works
  3. Configuration
  4. Exports and events
  5. Security
  6. Server owner how-tos
  7. Troubleshooting

1. Files#

FilePurpose
fxmanifest.luaManifest; depends on rsg-core, rsg-inventory
shared/config.luaBook item, XP, animation, recipes
client/client.luaNUI bridge, crafting animation
server/server.luaRecipes, craft start/finish/cancel, XP, exports
server/sv_config.lua, server/webhook.luaWebhook settings and Discord logs
server/versionchecker.luaGitHub version check
html/NUI crafting book
installation/shared_items.luaItems to add to your items file
locales/*.jsonen, de, el, es, fr, ja, nl, pl, pt-br, ro, ru

2. How it works#

  • The usable craftingbook item opens a draggable NUI (position saved per player).
  • Recipes are grouped by category. Locked recipes show the XP needed, with a progress bar to the next unlock.
  • Pick a recipe and a batch size (up to MaxBatch); time, output and XP scale with quantity.
  • Live ingredient counts (have / need) and a max-craftable indicator.
  • Optional job or job-type restriction per recipe, and optional tools (e.g. a hammer) that must be in the inventory but are never consumed.
  • Crafting continues if you close the book; reopen to watch or press Stop. Dying cancels. Nothing is taken until the craft completes.

3. Configuration#

shared/config.lua:

OptionDefaultMeaning
BookItem'craftingbook'Usable item that opens the UI
XPType'crafting'Rep type for AddRep / GetRep
Imagersg-inventory/html/images/Item images
MaxBatch10Max of one recipe per craft
ShowLockedtrueShow locked recipes greyed out
Animtabledict, clip, flag
CraftinglistRecipes

Recipe fields: category, receive, giveamount, crafttime (ms per craft), requiredxp, xpreward, optional requiredjob, ingredients ({ item, amount }, removed) and requireditems (tools, not removed).

{
    category = 'Basics', receive = 'bandage', giveamount = 1,
    crafttime = 10000, requiredxp = 0, xpreward = 1,
    ingredients = { { item = 'resource_cloth', amount = 1 } },
},

Webhook URLs are in server/sv_config.lua.

4. Exports and events#

NameSideNotes
OpenCraftingBook()client exportOpen the book
GetPlayerCraftingXP(src)server export
GivePlayerCraftingXP(src, amount)server export
GetCraftingRecipes()server exportCopy of Config.Crafting
SendCraftingLog(...)server exportWebhook log
rsg-crafting:client:openBookclient eventOpen the book
rsg-crafting:server:getRecipescallbackRecipes with the player's unlocks
rsg-crafting:server:startCraftingcallback(index, qty)
rsg-crafting:server:finishCraftingcallback(index)
rsg-crafting:server:cancelCraftingserver eventStop crafting

5. Security#

Fully server-authoritative: the server picks the recipe, validates timing, removes ingredients, gives items and XP, and refunds if anything fails. The client only sends a recipe index and quantity.

6. How-tos#

  • Add a recipe: add an entry to Config.Crafting; all items must exist in items.lua.
  • Job-locked recipe: add requiredjob = 'blacksmith' (job name or type).
  • Give the book: /giveitem [id] craftingbook 1.

7. Troubleshooting#

ProblemFix
Book does nothingItem name must match BookItem
Recipe lockedNeeds requiredxp crafting XP
Can't craftMissing ingredient or required tool
No imagesCheck Config.Image

rsg-skills integration#

Config.Skills = { Enabled, Skill, XPScale, SaveChance }. In craftRecipe (the only place items and XP are granted), after the output is added the server calls AddXP(src, 'crafting', xpreward * XPScale, 'crafting'), and rolls the save_chance perk; on a hit every ingredient is given back (when CanAddItem allows it). GivePlayerCraftingXP mirrors its XP the same way. Recipes' requiredxp still reads the rep value (Config.XPType), not rsg-skills. Skipped when rsg-skills is not started.

Support the Project : https://rexshack.tebex.store/

<!-- BEGIN AUTO-REFERENCE (generated from the code; re-run the generator instead of editing by hand) -->

Technical reference#

Generated from the source of rsg-crafting 3.2.0. Names, arguments and defaults below are read straight from the code.

Dependencies#

rsg-core, rsg-inventory

Configuration#

OptionDefaultNotes
Config.BookItem'craftingbook'usable item that opens the crafting UI
Config.XPType'crafting'rep type used with Player.Functions.AddRep / GetRep
Config.Image'rsg-inventory/html/images/'item image path
Config.MaxBatch10max of one recipe crafted in a single go (time scales with qty)
Config.ShowLockedtrueshow locked recipes (greyed out with the XP needed)
Config.Animtableanimation played while crafting
Config.Craftingtable
Config.SkillstableThe crafting XP above keeps working; this also awards XP to the shared rsg-skills skill.
Config.Enabledtrue
Config.Skill'crafting'
Config.XPScale5
Config.SaveChancetrue

Exports#

Server

ExportArgumentsFile
GetPlayerCraftingXPsrcserver/server.lua
GivePlayerCraftingXPsrc, amountserver/server.lua
GetCraftingRecipes``server/server.lua
SendCraftingLog``server/webhook.lua

Client

ExportArgumentsFile
OpenCraftingBook``client/client.lua
-- example
local result = exports['rsg-crafting']:GetPlayerCraftingXP(src)

Callbacks#

CallbackSideArgumentsFile
rsg-crafting:server:getRecipesserversrc, cbserver/server.lua
rsg-crafting:server:startCraftingserversrc, cb, index, qtyserver/server.lua
rsg-crafting:server:finishCraftingserversrc, cb, indexserver/server.lua
-- client side
RSGCore.Functions.TriggerCallback('rsg-crafting:server:getRecipes', function(result)
    -- use result
end)

Events#

Server events can be fired by any client, so every handler re-validates the player, the arguments and any permission, distance or cooldown on the server. Never add a reward to a handler without those checks.

EventSideArgumentsFile
rsg-crafting:client:openBookclient``client/client.lua
rsg-crafting:server:cancelCraftingserver``server/server.lua
-- from a client script
TriggerServerEvent('rsg-crafting:server:cancelCrafting')
-- from a server script
TriggerClientEvent('rsg-crafting:client:openBook', source)

Locales#

Language files in locales/: de, el, en, es, fr, ja, nl, pl, pt-br, ro, ru. Set the language with setr rsg:locale "en".

<!-- END AUTO-REFERENCE -->