API
This page covers the API exports, events, and triggers that allow you to integrate Koja-Crafting with other scripts and resources.
π₯οΈ Server Exports
Exports allow other resources to interact with Koja-Crafting directly.
AddExp Export
Purpose: Add experience points to a player programmatically from another resource.
Syntax
exports['koja-crafting']:AddExp(data)Parameters
data = {
identifier = 'steam:110000XXXXXXXX', -- Player identifier (optional if playerId provided)
playerId = 1, -- Server ID (optional if identifier provided)
exp = 100 -- Amount of XP to add
}identifier
String
β Optional*
Player's identifier (steam, license, etc.)
playerId
Number
β Optional*
Player's server ID
exp
Number
β Required
Experience points to add
*One of identifier or playerId must be provided.
Examples
Example 1: Add XP by Player ID
Example 2: Add XP by Identifier
Example 3: Quest Reward
Example 4: Job Payout Bonus
How It Works
β Validates player exists in database
β Adds XP to player's current total
π Automatically calculates level-ups
πΎ Saves to database
π’ Notifies player if online
AddBlueprint Export
Purpose: Grant a blueprint to a player programmatically from another resource.
Syntax
Parameters
identifier
String
β Yes
Player's identifier
blueprintName
String
β Yes
Blueprint item respname (not blueprintItem)
β οΈ Important: Use the item's respname, not the blueprintItem name!
Examples
Example 1: Basic Usage
Example 2: Event Reward
Example 3: Shop Purchase
Blueprint Configuration Reference
In your Config.Craftings:
Remember that player can use the item from inventory in ui to learn an blueprint!
Place Crafting
Purpose: Enter placement mode for portable crafting station.
Direction: Server β Client
When Triggered:
Player uses portable crafting item
Usage
Parameters
playerId
Number
Player to trigger placement mode
craftingType
String
Crafting station type/ID
Using the export in inventory to place a station.
OX-INVENTORY
Item definition (ox_inventory/data/items.lua)
ESX
In ESX, you register the item as usable:
QB-CORE
In QB, create a useable item:
π Callbacks
Server callbacks for retrieving data.
koja-crafting:server:checkForBlueprints
Purpose: Check player's inventory for blueprint items and automatically unlock them.
Direction: Client β Server
Returns: Result data with success status and blueprints found.
Usage
Response Structure
Example Integration
π¨ Integration Examples
Example 1: Quest System Integration
Scenario: Give crafting XP and blueprint as quest reward.
π Related Documentation
For command usage, see Commands
For player progression details, see Player Progression
For blueprint configuration, see Crafting Stations
For server setup, see Server Settings
π Getting Help with Integration
If you need help integrating Koja-Crafting with your scripts:
Check examples above for similar use cases
Enable debug mode to see what's happening
Test with simple exports first before complex integration
Visit Discord: https://discord.gg/kojascripts
Read documentation: https://docs.kojascripts.eu
Happy integrating! π
Remember: Koja-Crafting is designed to be easily integrated with other resources. Use exports for direct control, and events for dynamic updates.
Last updated