Koja Scripts
NEW

Commands

This page covers all available commands in Koja-Crafting, their usage, permissions, and examples.

Commands

📋 Command Overview

Koja-Crafting provides two admin commands for managing player progression and blueprints:

CommandPurposePermissionUsage
/addblueprintGrant blueprint to playerAdmin[playerID] [item]
/addexpGive experience to playerAdmin[playerID] [amount]

🔐 Permission System

Who Can Use Commands?

Commands are restricted to players with admin permissions. Access is controlled by Config.AdminGroups:

-- In shared/config.lua
Config.AdminGroups = { 'admin', 'owner', 'superadmin', 'god' }

How it works:

  • Script checks player's job/group from framework (ESX/QBCore)
  • If player's group matches any in Config.AdminGroups, command executes
  • If no match, player receives permission denied message

Configuration Examples:

-- ESX Standard
Config.AdminGroups = { 'admin', 'superadmin', 'owner' }

-- QBCore Standard
Config.AdminGroups = { 'admin', 'god' }

-- Custom Setup
Config.AdminGroups = { 'moderator', 'admin', 'developer', 'owner' }

-- Restricted (Owners only)
Config.AdminGroups = { 'owner' }

For detailed permission setup, see Admin Permissions.


🔷 Add Blueprint Command

Command Syntax

/addblueprint [playerID] [blueprintItem]

Parameters

ParameterTypeDescriptionRequired
playerIDNumberTarget player's server ID✅ Yes
blueprintItemStringBlueprint item name from config✅ Yes

What It Does

  1. Step 1

    Grants a special blueprint to the specified player.
  2. Step 2

    Saves blueprint to player's database record (koja-crafting table).
  3. Step 3

    Unlocks the corresponding item in crafting menu (if level requirement met).
  4. Step 4

    Sends notification to the player.
  5. Step 5

    Persists through server restarts and player disconnects.

Blueprint Configuration

In shared/config.lua:

blueprints = {
    {
        respname = 'parachute',
        name = 'Parachute',
        category = 'advanced',
        image = './images/parachute.webp',
        blueprintItem = 'parachute_blueprint',  -- ← This is what you use in command
        craftingTime = 120,
        requiredLevel = 4,
        resources = {
            { name = 'cloth', amount = 10 },
            { name = 'rope', amount = 5 }
        },
        exp = 150
    }
}

Command to give:

/addblueprint 1 parachute_blueprint

Error Messages

Blueprint Command — Error Messages
ErrorCauseSolution
"No permissions!"Not adminAdd your group to Config.AdminGroups
"Invalid player ID"Player offline or wrong IDCheck player is online with /players
"Blueprint not found"Wrong blueprint nameCheck blueprintItem in config
"Player already has blueprint"DuplicateNo action needed (already unlocked)

📊 Add Experience Command

Command Syntax

/addexp [playerID] [amount]

Parameters

ParameterTypeDescriptionRequired
playerIDNumberTarget player's server ID✅ Yes
amountNumberXP amount to add✅ Yes

What It Does

  1. Step 1

    Adds specified XP to player's current experience.
  2. Step 2

    Automatically calculates if player levels up.
  3. Step 3

    Handles multiple level-ups in one command.
  4. Step 4

    Saves progress to database immediately.
  5. Step 5

    Notifies player of new level/XP.
  6. Step 6

    Unlocks items if new level requirement met.

Error Messages

AddExp Command — Error Messages
ErrorCauseSolution
"No permissions!"Not adminAdd group to Config.AdminGroups
"Invalid player ID"Wrong ID/offlineVerify with /players
"Invalid amount"Negative/zeroUse positive number
"Command error"Framework issueCheck koja-lib is running

🛠️ Console vs In-Game

Running from Server Console

Commands can also be executed from server console:

# In server console (txAdmin, etc.)
addexp 1 500
addblueprint 5 weapon_blueprint

Note: When running from console (source = 0), permission checks are bypassed.


📊 Command Reference Table

CommandSyntaxPermissionPurposePersistent
/addblueprint[id] [item]AdminGrant blueprint✅ Yes
/addexp[id] [amount]AdminGive XP✅ Yes

  • General Settings — This page covers the basic configuration options for Koja-Crafting that control debug mode, language, and player behavior.
  • Server Settings — This page covers server-side configuration options including database management, crafting recovery, and shared table functionality.
  • Images Settings — This page explains how to configure item images, add custom graphics, and manage image paths in Koja-Crafting.
  • Player Progression Settings — This page covers the player progression system including levels, experience points, and how to configure the leveling system in Koja-Crafting.
  • Admin Settings — This page covers admin permission configuration and available admin commands for managing Koja-Crafting.
  • Interaction Settings — This page covers how players interact with crafting stations - either through key press or target system (ox_target,qb-target,).
  • Configuration — back to the section overview