Exports & API
noclip_crafting provides a comprehensive API for integrating with other scripts and customizing functionality.
Note: All exports are available after the resource has fully loaded. Make sure to wait for the resource to start before calling exports.
Server-Side Exports
These exports are available on the server-side and can be called from other server scripts.
Player Skill Management
Export |
Parameters |
Returns |
Description |
GetPlayerSkill |
playerId, skillType |
number |
Get player's skill level for a specific crafting type |
SetPlayerSkill |
playerId, skillType, level |
boolean |
Set player's skill level for a specific crafting type |
AddPlayerSkill |
playerId, skillType, amount |
boolean |
Add experience to player's skill |
GetPlayerExperience |
playerId, skillType |
number |
Get player's current experience for a skill |
Example Usage
-- Get player's weapon crafting skill
local skillLevel = exports['noclip_crafting']:GetPlayerSkill(playerId, 'weapon_crafting')
-- Add experience to player's electronics skill
local success = exports['noclip_crafting']:AddPlayerSkill(playerId, 'electronics', 50)
-- Set player's mechanics skill to level 10
local success = exports['noclip_crafting']:SetPlayerSkill(playerId, 'mechanics', 10)
Crafting Location Management
Export |
Parameters |
Returns |
Description |
GetCraftingLocations |
none |
table |
Get all configured crafting locations |
GetCraftingLocation |
locationId |
table |
Get specific crafting location data |
AddCraftingLocation |
locationData |
boolean |
Add a new crafting location dynamically |
RemoveCraftingLocation |
locationId |
boolean |
Remove a crafting location |
Example Usage
-- Get all crafting locations
local locations = exports['noclip_crafting']:GetCraftingLocations()
-- Add a new crafting location
local newLocation = {
name = "Custom Bench",
coords = { vector4(100.0, 200.0, 30.0, 90.0) },
prop = `prop_tool_bench02`,
craftingTable = {
["custom_item"] = {
amount = 1,
time = 3000,
requires = {
["material1"] = 2,
["material2"] = 1
}
}
}
}
local success = exports['noclip_crafting']:AddCraftingLocation(newLocation)
Recipe Management
Export |
Parameters |
Returns |
Description |
GetRecipe |
locationId, itemName |
table |
Get recipe data for a specific item |
AddRecipe |
locationId, itemName, recipeData |
boolean |
Add a new recipe to a location |
RemoveRecipe |
locationId, itemName |
boolean |
Remove a recipe from a location |
UpdateRecipe |
locationId, itemName, recipeData |
boolean |
Update an existing recipe |
Example Usage
-- Add a new recipe to location 1
local recipeData = {
amount = 1,
time = 5000,
requires = {
["steel"] = 3,
["electronics"] = 2
},
jobRestriction = {
job = "mechanic",
grade = 1
},
skillRequirement = {
type = "mechanics",
level = 5
}
}
local success = exports['noclip_crafting']:AddRecipe(1, "advanced_tool", recipeData)
-- Get recipe data
local recipe = exports['noclip_crafting']:GetRecipe(1, "advanced_tool")
Utility Functions
Export |
Parameters |
Returns |
Description |
CanPlayerCraft |
playerId, locationId, itemName |
boolean, string |
Check if player can craft an item (returns success and reason) |
GetPlayerCraftingHistory |
playerId |
table |
Get player's crafting history |
ResetPlayerSkills |
playerId |
boolean |
Reset all player skills to 0 |
GetCraftingStats |
none |
table |
Get overall crafting statistics |
Example Usage
-- Check if player can craft an item
local canCraft, reason = exports['noclip_crafting']:CanPlayerCraft(playerId, 1, "advanced_tool")
if not canCraft then
print("Cannot craft: " .. reason)
end
-- Get player's crafting history
local history = exports['noclip_crafting']:GetPlayerCraftingHistory(playerId)
-- Get overall stats
local stats = exports['noclip_crafting']:GetCraftingStats()
Client-Side Exports
These exports are available on the client-side and can be called from other client scripts.
UI Management
Export |
Parameters |
Returns |
Description |
OpenCraftingMenu |
locationId |
boolean |
Open the crafting menu for a specific location |
CloseCraftingMenu |
none |
boolean |
Close the currently open crafting menu |
IsCraftingMenuOpen |
none |
boolean |
Check if crafting menu is currently open |
Example Usage
-- Open crafting menu for location 1
local success = exports['noclip_crafting']:OpenCraftingMenu(1)
-- Check if menu is open
local isOpen = exports['noclip_crafting']:IsCraftingMenuOpen()
-- Close the menu
local success = exports['noclip_crafting']:CloseCraftingMenu()
Player Data
Export |
Parameters |
Returns |
Description |
GetLocalPlayerSkill |
skillType |
number |
Get local player's skill level |
GetLocalPlayerExperience |
skillType |
number |
Get local player's experience |
GetAvailableLocations |
none |
table |
Get locations available to the local player |
Example Usage
-- Get local player's weapon crafting skill
local skillLevel = exports['noclip_crafting']:GetLocalPlayerSkill('weapon_crafting')
-- Get available locations for local player
local locations = exports['noclip_crafting']:GetAvailableLocations()
Events
noclip_crafting also provides events that you can listen to for custom functionality.
Server Events
Event |
Parameters |
Description |
noclip_crafting:itemCrafted |
playerId, itemName, amount, locationId |
Triggered when a player successfully crafts an item |
noclip_crafting:skillLevelUp |
playerId, skillType, newLevel |
Triggered when a player levels up a skill |
noclip_crafting:craftingFailed |
playerId, itemName, reason |
Triggered when crafting fails |
Client Events
Event |
Parameters |
Description |
noclip_crafting:menuOpened |
locationId |
Triggered when crafting menu opens |
noclip_crafting:menuClosed |
none |
Triggered when crafting menu closes |
noclip_crafting:craftingStarted |
itemName, time |
Triggered when crafting process starts |
noclip_crafting:craftingCompleted |
itemName, amount |
Triggered when crafting process completes |
Example Usage
-- Server-side event listener
RegisterNetEvent('noclip_crafting:itemCrafted')
AddEventHandler('noclip_crafting:itemCrafted', function(playerId, itemName, amount, locationId)
print(string.format("Player %s crafted %dx %s at location %d", playerId, amount, itemName, locationId))
-- Add your custom logic here
end)
-- Client-side event listener
RegisterNetEvent('noclip_crafting:craftingCompleted')
AddEventHandler('noclip_crafting:craftingCompleted', function(itemName, amount)
print(string.format("Successfully crafted %dx %s", amount, itemName))
-- Add your custom logic here
end)
Integration Examples
Here are some practical examples of how to integrate noclip_crafting with other scripts.
Job Integration
-- Add crafting recipes based on job
RegisterNetEvent('QBCore:Server:OnJobUpdate')
AddEventHandler('QBCore:Server:OnJobUpdate', function(source, newJob)
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
-- Add mechanic-specific recipes when player becomes mechanic
if newJob.name == "mechanic" then
local recipeData = {
amount = 1,
time = 3000,
requires = {
["steel"] = 2,
["electronics"] = 1
}
}
exports['noclip_crafting']:AddRecipe(1, "mechanic_tool", recipeData)
end
end)
Skill-Based Rewards
-- Give rewards based on skill level
RegisterNetEvent('noclip_crafting:skillLevelUp')
AddEventHandler('noclip_crafting:skillLevelUp', function(playerId, skillType, newLevel)
local Player = QBCore.Functions.GetPlayer(playerId)
if not Player then return end
-- Give rewards for reaching skill milestones
if newLevel == 10 then
Player.Functions.AddMoney('cash', 1000, 'skill-milestone')
TriggerClientEvent('QBCore:Notify', playerId, 'Congratulations! You reached level 10 in ' .. skillType, 'success')
elseif newLevel == 50 then
Player.Functions.AddMoney('cash', 5000, 'skill-milestone')
TriggerClientEvent('QBCore:Notify', playerId, 'Amazing! You reached level 50 in ' .. skillType, 'success')
end
end)