Print Utilities
Side: Shared (Client + Server)
Global print functions with color support and debug mode. These are registered as global functions (not under tw.*).
Functions
log(...)
Prints to the console. Tables are JSON-formatted for readability. No color applied.
| Parameter | Type | Description |
|---|---|---|
... | any | Values to print. Tables are serialized to JSON |
sprint(...) / eprint(...)
Prints in red text. Useful for errors.
| Parameter | Type | Description |
|---|---|---|
... | any | Values to print |
gprint(...)
Prints in green text. Useful for success messages.
| Parameter | Type | Description |
|---|---|---|
... | any | Values to print |
oprint(...) / wprint(...)
Prints in orange text. Useful for warnings.
| Parameter | Type | Description |
|---|---|---|
... | any | Values to print |
bprint(...)
Prints in blue text. Useful for informational messages.
| Parameter | Type | Description |
|---|---|---|
... | any | Values to print |
dprint(cb_or_msg, ...)
Debug print. Only outputs when Config.Debug is truthy. Supports %s/%d format strings.
| Parameter | Type | Description |
|---|---|---|
cb_or_msg | function or string | If a function, calls it and prints the return value. If a string, formats with remaining args |
... | any | Format arguments (when cb_or_msg is a string) |
Inline Colors
All print functions support inline color tags within strings:
| Tag | Color |
|---|---|
~red~ | Red |
~green~ | Green |
~orange~ | Orange |
~blue~ | Blue |
Examples
Basic logging
lua
log("Server started")
log("Player data:", { name = "John", job = "sheriff" })
-- Output: Server started
-- Output: Player data: {"name":"John","job":"sheriff"}Colored output
lua
gprint("Successfully loaded", resource_name)
sprint("Failed to connect to database")
oprint("Warning: config value missing, using default")
bprint("Processing", #items, "items")Debug print (only when Config.Debug is true)
lua
Config.Debug = true
-- Simple format string
dprint("Player %s collected %d items", player_name, count)
-- With a callback (evaluated only if debug is on)
dprint(function()
return "Expensive debug info: " .. json.encode(large_table)
end)Inline color tags
lua
log("Status: ~green~OK~red~ errors: 0")
oprint("Item ~blue~bandage~orange~ added to inventory")Notes
logserializes tables to JSON automatically, making it convenient for inspecting data structures.dprintchecksConfig.Debugbefore evaluating its arguments. When passing a function, the function is only called if debug mode is active, avoiding unnecessary computation in production.- Color output depends on terminal/console support. In the FiveM/RedM server console, ANSI colors are supported.

