Server Settings

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


πŸ”§ 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:

Scenario
Recovery Enabled
Recovery 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 Type
Recommended Setting
Reason

Public Server

false (Personal)

Prevents griefing

Roleplay Server

true (Personal)

More realistic

Gang/Faction Server

true (Shared)

Team collaboration

Whitelisted Community

true (Shared)

Trust between players

Advantages of Shared Tables:

  • Gang members can craft for each other

  • Multiple players can contribute to large crafts

  • Faster production with team effort

  • Promotes cooperation

Disadvantages:

  • Players can steal others' items

  • Requires trust and rules

  • Can cause player conflicts

  • Needs active moderation


πŸ” 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;

  • For player data configuration, see Player Progression

  • For queue behavior, see Crafting Queue Settings

  • For installation guide, see Installation

Last updated