Crafting Integration
Integrate Dime Skills with ox_inventory crafting system
Crafting Integration Guide
This guide explains how to integrate Dime Skills with ox_inventory's crafting system to add skill requirements and rewards to recipes.
Overview
The integration allows you to:
- Require minimum skill levels to craft items
- Grant skill XP when items are successfully crafted
- Block crafting attempts if skill requirements aren't met
- Create skill-based progression in crafting
Setup
Enable Crafting Integration
In shared/config.lua, enable crafting skills:
craftingSkills = trueThis automatically registers the ox_inventory hook.
Configure Recipes
Edit your ox_inventory recipes to include skill data.
Recipes are typically in ox_inventory/data/items.lua or custom recipe files.
Recipe Configuration
Basic Structure
Add a skills table to any recipe:
['item_name'] = {
label = 'Item Label',
weight = 100,
duration = 5000,
skills = {
required = {
-- Skill requirements
},
reward = {
-- XP rewards
}
},
ingredients = {
-- Recipe ingredients
}
}Required Skills
Specify minimum skill levels needed to craft:
skills = {
required = {
crafting = 10, -- Level 10 crafting required
chemistry = 5 -- Level 5 chemistry required
}
}Behavior:
- All requirements must be met
- Craft will fail if any skill is too low
- Player receives error notification
Skill Rewards
Grant XP when craft succeeds:
skills = {
reward = {
crafting = 15, -- Gain 15 XP in crafting
chemistry = 10 -- Gain 10 XP in chemistry
}
}Behavior:
- XP granted only on successful craft
- Multiple skills can receive XP
- Subject to
rewardMaxsafety limits - Triggers skill notifications
Complete Examples
Simple Crafting Item
Lockpick with basic requirements:
['lockpick'] = {
label = 'Lockpick',
weight = 50,
stack = true,
close = true,
description = 'A tool for picking locks',
client = {
image = 'lockpick.png'
},
-- Crafting configuration
duration = 5000,
skills = {
required = {
crafting = 5 -- Level 5 crafting needed
},
reward = {
crafting = 10 -- Gain 10 XP
}
},
ingredients = {
{ name = 'metalscrap', amount = 2 },
{ name = 'plastic', amount = 1 }
}
}Advanced Crafting Item
Weapon requiring multiple skills:
['weapon_pistol'] = {
label = 'Pistol',
weight = 1000,
stack = false,
close = true,
description = 'A handcrafted pistol',
client = {
image = 'weapon_pistol.png'
},
-- Advanced crafting
duration = 15000,
skills = {
required = {
weaponary = 15, -- Level 15 weaponary
crafting = 10 -- Level 10 crafting
},
reward = {
weaponary = 25, -- Gain 25 XP
crafting = 15 -- Gain 15 XP
}
},
ingredients = {
{ name = 'steel', amount = 5 },
{ name = 'weapon_parts', amount = 3 },
{ name = 'screws', amount = 10 }
}
}Chemistry Item
Medical item with chemistry requirement:
['medkit'] = {
label = 'Medical Kit',
weight = 500,
stack = true,
close = true,
description = 'Advanced medical supplies',
client = {
image = 'medkit.png'
},
duration = 10000,
skills = {
required = {
chemistry = 20 -- High chemistry requirement
},
reward = {
chemistry = 30 -- Substantial XP reward
}
},
ingredients = {
{ name = 'bandage', amount = 5 },
{ name = 'chemicals', amount = 3 },
{ name = 'plastic', amount = 2 }
}
}No Requirements, Only Rewards
Grant XP without requirements:
['simple_item'] = {
label = 'Simple Item',
-- ... other properties
duration = 3000,
skills = {
-- No requirements
reward = {
crafting = 5 -- Just grant XP
}
},
ingredients = {
{ name = 'material', amount = 1 }
}
}Hook System
How It Works
When craftingSkills = true, Dime Skills registers this hook:
exports.ox_inventory:registerHook('craftItem', function(payload)
local itemData = payload.recipe
local source = payload.source
-- Check skill requirements
if itemData.skills and itemData.skills.required then
local playerSkills = getPlayerSkills(source)
for skill, requiredLevel in pairs(itemData.skills.required) do
if playerSkills[skill].level < requiredLevel then
return false -- Block craft
end
end
end
return true -- Allow craft
end, {print = false})Reward Handling
After successful craft, XP is granted:
RegisterNetEvent('dime_skills:craftItemSuccess', function(source, itemData)
if itemData.skills and itemData.skills.reward then
for skill, xpGain in pairs(itemData.skills.reward) do
exports.dime_skills:addEXP(source, skill, xpGain)
end
end
end)Custom Crafting Systems
If you're not using ox_inventory, you can integrate manually:
Check Requirements
RegisterNetEvent('mycrafting:attemptCraft', function(recipeName)
local recipe = MyRecipes[recipeName]
if recipe.skills and recipe.skills.required then
-- Check each requirement
for skill, level in pairs(recipe.skills.required) do
local playerSkill = exports.dime_skills:grabSkill(source, skill)
if not playerSkill or playerSkill.level < level then
TriggerClientEvent('ox_lib:notify', source, {
type = 'error',
description = ('Requires %s Level %d'):format(skill, level)
})
return
end
end
end
-- Allow crafting
TriggerClientEvent('mycrafting:startCraft', source, recipeName)
end)Grant Rewards
RegisterNetEvent('mycrafting:craftComplete', function(recipeName)
local recipe = MyRecipes[recipeName]
if recipe.skills and recipe.skills.reward then
-- Grant XP for each skill
for skill, xp in pairs(recipe.skills.reward) do
exports.dime_skills:addEXP(source, skill, xp)
end
end
-- Grant item
-- ...
end)Advanced Patterns
Difficulty-Based Rewards
More XP for harder recipes:
['advanced_item'] = {
-- ... properties
skills = {
required = {
crafting = 25 -- High requirement
},
reward = {
crafting = 50 -- High reward
}
}
}
['simple_item'] = {
-- ... properties
skills = {
required = {
crafting = 5 -- Low requirement
},
reward = {
crafting = 10 -- Low reward
}
}
}Multi-Skill Progression
Items that train multiple skills:
['explosive_device'] = {
-- ... properties
skills = {
required = {
crafting = 20,
chemistry = 15,
weaponary = 10
},
reward = {
crafting = 20,
chemistry = 25,
weaponary = 15
}
}
}Job-Locked Recipes
Combine with job-locked skills:
-- In config.lua
skills = {
['advanced_mechanic'] = {
visuals = { label = 'Advanced Mechanics' },
levels = { lvlMax = 30 },
job = 'mechanic' -- Job-locked
}
}
-- In recipe
['turbo_engine'] = {
-- ... properties
skills = {
required = {
advanced_mechanic = 15 -- Mechanics only
},
reward = {
advanced_mechanic = 30
}
}
}Progressive Recipes
Unlock recipes at certain levels:
-- Beginner recipe
['basic_weapon'] = {
skills = {
required = { weaponary = 1 },
reward = { weaponary = 10 }
}
}
-- Intermediate recipe
['improved_weapon'] = {
skills = {
required = { weaponary = 10 },
reward = { weaponary = 20 }
}
}
-- Advanced recipe
['masterwork_weapon'] = {
skills = {
required = { weaponary = 25 },
reward = { weaponary = 50 }
}
}Notifications
Default Behavior
When crafting fails due to skill requirements:
-- Automatically shown to player
{
type = 'error',
title = 'Insufficient Skill',
description = 'Requires Crafting Level 10'
}Custom Messages
Override in your crafting system:
if not hasRequiredSkills then
TriggerClientEvent('ox_lib:notify', source, {
type = 'error',
title = 'Cannot Craft',
description = 'You need more experience before attempting this recipe.',
duration = 5000
})
endBalancing Tips
XP Per Craft
Guidelines for XP rewards:
- Common Items: 5-10 XP
- Uncommon Items: 15-25 XP
- Rare Items: 30-50 XP
- Legendary Items: 75-100 XP
Consider:
- Material cost
- Craft time
- Item power/value
- Frequency of crafting
Level Requirements
Set appropriate gates:
- Basic Items: 1-5
- Intermediate Items: 10-15
- Advanced Items: 20-25
- Master Items: 30+
Progression Curve
Create a natural progression:
-- Early game (Easy to obtain)
lockpick: Level 1 → 5 XP
-- Mid game (Moderate effort)
armor_vest: Level 10 → 20 XP
-- Late game (Significant grind)
advanced_weapon: Level 25 → 50 XPTroubleshooting
Recipe Not Checking Skills
- Verify
craftingSkills = truein config - Ensure resource started after ox_inventory
- Check console for hook registration messages
- Restart both resources
Skills Not Granting XP
- Check recipe has
skills.rewardtable - Verify skill names match config
- Check
rewardMaxisn't too low - Enable Debug mode to see XP grants
Requirements Not Working
- Ensure
skills.requiredis properly formatted - Check skill names are correct
- Verify player has the skill unlocked
- Check for job restrictions
Best Practices
Recipe Organization
-- Group by skill type
local CraftingRecipes = { ... }
local ChemistryRecipes = { ... }
local WeaponaryRecipes = { ... }
-- Or by difficulty
local BeginnerRecipes = { ... }
local AdvancedRecipes = { ... }
local MasterRecipes = { ... }Documentation
Document your recipes:
['item_name'] = {
-- CRAFTING SKILL: Level 15 required
-- REWARDS: 25 XP in Crafting
-- DIFFICULTY: Intermediate
skills = {
required = { crafting = 15 },
reward = { crafting = 25 }
}
}Testing
Always test:
- Craft with insufficient skills
- Craft with exact requirements
- Craft with skills over requirement
- Verify XP is granted correctly
- Check job-locked recipes
Related
- Configuration - Config skills
- Skills System - How skills work
- Server Exports - API reference