Koja Scripts
KOJA-LIB

Debugging

koja-lib includes a debug printer with coloured log levels.

Debugging

koja-lib includes a debug printer with coloured log levels.


Config.Debug

Enable debug output globally:

-- editable/shared/config.lua
Config.Debug = true

When enabled, internal koja-lib messages are printed to the console (points callbacks, DUI lifecycle, storage events, etc.).


KOJA.Client.Print

Print a formatted debug message to the client console.

KOJA.Client.Print(level, debug, message)
ParameterTypeDescription
levelstringLog level — see table below
debugbooleanIf false, the message is suppressed
messageanyString or table to print (tables are JSON-encoded)

Log Levels

LevelColourUse Case
"success"GreenSuccessful operations
"error"RedErrors and failures
"warn"YellowWarnings and unexpected states
"info"BlueInformational messages
"debug"CyanVerbose debug output

Examples

KOJA.Client.Print('info', Config.Debug, 'Player loaded')

KOJA.Client.Print('success', Config.Debug, 'Item added successfully')

KOJA.Client.Print('error', Config.Debug, 'Failed to fetch player data')

KOJA.Client.Print('warn', Config.Debug, 'Inventory adapter not found, using fallback')

-- Print a table (auto JSON-encoded)
KOJA.Client.Print('debug', Config.Debug, { job = 'police', grade = 2 })

Gate behind Config.Debug

Pass Config.Debug as the second argument so messages only print when debugging is on:

KOJA.Client.Print('info', Config.Debug, 'Adapter resolved: ' .. KOJA.Inventory)

Pass true directly to always print regardless of the config:

KOJA.Client.Print('error', true, 'Critical failure — always shown')

Console Output Format

^2[SUCCESS]  ^7  Item added successfully
^1[ERROR]    ^7  Failed to fetch player data
^3[WARN]     ^7  Inventory adapter not found, using fallback
^4[INFO]     ^7  Player loaded
^6[DEBUG]    ^7  {"job":"police","grade":2}

Colours use FiveM's ^n colour codes and render in the F8 console.

  • Getting Started — Configuration and Installation for Getting Started.
  • API Reference — Client API and Server API for API Reference.
  • Frameworks — Custom Framework and Overview for Frameworks.
  • Inventory — Custom Inventory and Overview for Inventory.
  • Weapon — Utility function for reading the player's current weapon state.
  • Text UI — A small on-screen prompt that shows an action key and a label.