file-binaryAPI

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
}
Parameter
Type
Required
Description

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

  1. βœ… Validates player exists in database

  2. βž• Adds XP to player's current total

  3. πŸ“ˆ Automatically calculates level-ups

  4. πŸ’Ύ Saves to database

  5. πŸ“’ Notifies player if online


AddBlueprint Export

Purpose: Grant a blueprint to a player programmatically from another resource.

Syntax

Parameters

Parameter
Type
Required
Description

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:

circle-exclamation

Place Crafting

Purpose: Enter placement mode for portable crafting station.

Direction: Server β†’ Client

When Triggered:

  • Player uses portable crafting item

Usage

Parameters

Parameter
Type
Description

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.


  • 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:

  1. Check examples above for similar use cases

  2. Enable debug mode to see what's happening

  3. Test with simple exports first before complex integration

  4. Visit Discord: https://discord.gg/kojascripts

  5. 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