Koja Scripts
NEW

Server Settings

This page covers server-side configuration options including database management, crafting recovery, and shared table functionality.

Server Settings

🔧 Configuration Options

All server settings are located in shared/config.lua under the SERVER SETTINGS section.

-- ════════════════════════════════════════════════════════════════════════════════════
--  SERVER SETTINGS
-- ════════════════════════════════════════════════════════════════════════════════════

Config.CreateAutoTable = true
Config.CraftingItemsRecovery = true
Config.SharedTables = false

📝 Setting Descriptions

Automatic Database Creation

Config.CreateAutoTable = true

Purpose: Automatically create required database tables when the resource starts for the first time.

Options:

  • true - Database tables are created automatically (recommended for easy setup)
  • false - Tables must be created manually using koja-crafting.sql

How it works: When enabled, the script will execute SQL queries on first startup to create three tables:

  1. koja-crafting

    Stores player data Fields:
    • identifier - Player identifier (steam, license, etc.)
    • blueprints - JSON array of unlocked blueprints
    • level - Current crafting level
    • exp - Current experience points
  2. koja-crafting-objects

    Stores placed crafting stations Fields:
    • id - Unique object ID
    • craftingId - Reference to crafting station config
    • model - Prop model name
    • x, y, z, heading - Object position and rotation
  3. koja-crafting-queue

    Stores crafting queue data Fields:
    • id - Unique queue item ID
    • identifier - Player identifier
    • craftingTableId - Which table is being used
    • itemName - Item being crafted
    • itemImage - Item image path
    • amount - Quantity being crafted
    • craftingAmount - Items per craft
    • exp - Experience gained on completion
    • startTime, endTime - Crafting timestamps
    • craftingTime - Duration in seconds
    • completed - Whether crafting is finished

When to use each option:

✅ Use true (Auto-Create) when:

  • First time installing the script
  • Want quick and easy setup
  • Don't have direct database access
  • Prefer automated setup

✅ Use false (Manual Import) when:

  • You have custom database naming conventions
  • Want more control over table structure
  • Already have tables from previous version
  • Prefer manual database management

Crafting Items Recovery

Config.CraftingItemsRecovery = true

Purpose: Save crafting progress to database, allowing players to recover items after disconnect, server crash, or restart.

Options:

  • true - Crafting progress is saved to database (recommended)
  • false - Crafting progress is lost on disconnect/restart

How it works:

  1. When enabled (true)

    • Player starts crafting an item
    • Progress is saved to koja-crafting-queue table
    • If player disconnects, data remains in database
    • When player reconnects, they can claim completed items
    • Items show in queue menu with "CLAIM" button when ready
  2. When disabled (false)

    • Player starts crafting an item
    • Progress stored only in memory (RAM)
    • If player disconnects, crafting is lost
    • If server restarts, all active crafts are cancelled
    • No persistent storage

Example Scenarios:

ScenarioRecovery EnabledRecovery Disabled
Player crafts item, logs out normally✅ Can claim when back❌ Lost forever
Server crashes during crafting✅ Items recoverable❌ All progress lost
Player crashes/timeout✅ Progress saved❌ Must restart craft
Server restart for update✅ Queue preserved❌ Queue wiped

Recommendation:

  • ✅ Keep enabled for player satisfaction — prevents frustration from lost items. Adds minimal performance impact (one INSERT per craft start and updates on completion).

Performance Considerations:

  • Minimal database writes
  • Negligible impact on modern MySQL servers
  • Benefits outweigh the small overhead

Shared Crafting Tables

Config.SharedTables = false

Purpose: Control whether crafting queues are shared between all players or personal to each player.

Options:

  • false - Each player has their own private queue (default)
  • true - All players share the same queue per crafting station

How it works:

Personal Queues (false - Default):

  • Each player sees only their own crafting items
  • Other players can't interact with your queue
  • Items are bound to your character
  • Prevents griefing

Shared Queues (true):

  • All players see the same queue at each station
  • Anyone can claim completed items (first come, first served)
  • Promotes teamwork and collaboration
  • Risk of item theft if not managed

Use Cases:

Server TypeRecommended SettingReason
Public Serverfalse (Personal)Prevents griefing
Roleplay Servertrue (Personal)More realistic
Gang/Faction Servertrue (Shared)Team collaboration
Whitelisted Communitytrue (Shared)Trust between players

🔍 Troubleshooting

Tables not created automatically
  • Check if oxmysql is running
  • Verify database connection in server.cfg
  • Check console for SQL errors
  • Try manual import if auto-create fails
Recovery not working
  • Verify Config.CraftingItemsRecovery = true
  • Check if koja-crafting-queue table exists
  • Look for database errors in console
  • Ensure oxmysql is up to date
Shared tables not functioning
  • Confirm Config.SharedTables = true
  • Restart resource after config change
  • Check if multiple players are at same station ID
  • Verify station IDs match in config
Database permissions error
  • Grant CREATE, INSERT, UPDATE, DELETE permissions
  • Check MySQL user has table creation rights
  • Verify connection credentials

📊 Monitoring Database Health (FOR EMERGENCY)

Check active crafting entries:

SELECT COUNT(*) FROM `koja-crafting-queue` WHERE completed = 0;

Check player progression:

SELECT identifier, level, exp FROM `koja-crafting` ORDER BY level DESC LIMIT 10;

Find stuck/old crafting items:

SELECT * FROM `koja-crafting-queue` 
WHERE completed = 0 
AND endTime < UNIX_TIMESTAMP(NOW()) * 1000;

  • General Settings — This page covers the basic configuration options for Koja-Crafting that control debug mode, language, and player behavior.
  • 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,).
  • Crafting Queue Settings — This page covers the crafting queue system that manages distance checking, warnings, and crafting cancellation when players move away from stations.
  • Configuration — back to the section overview