{
 "name": "Snayl Lua API",
 "language": "en",
 "schemaVersion": 1,
 "scope": "Reference for the Snayl Lua API exposed by the Snayl client runtime: runtime control, client resources, natives and native hooks, HTTP, keyboard input, NUI surfaces, damage events, clipboard, and server information. Snayl.Drawing, Snayl.SyncTree, Snayl.Images, Snayl.Fonts, and Snayl.Events are reserved empty tables and are not documented here.",
 "verification": "Described from the Snayl Lua and C++ implementation in Source/sdk/Snayl-API.h. Behaviour that depends on the FiveM build (native availability, NUI exports, optional bridges) can differ at runtime. The page was not tested in a live game session; the native-hook and console-command claims in particular are untested.",
 "sources": [
  "API.md",
  "API.json",
  "Source/sdk/Snayl-API.h",
  "Source/sdk/Executor.cpp"
 ],
 "conventions": {
  "returns": "Ordered list of return values. An empty list means the function documents no return value.",
  "hash": "A native hash is passed as a full 64-bit value: a Lua integer, a decimal string, or a 0x-prefixed hexadecimal string such as 0xD24D37CC275948CC. Floats are rejected so no byte is lost.",
  "scope": "Snayl functions are available in the isolated editor runtime and in client resources created with Snayl.CreateResource."
 },
 "functionCount": 80,
 "types": {
  "HttpResult": {
   "type": "table",
   "description": "Table returned by Snayl.HttpGet and Snayl.HttpPost.",
   "fields": {
    "success": {
     "type": "boolean",
     "description": "True for a 2xx response."
    },
    "status": {
     "type": "integer",
     "description": "HTTP status code, or 0 when no HTTP response was received."
    },
    "data": {
     "type": "string",
     "description": "Response body."
    },
    "error": {
     "type": "string",
     "description": "Failure reason, or an empty string on success."
    }
   }
  }
 },
 "functions": {
  "Snayl.Execute": {
   "signature": "Snayl.Execute(code)",
   "description": "Runs a Lua chunk in the isolated client runtime and reports whether it completed.",
   "parameters": [
    {
     "name": "code",
     "type": "string",
     "description": "Lua source to run. Empty source is rejected."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the chunk compiled and ran without error."
    }
   ],
   "notes": [
    "The two-argument form Snayl.Execute(resource, code) only accepts the current resource name; any other name fails with a message.",
    "Syntax errors and runtime errors are printed to the console and return false."
   ],
   "exampleLua": "local ok = Snayl.Execute([[print('hello from Snayl')]])\nprint(ok)",
   "category": "runtime"
  },
  "Snayl.Scripting.Execute": {
   "signature": "Snayl.Scripting.Execute(code)",
   "description": "Loads and runs Lua source in the current runtime without reporting errors.",
   "parameters": [
    {
     "name": "code",
     "type": "string",
     "description": "Lua source to load."
    }
   ],
   "returns": [],
   "notes": [
    "Compilation and runtime errors are swallowed by pcall and nothing is returned."
   ],
   "category": "runtime"
  },
  "Snayl.RestartEnvironment": {
   "signature": "Snayl.RestartEnvironment()",
   "description": "Requests a rebuild of the isolated Lua runtime, the same path as the Refresh button.",
   "parameters": [],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the native bridge accepted the request."
    },
    {
     "name": "reason",
     "type": "string?",
     "description": "Failure message when the request was not accepted."
    }
   ],
   "notes": [
    "The runtime is rebuilt between two ticks, so the call returns before the restart happens.",
    "Global variables, registered native hooks, and created resources of the runtime are lost, and open NUI surfaces are closed."
   ],
   "exampleLua": "Snayl.RestartEnvironment()",
   "category": "runtime"
  },
  "Snayl.print": {
   "signature": "Snayl.print(...)",
   "description": "Writes values to the F8 console, separated by tabs and including nil.",
   "parameters": [
    {
     "name": "...",
     "type": "any",
     "description": "Values to write. Tables and other objects go through tostring."
    }
   ],
   "returns": [],
   "notes": [
    "nil is written as nil, and several arguments are separated by a tab.",
    "Uses the runtime print, which writes to the F8 console of the Snayl runtime. A resource created with Snayl.CreateResource keeps its own print for its script:<name> channel.",
    "A value whose __tostring raises is written as <type>.",
    "When the runtime has no print, the text is sent through the console bridge 0x534E5054 instead."
   ],
   "exampleLua": "Snayl.print('Resource:', GetCurrentResourceName(), 'value:', 42)",
   "category": "runtime"
  },
  "Snayl.pcall": {
   "signature": "Snayl.pcall(func, ...)",
   "description": "Runs a function in a protected call and preserves every result, including nil values.",
   "parameters": [
    {
     "name": "func",
     "type": "function",
     "description": "Function to execute."
    },
    {
     "name": "...",
     "type": "any",
     "description": "Arguments passed to func."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True on success, false on failure."
    },
    {
     "name": "results",
     "type": "any",
     "description": "All results on success, or the error message on failure."
    }
   ],
   "notes": [
    "Multiple results and nil values are preserved, including a nil before another result.",
    "A func that is not a function fails without raising, with the usual attempt to call message."
   ],
   "exampleLua": "local ok, result = Snayl.pcall(function()\n  return 6 * 7\nend)\nSnayl.print(ok, result)",
   "category": "runtime"
  },
  "Snayl.CreateThread": {
   "signature": "Snayl.CreateThread(func)",
   "description": "Starts a coroutine that runs alongside the game loop, for timed work that calls Wait.",
   "parameters": [
    {
     "name": "func",
     "type": "function",
     "description": "Function to run inside the coroutine."
    }
   ],
   "returns": [
    {
     "name": "thread",
     "type": "integer",
     "description": "Reference of the created thread, or 0 when func is not a function or the runtime cannot start threads."
    }
   ],
   "notes": [
    "The thread is tracked by the editor session, so a Refresh or stop closes suspended ones.",
    "An error inside the thread unwinds it and is then raised on the game loop, like other editor threads."
   ],
   "exampleLua": "Snayl.CreateThread(function()\n  Wait(100)\n  Snayl.print('Coroutine resumed')\nend)",
   "category": "runtime"
  },
  "Snayl.Wait": {
   "signature": "Snayl.Wait(ms)",
   "description": "Pauses the current coroutine for the requested delay; 0 resumes it on the next game tick.",
   "parameters": [
    {
     "name": "ms",
     "type": "number",
     "description": "Delay in milliseconds. 0 yields until the next available tick."
    }
   ],
   "returns": [],
   "notes": [
    "Use it inside a coroutine that can yield, such as one started with Snayl.CreateThread or a Citizen thread.",
    "A negative or non-finite delay is treated as 0.",
    "Returns nothing; use it for timing, not for polling a result."
   ],
   "exampleLua": "Snayl.CreateThread(function() Snayl.Wait(1000); Snayl.print('After the delay') end)",
   "category": "runtime"
  },
  "Snayl.type": {
   "signature": "Snayl.type(value)",
   "description": "Returns the type of a value, including FiveM-specific types such as vector3.",
   "parameters": [
    {
     "name": "value",
     "type": "any",
     "description": "Value to inspect. Pass nil explicitly to inspect nil."
    }
   ],
   "returns": [
    {
     "name": "name",
     "type": "string",
     "description": "Lua type name, such as number, table, nil, or vector3."
    }
   ],
   "notes": [
    "Vector values report their own tag, so a vector3 created by the game returns vector3 rather than userdata."
   ],
   "exampleLua": "Snayl.print(Snayl.type(42), Snayl.type(vector3(1, 2, 3)))",
   "category": "runtime"
  },
  "Snayl.tostring": {
   "signature": "Snayl.tostring(value)",
   "description": "Converts a value to text, using its __tostring metamethod when it defines one.",
   "parameters": [
    {
     "name": "value",
     "type": "any",
     "description": "Value to convert."
    }
   ],
   "returns": [
    {
     "name": "text",
     "type": "string",
     "description": "Converted value."
    }
   ],
   "notes": [
    "A conversion that fails raises a Lua error, unlike Snayl.print which writes <type> instead.",
    "Numbers keep their Lua formatting, so 42 becomes 42 and 4.5 becomes 4.5."
   ],
   "exampleLua": "local text = Snayl.tostring(42)",
   "category": "runtime"
  },
  "Snayl.setmetatable": {
   "signature": "Snayl.setmetatable(target, metatable)",
   "description": "Assigns a metatable to a table, or removes it when passed nil.",
   "parameters": [
    {
     "name": "target",
     "type": "table",
     "description": "Table to modify."
    },
    {
     "name": "metatable",
     "type": "table|nil",
     "description": "New metatable, or nil to remove it."
    }
   ],
   "returns": [
    {
     "name": "target",
     "type": "table",
     "description": "The original target table."
    }
   ],
   "notes": [
    "A protected metatable cannot be replaced or removed through this function, so it raises a Lua error."
   ],
   "exampleLua": "local values = {}; Snayl.setmetatable(values, { __index = function() return 0 end }); Snayl.print(values.missing)",
   "category": "runtime"
  },
  "Snayl.load": {
   "signature": "Snayl.load(chunk, chunkName?, mode?, environment?)",
   "description": "Compiles Lua source, bytecode or a reader function into a callable function without executing it.",
   "parameters": [
    {
     "name": "chunk",
     "type": "string|number|function",
     "description": "Source text or bytecode, a number converted to text, or a reader returning string fragments until nil or an empty string."
    },
    {
     "name": "chunkName",
     "type": "string|nil",
     "description": "Optional name used in diagnostics."
    },
    {
     "name": "mode",
     "type": "string|nil",
     "description": "Allowed input: t for text, b for bytecode, bt for either. Defaults to bt."
    },
    {
     "name": "environment",
     "type": "any",
     "description": "Environment value, normally a table. Omit it to use the runtime globals; pass nil explicitly for a nil environment."
    }
   ],
   "returns": [
    {
     "name": "chunk",
     "type": "function",
     "description": "The compiled function on success."
    },
    {
     "name": "error",
     "type": "string",
     "description": "The compilation error, returned instead of the function on failure."
    }
   ],
   "notes": [
    "Nothing runs until you call the returned function.",
    "Pass _ENV explicitly when the chunk should keep the current environment.",
    "An explicit nil environment is enforced by clearing the chunk _ENV after compilation, because the runtime ignores a nil environment argument.",
    "A compilation failure returns nil followed by the error, so wrap the call in an if instead of using assert in a hot loop."
   ],
   "exampleLua": "local chunk, err = Snayl.load('return value * 2', '=example', 't', { value = 21 }); if chunk then Snayl.print(chunk()) else Snayl.print(err) end",
   "category": "runtime"
  },
  "Snayl.loadstring": {
   "signature": "Snayl.loadstring(source, chunkName?)",
   "description": "Compiles a Lua source string into a callable function without executing it.",
   "parameters": [
    {
     "name": "source",
     "type": "string|number",
     "description": "String to compile; a number is converted to text by Lua."
    },
    {
     "name": "chunkName",
     "type": "string|nil",
     "description": "Optional diagnostic name."
    }
   ],
   "returns": [
    {
     "name": "chunk",
     "type": "function",
     "description": "The compiled function on success."
    },
    {
     "name": "error",
     "type": "string",
     "description": "The compilation error, returned instead of the function on failure."
    }
   ],
   "notes": [
    "Text only: bytecode needs Snayl.load with mode b.",
    "Invalid argument types raise a Lua error instead of returning nil.",
    "Use Snayl.load when you need a reader function, a loading mode or a custom environment."
   ],
   "exampleLua": "local chunk, err = Snayl.loadstring('return 6 * 7', '=example'); if chunk then Snayl.print(chunk()) else Snayl.print(err) end",
   "category": "runtime"
  },
  "Snayl.RawGet": {
   "signature": "Snayl.RawGet(target, key)",
   "description": "Reads a stored table value without calling its __index metamethod.",
   "parameters": [
    {
     "name": "target",
     "type": "table",
     "description": "Table to read."
    },
    {
     "name": "key",
     "type": "any",
     "description": "Key to look up."
    }
   ],
   "returns": [
    {
     "name": "value",
     "type": "any",
     "description": "Stored value, or nil if the key is absent."
    }
   ],
   "notes": [
    "Use it when a metatable default would hide whether the key really exists."
   ],
   "exampleLua": "local values = { answer = 42 }; Snayl.print(Snayl.RawGet(values, 'answer'))",
   "category": "runtime"
  },
  "Snayl.RawSet": {
   "signature": "Snayl.RawSet(target, key, value)",
   "description": "Writes a table value without calling its __newindex metamethod.",
   "parameters": [
    {
     "name": "target",
     "type": "table",
     "description": "Table to modify."
    },
    {
     "name": "key",
     "type": "any",
     "description": "Valid table key; nil and NaN keys are rejected."
    },
    {
     "name": "value",
     "type": "any",
     "description": "Value to store, including nil."
    }
   ],
   "returns": [
    {
     "name": "target",
     "type": "table",
     "description": "The original target table."
    }
   ],
   "notes": [
    "Setting the value to nil removes the key.",
    "The write bypasses __newindex, so a read-only proxy can only be changed through this call."
   ],
   "exampleLua": "local values = {}; Snayl.RawSet(values, 'answer', 42); Snayl.print(values.answer)",
   "category": "runtime"
  },
  "Snayl.GetMetatable": {
   "signature": "Snayl.GetMetatable(value)",
   "description": "Returns the actual metatable of a value, or false if it has none. A __metatable field does not replace the returned table.",
   "parameters": [
    {
     "name": "value",
     "type": "any",
     "description": "Value whose metatable is requested."
    }
   ],
   "returns": [
    {
     "name": "metatable",
     "type": "table|false",
     "description": "The real metatable, or false when the value has none."
    }
   ],
   "notes": [
    "A __metatable guard does not hide the table from this call, unlike getmetatable, as long as the runtime exposes debug.getmetatable. The sandboxed CFX client does not, so the guard is returned there.",
    "Called without an argument it returns no values, so the result can be checked with select('#')"
   ],
   "exampleLua": "local value = {}; Snayl.print(Snayl.GetMetatable(value) == false)",
   "category": "runtime"
  },
  "Snayl.GetUpvalue": {
   "signature": "Snayl.GetUpvalue(func, index)",
   "description": "Reads a value captured by a function and returns that value followed by its name.",
   "parameters": [
    {
     "name": "func",
     "type": "function",
     "description": "Closure to inspect."
    },
    {
     "name": "index",
     "type": "integer",
     "description": "One-based upvalue index."
    }
   ],
   "returns": [
    {
     "name": "value",
     "type": "any",
     "description": "The captured value."
    },
    {
     "name": "name",
     "type": "string",
     "description": "The upvalue name."
    }
   ],
   "notes": [
    "Returns no values when the function is not a closure or the index is out of range, so select('#') tells a real nil apart from a miss."
   ],
   "exampleLua": "local captured = 42; local function read() return captured end; local value, name = Snayl.GetUpvalue(read, 1); Snayl.print(name, value)",
   "category": "runtime"
  },
  "Snayl.SetUpvalue": {
   "signature": "Snayl.SetUpvalue(func, index, value)",
   "description": "Replaces a value captured by a function and returns its name.",
   "parameters": [
    {
     "name": "func",
     "type": "function",
     "description": "Closure to modify."
    },
    {
     "name": "index",
     "type": "integer",
     "description": "One-based upvalue index."
    },
    {
     "name": "value",
     "type": "any",
     "description": "New value, including nil."
    }
   ],
   "returns": [
    {
     "name": "name",
     "type": "string",
     "description": "The upvalue name on success."
    }
   ],
   "notes": [
    "Changes are visible to every closure that shares the same captured variable.",
    "Returns no values for an invalid function or index.",
    "When the runtime does not expose debug.setupvalue (the sandboxed CFX client), it returns nil and an availability message instead of raising."
   ],
   "exampleLua": "local captured = 1; local function read() return captured end; local name = Snayl.SetUpvalue(read, 1, 42); Snayl.print(name, read())",
   "category": "runtime"
  },
  "Snayl.GetRegistry": {
   "signature": "Snayl.GetRegistry()",
   "description": "Returns the Lua registry of the current environment, including its stored references and shared tables.",
   "parameters": [],
   "returns": [
    {
     "name": "registry",
     "type": "table",
     "description": "The current Lua registry."
    }
   ],
   "notes": [
    "The returned table is live: changes affect the current Lua environment.",
    "Without debug.getregistry, as on the sandboxed CFX client, it returns the globals table plus a second value describing the fallback.",
    "The registry holds the loaded modules table and the globals table, so it is also a way to reach them as data."
   ],
   "exampleLua": "Snayl.print('Registry type:', Snayl.type(Snayl.GetRegistry()))",
   "category": "runtime"
  },
  "Snayl.ScanAllStrings": {
   "signature": "Snayl.ScanAllStrings(minLength?, maxLength?)",
   "description": "Lists unique strings reachable in the current resource Lua VM, sorted, with count and truncated fields.",
   "parameters": [
    {
     "name": "minLength",
     "type": "integer|nil",
     "description": "Minimum byte length, default 5."
    },
    {
     "name": "maxLength",
     "type": "integer|nil",
     "description": "Maximum byte length, default 80; both bounds are clamped to 0..65536."
    }
   ],
   "returns": [
    {
     "name": "values",
     "type": "table",
     "description": "Sorted strings plus count and truncated fields."
    }
   ],
   "notes": [
    "At most 16384 strings and 4 MiB are retained, and a scan examines at most one million objects.",
    "The walk starts at the registry and follows globals, nested tables, metatables and function upvalues, because Lua does not expose the VM string table. Strings that are unreachable from there are not listed.",
    "Other resource VMs are not scanned."
   ],
   "exampleLua": "local values = Snayl.ScanAllStrings(5, 80); for _, text in ipairs(values) do Snayl.print(text) end; Snayl.print(values.count, values.truncated)",
   "category": "runtime"
  },
  "Snayl.ScanProtoStrings": {
   "signature": "Snayl.ScanProtoStrings(func)",
   "description": "Lists string constants in a Lua function and its nested prototypes.",
   "parameters": [
    {
     "name": "func",
     "type": "function",
     "description": "A Lua function. C functions are rejected."
    }
   ],
   "returns": [
    {
     "name": "values",
     "type": "table",
     "description": "Sorted unique strings plus count and truncated fields."
    }
   ],
   "notes": [
    "Includes strings of 4..199 bytes.",
    "The function is dumped and its bytecode constants are read, so stripped or partially parsed data sets truncated instead of failing.",
    "Traversal and result sizes are bounded; truncated reports an incomplete scan.",
    "A runtime that disables string.dump (the sandboxed CFX client) returns an empty list with truncated and unsupported set, instead of guessing."
   ],
   "exampleLua": "local function example() return 'example:event' end; local values = Snayl.ScanProtoStrings(example); for _, text in ipairs(values) do Snayl.print(text) end",
   "category": "runtime"
  },
  "Snayl.CreateResource": {
   "signature": "Snayl.CreateResource(name, code)",
   "description": "Creates and starts a client resource from the supplied Lua source.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "1 to 64 letters, digits, underscores, or hyphens."
    },
    {
     "name": "code",
     "type": "string",
     "description": "Non-empty Lua source, at most 4 MiB, without NUL bytes."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the request was accepted."
    },
    {
     "name": "reason",
     "type": "string?",
     "description": "Failure message, such as a duplicate name."
    }
   ],
   "notes": [
    "The resource has its own globals, sees the Snayl table, and GetCurrentResourceName() returns its name.",
    "Its print output goes to its own console channel, script:<name>.",
    "Its code runs in its own thread, so Wait and CreateThread behave as in a real resource."
   ],
   "exampleLua": "Snayl.CreateResource('demo', [[\n  print('running', GetCurrentResourceName())\n]])",
   "category": "resources"
  },
  "Snayl.DestroyResource": {
   "signature": "Snayl.DestroyResource(name)",
   "description": "Stops and unloads a resource created with Snayl.CreateResource.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Name of a resource created by Snayl."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the resource was destroyed."
    },
    {
     "name": "reason",
     "type": "string?",
     "description": "Failure message when the resource does not exist."
    }
   ],
   "notes": [
    "Suspended threads are closed, CreateThread and SetTimeout stop working for that resource, and its name becomes available again.",
    "Only client resources created by Snayl can be destroyed this way."
   ],
   "category": "resources"
  },
  "Snayl.NativeLogger": {
   "signature": "Snayl.NativeLogger(name)",
   "description": "Lists the natives a resource uses, then prints the sorted list.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Loaded resource, or a resource created with Snayl.CreateResource."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the scan completed."
    },
    {
     "name": "natives",
     "type": "table | string",
     "description": "Sorted list of native names, or a failure message."
    }
   ],
   "notes": [
    "For a loaded resource it reads fxmanifest.lua or __resource.lua and loads client_scripts, shared_scripts, and .lua files through LoadResourceFile.",
    "For a resource created with Snayl.CreateResource it scans the stored source.",
    "Comments and string literals are stripped; only identifiers that exist as functions in the runtime are kept.",
    "Manifest glob patterns such as *.lua are not expanded."
   ],
   "category": "resources"
  },
  "Snayl.Inject": {
   "signature": "Snayl.Inject(res, code)",
   "description": "Delegates to an optional resource-injection bridge.",
   "parameters": [
    {
     "name": "res",
     "type": "string",
     "description": "Target client resource name, or \"any\" to pick a random client resource from Snayl.Resources.GetList()."
    },
    {
     "name": "code",
     "type": "string",
     "description": "Lua source to inject."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True only when the bridge confirmed success."
    },
    {
     "name": "reason",
     "type": "string?",
     "description": "Failure message or bridge reply."
    }
   ],
   "notes": [
    "res = \"any\" reads __snaylGetResList (installed from GetNumResources when no external bridge exists) and injects into one of those client resources, chosen at random each call.",
    "When __snaylGetResList is missing or empty, res = \"any\" returns false with a message instead of picking a name.",
    "Requires a __snaylInjectRes function to be present in the runtime; the supplied runtime does not install one, so the call returns false with a message.",
    "Snayl.InjectSafe wraps Snayl.Inject in pcall and converts exceptions into failure messages."
   ],
   "category": "resources"
  },
  "Snayl.InjectSafe": {
   "signature": "Snayl.InjectSafe(res, code)",
   "description": "Protected variant of Snayl.Inject that turns Lua errors into failure messages.",
   "parameters": [
    {
     "name": "res",
     "type": "string",
     "description": "Target client resource name, or \"any\" to pick a random client resource from Snayl.Resources.GetList()."
    },
    {
     "name": "code",
     "type": "string",
     "description": "Lua source to inject."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the bridge confirmed success."
    },
    {
     "name": "reason",
     "type": "string?",
     "description": "Failure message."
    }
   ],
   "category": "resources"
  },
  "Snayl.Resources.Inject": {
   "aliasOf": "Snayl.Inject",
   "signature": "Snayl.Resources.Inject(res, code)",
   "description": "Alias of Snayl.Inject.",
   "parameters": [
    {
     "name": "res",
     "type": "string"
    },
    {
     "name": "code",
     "type": "string"
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean"
    },
    {
     "name": "reason",
     "type": "string?"
    }
   ],
   "category": "resources"
  },
  "Snayl.Resources.NativeLogger": {
   "aliasOf": "Snayl.NativeLogger",
   "signature": "Snayl.Resources.NativeLogger(name)",
   "description": "Alias of Snayl.NativeLogger.",
   "parameters": [
    {
     "name": "name",
     "type": "string"
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean"
    },
    {
     "name": "natives",
     "type": "table | string"
    }
   ],
   "category": "resources"
  },
  "Snayl.Resources.CreateResource": {
   "aliasOf": "Snayl.CreateResource",
   "signature": "Snayl.Resources.CreateResource(name, code)",
   "description": "Alias of Snayl.CreateResource.",
   "parameters": [
    {
     "name": "name",
     "type": "string"
    },
    {
     "name": "code",
     "type": "string"
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean"
    },
    {
     "name": "reason",
     "type": "string?"
    }
   ],
   "category": "resources"
  },
  "Snayl.Resources.DestroyResource": {
   "aliasOf": "Snayl.DestroyResource",
   "signature": "Snayl.Resources.DestroyResource(name)",
   "description": "Alias of Snayl.DestroyResource.",
   "parameters": [
    {
     "name": "name",
     "type": "string"
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean"
    },
    {
     "name": "reason",
     "type": "string?"
    }
   ],
   "category": "resources"
  },
  "Snayl.Resources.GetList": {
   "signature": "Snayl.Resources.GetList()",
   "description": "Lists the client resources known to the runtime: an external __snaylGetResList bridge when it exists, otherwise GetNumResources / GetResourceByFindIndex.",
   "parameters": [],
   "returns": [
    {
     "name": "resources",
     "type": "table",
     "description": "Resource names, or an empty table when neither the bridge nor the natives are available."
    }
   ],
   "category": "resources",
   "notes": [
    "The runtime installs __snaylGetResList from GetNumResources and GetResourceByFindIndex; an external bridge set before Snayl loads is kept as-is.",
    "Without __snaylGetResList the call returns an empty table, so the example prints the no-bridge line.",
    "The bridge may return an array of names or a map keyed by name; the example normalises both before printing."
   ],
   "exampleLua": "-- Prints every client resource reported by the optional list bridge.\nlocal list = Snayl.Resources.GetList()\nlocal names = {}\nfor key, value in pairs(list) do\n    local name = type(value) == 'string' and value or (type(key) == 'string' and key)\n    if name then names[#names + 1] = name end\nend\ntable.sort(names)\nprint(('Snayl.Resources.GetList(): %d resource(s)'):format(#names))\nfor index, name in ipairs(names) do\n    print(('[%d] %s'):format(index, name))\nend\nif #names == 0 then\n    print('No list bridge: __snaylGetResList is not installed in this runtime.')\nend"
  },
  "Snayl.InvokeNative": {
   "signature": "Snayl.InvokeNative(hash, ...)",
   "description": "Calls a GTA or CFX native by its full 64-bit hash.",
   "parameters": [
    {
     "name": "hash",
     "type": "integer | string",
     "description": "Native hash as a number, decimal string, or 0x-hex string."
    },
    {
     "name": "...",
     "type": "any",
     "description": "Arguments matching the native signature."
    }
   ],
   "returns": [
    {
     "name": "result",
     "type": "any",
     "description": "Native return values, or nil and a message when the call failed."
    }
   ],
   "notes": [
    "Citizen.ResultAs* and Citizen.PointerValue* markers are passed through unchanged.",
    "A non-integer hash is rejected before the call with hash must be an integer or hash must be a number or a string.",
    "Calls made through Citizen.InvokeNative in this runtime run any registered Snayl native hook first."
   ],
   "exampleLua": "local model = Snayl.InvokeNative(0xD24D37CC275948CC, 'adder')\nprint(model)",
   "category": "natives"
  },
  "Snayl.Natives.Invoke": {
   "aliasOf": "Snayl.InvokeNative",
   "signature": "Snayl.Natives.Invoke(hash, ...)",
   "description": "Alias of Snayl.InvokeNative.",
   "parameters": [
    {
     "name": "hash",
     "type": "integer | string"
    },
    {
     "name": "...",
     "type": "any"
    }
   ],
   "returns": [
    {
     "name": "result",
     "type": "any"
    }
   ],
   "category": "natives"
  },
  "Snayl.HookNative": {
   "signature": "Snayl.HookNative(hash, callback)",
   "description": "Registers a callback for a native and returns true, or false with a reason.",
   "parameters": [
    {
     "name": "hash",
     "type": "integer",
     "description": "Nonzero exact native hash as a number, decimal string, or 0x-hex string."
    },
    {
     "name": "label",
     "type": "string",
     "optional": true,
     "description": "Optional diagnostic name. The form Snayl.HookNative(hash, label, callback) is also accepted."
    },
    {
     "name": "callback",
     "type": "function",
     "description": "Receives the native arguments. Return no values, or a truthy first value, to keep the original call. Return false or nil followed by values to replace the results."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the hook was registered."
    },
    {
     "name": "reason",
     "type": "string?",
     "description": "Failure message for an invalid hash, callback, or label."
    }
   ],
   "notes": [
    "Registering the same hash again replaces the previous callback.",
    "A callback that raises an error is ignored and the original call proceeds, so the native keeps its normal behaviour.",
    "Callbacks must not yield.",
    "While a callback runs, a call to the same native bypasses the hook, which prevents recursion.",
    "Hooks wrap Citizen.InvokeNative in the isolated runtime and in resources created with Snayl.CreateResource, which share it. Global native functions such as GetHashKey(...) and other game resources are not intercepted.",
    "A Refresh or Snayl.RestartEnvironment removes every hook."
   ],
   "exampleLua": "local hash = 0xD24D37CC275948CC -- GET_HASH_KEY\nlocal ok, err = Snayl.HookNative(hash, function(value)\n  return true -- keep the original result\nend)\nif not ok then print(err) end",
   "category": "natives"
  },
  "Snayl.UnhookNative": {
   "signature": "Snayl.UnhookNative(hash)",
   "description": "Removes the callback registered for a native hash and restores normal behaviour.",
   "parameters": [
    {
     "name": "hash",
     "type": "integer",
     "description": "Nonzero exact native hash."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True, including when no hook exists for that hash; false for a zero or non-integer hash."
    },
    {
     "name": "reason",
     "type": "string?",
     "description": "Failure message for an invalid hash."
    }
   ],
   "notes": [
    "When the last hook is removed, Citizen.InvokeNative is restored to its original function."
   ],
   "exampleLua": "Snayl.UnhookNative(0xD24D37CC275948CC)",
   "category": "natives"
  },
  "Snayl.UnhookAllNatives": {
   "signature": "Snayl.UnhookAllNatives()",
   "description": "Removes every active Snayl native callback, including callbacks registered by other resources sharing the runtime.",
   "parameters": [],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "Always true."
    }
   ],
   "exampleLua": "Snayl.UnhookAllNatives()",
   "category": "natives"
  },
  "Snayl.HttpGet": {
   "signature": "Snayl.HttpGet(url, headers?, insecure?)",
   "description": "Sends an HTTP GET request and waits for the response.",
   "parameters": [
    {
     "name": "url",
     "type": "string",
     "description": "http:// or https:// URL, at most 2048 bytes."
    },
    {
     "name": "headers",
     "type": "table",
     "optional": true,
     "description": "Header table such as { ['Content-Type'] = 'application/json' }."
    },
    {
     "name": "insecure",
     "type": "boolean",
     "optional": true,
     "default": false,
     "description": "Skip TLS certificate verification."
    }
   ],
   "returns": [
    {
     "name": "response",
     "type": "HttpResult",
     "description": "Status, body, and failure reason."
    }
   ],
   "notes": [
    "The request runs on a WinHTTP thread and the call waits with Wait(0), so start it from a CreateThread coroutine to keep your logic responsive.",
    "Requests time out after 30 seconds.",
    "Header names and values must not contain line breaks."
   ],
   "exampleLua": "local res = Snayl.HttpGet('https://example.com/')\nprint(res.status, res.data)",
   "category": "http"
  },
  "Snayl.HttpPost": {
   "signature": "Snayl.HttpPost(url, payload, headers?, insecure?)",
   "description": "Sends an HTTP POST request and waits for the response.",
   "parameters": [
    {
     "name": "url",
     "type": "string",
     "description": "http:// or https:// URL, at most 2048 bytes."
    },
    {
     "name": "payload",
     "type": "string",
     "description": "Request body, at most 16 MiB. Use json.encode for JSON."
    },
    {
     "name": "headers",
     "type": "table",
     "optional": true,
     "description": "Header table such as { ['Content-Type'] = 'application/json' }."
    },
    {
     "name": "insecure",
     "type": "boolean",
     "optional": true,
     "default": false,
     "description": "Skip TLS certificate verification."
    }
   ],
   "returns": [
    {
     "name": "response",
     "type": "HttpResult",
     "description": "Status, body, and failure reason."
    }
   ],
   "notes": [
    "The request runs on a WinHTTP thread and the call waits with Wait(0), so start it from a CreateThread coroutine.",
    "Requests time out after 30 seconds."
   ],
   "exampleLua": "local res = Snayl.HttpPost('https://example.com/api', json.encode({ ok = true }),\n  { ['Content-Type'] = 'application/json' })\nprint(res.success, res.status)",
   "category": "http"
  },
  "Snayl.HttpBridgeInfo": {
   "signature": "Snayl.HttpBridgeInfo()",
   "description": "Returns the HTTP bridge registration diagnostics written by the C++ side.",
   "parameters": [],
   "returns": [
    {
     "name": "diagnostics",
     "type": "table",
     "description": "Bridge registration state, or nil in a runtime without the bridge."
    }
   ],
   "notes": [
    "Useful when Snayl.HttpGet or Snayl.HttpPost reports that the bridge is unavailable."
   ],
   "category": "http"
  },
  "Snayl.Input.IsKeyJustPressed": {
   "signature": "Snayl.Input.IsKeyJustPressed(vk)",
   "description": "Reports the frame a keyboard key starts being held.",
   "parameters": [
    {
     "name": "vk",
     "type": "integer",
     "description": "Windows virtual-key code."
    }
   ],
   "returns": [
    {
     "name": "pressed",
     "type": "boolean",
     "description": "True on the initial press."
    }
   ],
   "notes": [
    "Only a fixed set of keys is mapped: Enter, Home, Insert, Delete, the arrow keys, F4, and F8. Any other key returns false.",
    "Both normal and disabled controls are checked, so the key is detected while NUI has focus."
   ],
   "exampleLua": "if Snayl.Input.IsKeyJustPressed(36) then print('Home pressed') end",
   "category": "input"
  },
  "Snayl.Input.IsKeyPressed": {
   "signature": "Snayl.Input.IsKeyPressed(vk)",
   "description": "Reports whether a keyboard key is held.",
   "parameters": [
    {
     "name": "vk",
     "type": "integer",
     "description": "Windows virtual-key code."
    }
   ],
   "returns": [
    {
     "name": "pressed",
     "type": "boolean",
     "description": "True while the key is held."
    }
   ],
   "notes": [
    "Uses the same fixed key map as Snayl.Input.IsKeyJustPressed; unknown keys return false."
   ],
   "category": "input"
  },
  "Snayl.IsKeyJustPressed": {
   "aliasOf": "Snayl.Input.IsKeyJustPressed",
   "signature": "Snayl.IsKeyJustPressed(vk)",
   "description": "Alias of Snayl.Input.IsKeyJustPressed.",
   "parameters": [
    {
     "name": "vk",
     "type": "integer"
    }
   ],
   "returns": [
    {
     "name": "pressed",
     "type": "boolean"
    }
   ],
   "category": "input"
  },
  "Snayl.IsKeyPressed": {
   "aliasOf": "Snayl.Input.IsKeyPressed",
   "signature": "Snayl.IsKeyPressed(vk)",
   "description": "Alias of Snayl.Input.IsKeyPressed.",
   "parameters": [
    {
     "name": "vk",
     "type": "integer"
    }
   ],
   "returns": [
    {
     "name": "pressed",
     "type": "boolean"
    }
   ],
   "category": "input"
  },
  "Snayl.CreateNui": {
   "signature": "Snayl.CreateNui(name, url)",
   "description": "Creates a named browser surface managed by the game: a visible, passive CEF frame with no texture or sprite.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Surface name, at most 128 bytes."
    },
    {
     "name": "url",
     "type": "string",
     "description": "Page URL. A URL without a scheme receives the https:// prefix."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the surface was created or reloaded."
    }
   ],
   "notes": [
    "The surface does not capture keyboard or mouse until Snayl.SetNuiFocus is called.",
    "Reusing an existing name loads the new URL into that surface, makes it visible, and releases its focus request."
   ],
   "exampleLua": "Snayl.CreateNui('menu', 'https://example.com/')\nSnayl.SetNuiFocus('menu', true)",
   "category": "nui"
  },
  "Snayl.Nui.CreateNui": {
   "aliasOf": "Snayl.CreateNui",
   "signature": "Snayl.Nui.CreateNui(name, url)",
   "description": "Alias of Snayl.CreateNui.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Surface name, at most 128 bytes."
    },
    {
     "name": "url",
     "type": "string",
     "description": "Page URL. A URL without a scheme receives the https:// prefix."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the surface was created or reloaded."
    }
   ],
   "category": "nui"
  },
  "Snayl.DestroyNui": {
   "signature": "Snayl.DestroyNui(name)",
   "description": "Closes a named surface.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Surface name, at most 128 bytes."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the request was accepted."
    }
   ],
   "category": "nui"
  },
  "Snayl.Nui.DestroyNui": {
   "aliasOf": "Snayl.DestroyNui",
   "signature": "Snayl.Nui.DestroyNui(name)",
   "description": "Alias of Snayl.DestroyNui.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Surface name, at most 128 bytes."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the request was accepted."
    }
   ],
   "category": "nui"
  },
  "Snayl.ToggleLocalNui": {
   "signature": "Snayl.ToggleLocalNui(name)",
   "description": "Shows or hides a named surface without reloading the page.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Surface name."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the request was accepted."
    }
   ],
   "notes": [
    "When the build exposes no visibility control, the frame is closed and recreated from its URL, so the page reloads."
   ],
   "category": "nui"
  },
  "Snayl.Nui.ToggleLocalNui": {
   "aliasOf": "Snayl.ToggleLocalNui",
   "signature": "Snayl.Nui.ToggleLocalNui(name)",
   "description": "Alias of Snayl.ToggleLocalNui.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Surface name."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the request was accepted."
    }
   ],
   "category": "nui"
  },
  "Snayl.SetNuiFocus": {
   "signature": "Snayl.SetNuiFocus(name, focus)",
   "description": "Requests or releases keyboard and mouse for a named surface.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Surface name."
    },
    {
     "name": "focus",
     "type": "boolean",
     "description": "True to capture input, false to release it."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the request was accepted."
    }
   ],
   "notes": [
    "Only one surface can hold focus at a time.",
    "Raises a Lua error when the arguments are not a string and a boolean."
   ],
   "category": "nui"
  },
  "Snayl.Nui.SetNuiFocus": {
   "aliasOf": "Snayl.SetNuiFocus",
   "signature": "Snayl.Nui.SetNuiFocus(name, focus)",
   "description": "Alias of Snayl.SetNuiFocus.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Surface name."
    },
    {
     "name": "focus",
     "type": "boolean",
     "description": "True to capture input, false to release it."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the request was accepted."
    }
   ],
   "category": "nui"
  },
  "Snayl.ExecuteNuiScript": {
   "signature": "Snayl.ExecuteNuiScript(name, source)",
   "description": "Runs JavaScript in a named surface.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Surface name."
    },
    {
     "name": "source",
     "type": "string",
     "description": "JavaScript source, at most 4 MiB."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the script was accepted; false when the build does not expose the call."
    }
   ],
   "category": "nui"
  },
  "Snayl.Nui.ExecuteNuiScript": {
   "aliasOf": "Snayl.ExecuteNuiScript",
   "signature": "Snayl.Nui.ExecuteNuiScript(name, source)",
   "description": "Alias of Snayl.ExecuteNuiScript.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Surface name."
    },
    {
     "name": "source",
     "type": "string",
     "description": "JavaScript source, at most 4 MiB."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the script was accepted; false when the build does not expose the call."
    }
   ],
   "category": "nui"
  },
  "Snayl.SendNuiMessage": {
   "signature": "Snayl.SendNuiMessage(name, json)",
   "description": "Sends a JSON message to a named surface.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Surface name."
    },
    {
     "name": "json",
     "type": "string",
     "description": "JSON text, at most 4 MiB. Use json.encode to build it."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the message was sent."
    }
   ],
   "notes": [
    "The page receives it through window.addEventListener('message', ...)."
   ],
   "exampleLua": "Snayl.SendNuiMessage('menu', json.encode({ visible = true }))",
   "category": "nui"
  },
  "Snayl.Nui.SendNuiMessage": {
   "aliasOf": "Snayl.SendNuiMessage",
   "signature": "Snayl.Nui.SendNuiMessage(name, json)",
   "description": "Alias of Snayl.SendNuiMessage.",
   "parameters": [
    {
     "name": "name",
     "type": "string",
     "description": "Surface name."
    },
    {
     "name": "json",
     "type": "string",
     "description": "JSON text, at most 4 MiB. Use json.encode to build it."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the message was sent."
    }
   ],
   "category": "nui"
  },
  "Snayl.DestroyAllNui": {
   "signature": "Snayl.DestroyAllNui()",
   "description": "Closes every open named surface and clears the surface table.",
   "parameters": [],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "Always true; the call is idempotent."
    }
   ],
   "notes": [
    "An environment reset calls it automatically, so no frame outlives a Refresh."
   ],
   "category": "nui"
  },
  "Snayl.Nui.DestroyAllNui": {
   "aliasOf": "Snayl.DestroyAllNui",
   "signature": "Snayl.Nui.DestroyAllNui()",
   "description": "Alias of Snayl.DestroyAllNui.",
   "parameters": [],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "Always true; the call is idempotent."
    }
   ],
   "category": "nui"
  },
  "Snayl.Network_DamageStatus": {
   "signature": "Snayl.Network_DamageStatus()",
   "description": "Checks whether the damage bridge answers and returns a diagnostic message.",
   "parameters": [],
   "returns": [
    {
     "name": "ready",
     "type": "boolean",
     "description": "True when the bridge reported its ready marker."
    },
    {
     "name": "message",
     "type": "string",
     "description": "Bridge version, or the reason it is unavailable."
    }
   ],
   "exampleLua": "local ready, message = Snayl.Network_DamageStatus()\nprint(ready, message)",
   "category": "damage"
  },
  "Snayl.Network_TriggerDamageEvent": {
   "signature": "Snayl.Network_TriggerDamageEvent(ped, x, y, z, weapon, damage, flags?, silenced?, action?)",
   "description": "Applies a damage event to a ped from the local player.",
   "parameters": [
    {
     "name": "ped",
     "type": "integer",
     "description": "Client ped handle of the target. It must exist and be a ped."
    },
    {
     "name": "x",
     "type": "number",
     "description": "Hit X coordinate."
    },
    {
     "name": "y",
     "type": "number",
     "description": "Hit Y coordinate."
    },
    {
     "name": "z",
     "type": "number",
     "description": "Hit Z coordinate."
    },
    {
     "name": "weapon",
     "type": "integer",
     "description": "Weapon hash, stored as an unsigned 32-bit value."
    },
    {
     "name": "damage",
     "type": "number",
     "description": "Damage amount, zero or greater."
    },
    {
     "name": "flags",
     "type": "integer",
     "optional": true,
     "default": 0,
     "description": "Damage flags, zero or greater."
    },
    {
     "name": "silenced",
     "type": "boolean | 0 | 1",
     "optional": true,
     "default": 0,
     "description": "Silenced flag; booleans are converted."
    },
    {
     "name": "action",
     "type": "integer",
     "optional": true,
     "default": 0,
     "description": "Action result ID. Defaults to 32784 for WEAPON_UNARMED with flags 10."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the bridge acknowledged the event."
    },
    {
     "name": "reason",
     "type": "string?",
     "description": "Validation or bridge failure message."
    }
   ],
   "notes": [
    "The source ped is always PlayerPedId().",
    "Coordinates and damage are sent as floats even when you pass integers.",
    "Every argument is validated in Lua before the native call, so an out-of-range value returns a message naming the field instead of calling the bridge."
   ],
   "exampleLua": "local ok, reason = Snayl.Network_TriggerDamageEvent(\n  PlayerPedId(), 0.0, 0.0, 0.0, 0x0566B5C2, 5.0)\nif not ok then print(reason) end",
   "category": "damage"
  },
  "Snayl.GetServerIP": {
   "signature": "Snayl.GetServerIP()",
   "description": "Reads the address of the connected FiveM server without the port.",
   "parameters": [],
   "returns": [
    {
     "name": "ip",
     "type": "string",
     "description": "203.0.113.7 for IPv4, 2001:db8::1 for IPv6 (brackets removed). Empty when not connected."
    }
   ],
   "notes": [
    "Backed by the client native GET_CURRENT_SERVER_ENDPOINT, which returns ip:port; the port is stripped in Lua.",
    "An IPv6 address keeps every colon and is returned unchanged."
   ],
   "exampleLua": "print(Snayl.GetServerIP())",
   "category": "server"
  },
  "Snayl.GetServerEndpoint": {
   "signature": "Snayl.GetServerEndpoint()",
   "description": "Reads the full ip:port endpoint of the active connection.",
   "parameters": [],
   "returns": [
    {
     "name": "endpoint",
     "type": "string?",
     "description": "203.0.113.7:30120 or [2001:db8::1]:30120."
    },
    {
     "name": "reason",
     "type": "string?",
     "description": "not connected to a server, or GET_CURRENT_SERVER_ENDPOINT is unavailable."
    }
   ],
   "category": "server"
  },
  "Snayl.GetServerVersion": {
   "signature": "Snayl.GetServerVersion()",
   "description": "Reads the game build of the connected server, falling back to the FXServer version.",
   "parameters": [],
   "returns": [
    {
     "name": "build",
     "type": "string",
     "description": "sv_defaultGameBuild (3889), else sv_enforceGameBuild, else the FXServer version string."
    },
    {
     "name": "reason",
     "type": "string?",
     "description": "not connected to a server, server info request failed (...), or version field is missing in /info.json."
    }
   ],
   "notes": [
    "Reads the sv_version convar first when the server replicates it, which needs no HTTP request.",
    "Otherwise requests http://ip:port/info.json through Snayl.HttpGet and prefers sv_defaultGameBuild, then sv_enforceGameBuild, then the server field.",
    "One call makes at most one HTTP request."
   ],
   "exampleLua": "local build, reason = Snayl.GetServerVersion()\nprint(build or reason)",
   "category": "server"
  },
  "Snayl.GetServerName": {
   "signature": "Snayl.GetServerName()",
   "description": "Reads the server hostname with its formatting codes preserved.",
   "parameters": [],
   "returns": [
    {
     "name": "name",
     "type": "string",
     "description": "Hostname such as ^2[FR]^7 Mon ^1Serveur, or an empty string when unavailable."
    }
   ],
   "notes": [
    "Reads the sv_hostname, hostname or sv_projectName convar when the server replicates it; otherwise the hostname field of /dynamic.json.",
    "FXServer removes sv_hostname from /info.json, so the name comes from /dynamic.json, then from hostname or sv_projectName in /info.json.",
    "One call makes at most one request to /dynamic.json and one to /info.json, so call it from a thread when the name is not replicated.",
    "Formatting codes such as ^1, ^2 and ~r~ are kept as-is.",
    "Returns an empty string instead of raising when disconnected or when the field is missing."
   ],
   "exampleLua": "print(Snayl.GetServerName())",
   "category": "server"
  },
  "Snayl.CopyClipboard": {
   "signature": "Snayl.CopyClipboard(text)",
   "description": "Replaces the Windows clipboard text.",
   "parameters": [
    {
     "name": "text",
     "type": "string | number | vector",
     "description": "Value to copy. Other types are converted with tostring; at most 4 MiB of UTF-8, without NUL bytes."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the text was copied."
    }
   ],
   "notes": [
    "Stored as CF_UNICODETEXT, so accents and non-ASCII characters survive the round trip.",
    "If another application holds the clipboard, the call retries briefly and then returns false."
   ],
   "exampleLua": "Snayl.CopyClipboard('hello')\nprint(Snayl.GetClipboard())",
   "category": "clipboard"
  },
  "Snayl.Clipboard.Copy": {
   "aliasOf": "Snayl.CopyClipboard",
   "signature": "Snayl.Clipboard.Copy(text)",
   "description": "Alias of Snayl.CopyClipboard.",
   "parameters": [
    {
     "name": "text",
     "type": "string | number | vector"
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean"
    }
   ],
   "category": "clipboard"
  },
  "Snayl.AddToClipboard": {
   "signature": "Snayl.AddToClipboard(text)",
   "description": "Appends text to the Windows clipboard without a separator.",
   "parameters": [
    {
     "name": "text",
     "type": "string | number | vector",
     "description": "Value to append. The combined text must fit in 4 MiB."
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean",
     "description": "True when the combined text was written."
    }
   ],
   "notes": [
    "The read and write are separate clipboard operations, so a concurrent copy from another application can interleave."
   ],
   "category": "clipboard"
  },
  "Snayl.Clipboard.Add": {
   "aliasOf": "Snayl.AddToClipboard",
   "signature": "Snayl.Clipboard.Add(text)",
   "description": "Alias of Snayl.AddToClipboard.",
   "parameters": [
    {
     "name": "text",
     "type": "string | number | vector"
    }
   ],
   "returns": [
    {
     "name": "ok",
     "type": "boolean"
    }
   ],
   "category": "clipboard"
  },
  "Snayl.GetClipboard": {
   "signature": "Snayl.GetClipboard()",
   "description": "Reads the Windows clipboard text.",
   "parameters": [],
   "returns": [
    {
     "name": "text",
     "type": "string",
     "description": "Clipboard text, or an empty string when it is empty or holds no text format."
    }
   ],
   "category": "clipboard"
  },
  "Snayl.Clipboard.Get": {
   "aliasOf": "Snayl.GetClipboard",
   "signature": "Snayl.Clipboard.Get()",
   "description": "Alias of Snayl.GetClipboard.",
   "parameters": [],
   "returns": [
    {
     "name": "text",
     "type": "string"
    }
   ],
   "category": "clipboard"
  },
  "Snayl.WorldToScreen": {
   "signature": "Snayl.WorldToScreen(x, y, z)",
   "description": "Projects world coordinates into screen pixels. Returns {x, y, onScreen}. A point outside the viewport, behind the camera, or an unavailable camera returns x = 0, y = 0 and onScreen = false.",
   "parameters": [
    {
     "name": "x",
     "type": "number",
     "description": "World X"
    },
    {
     "name": "y",
     "type": "number",
     "description": "World Y"
    },
    {
     "name": "z",
     "type": "number",
     "description": "World Z"
    }
   ],
   "returns": [
    {
     "name": "screen",
     "type": "table",
     "description": "x, y and onScreen."
    }
   ],
   "notes": [
    "Uses GetGameplayCamCoord, GetGameplayCamRot and GetGameplayCamFov, so no memory read is needed.",
    "Camera roll (rot.y) is ignored by the projection."
   ],
   "exampleLua": "local coords = GetEntityCoords(PlayerPedId())\nlocal p = Snayl.WorldToScreen(coords.x, coords.y, coords.z + 1.0)\nif p.onScreen then\n    Snayl.DrawCircle(p.x, p.y, 5, true, 255, 0, 0, 255)\nend\nSnayl.DrawCommit()",
   "category": "draw"
  },
  "Snayl.GetScreenSize": {
   "signature": "Snayl.GetScreenSize()",
   "description": "Returns the current screen resolution in pixels, for proportional layouts (center, corners, percentage positions).",
   "parameters": [],
   "returns": [
    {
     "name": "width",
     "type": "number",
     "description": "Screen width in pixels."
    },
    {
     "name": "height",
     "type": "number",
     "description": "Screen height in pixels."
    }
   ],
   "notes": [
    "Returns 0, 0 until the first frame is displayed."
   ],
   "exampleLua": "local w, h = Snayl.GetScreenSize()\nSnayl.DrawLine(w*0.5 - 10, h*0.5, w*0.5 + 10, h*0.5, 255, 255, 255, 220, 1.5)\nSnayl.DrawCommit()",
   "category": "draw"
  },
  "Snayl.DrawLine": {
   "signature": "Snayl.DrawLine(x1, y1, x2, y2, r, g, b, a, thickness?, priority?)",
   "description": "Draws a straight line from (x1, y1) to (x2, y2) in screen pixels.",
   "parameters": [
    {
     "name": "x1",
     "type": "number",
     "description": "Start X in pixels."
    },
    {
     "name": "y1",
     "type": "number",
     "description": "Start Y in pixels."
    },
    {
     "name": "x2",
     "type": "number",
     "description": "End X in pixels."
    },
    {
     "name": "y2",
     "type": "number",
     "description": "End Y in pixels."
    },
    {
     "name": "r",
     "type": "number",
     "description": "Red 0 to 255."
    },
    {
     "name": "g",
     "type": "number",
     "description": "Green 0 to 255."
    },
    {
     "name": "b",
     "type": "number",
     "description": "Blue 0 to 255."
    },
    {
     "name": "a",
     "type": "number",
     "description": "Alpha 0 to 255."
    },
    {
     "name": "thickness",
     "type": "number?",
     "description": "Optional thickness in pixels. Default: 1.0."
    },
    {
     "name": "priority",
     "type": "number?",
     "description": "Optional draw order. Default: 0."
    }
   ],
   "returns": [],
   "notes": [
    "RGBA channels are clamped to 0..255; non-numeric arguments fall back to 0.",
    "Calls are queued until Snayl.DrawCommit (or Snayl.Wait)."
   ],
   "exampleLua": "Snayl.DrawLine(100, 100, 300, 100, 255, 255, 255, 255, 2)\nSnayl.DrawCommit()",
   "category": "draw"
  },
  "Snayl.DrawRect": {
   "signature": "Snayl.DrawRect(x, y, w, h, filled, r, g, b, a, rounding?, thickness?, priority?)",
   "description": "Draws a rectangle from its top-left corner: filled when filled is true, otherwise a border. Thickness is ignored when filled, rounding when it is not.",
   "parameters": [
    {
     "name": "x",
     "type": "number",
     "description": "Top-left X in pixels."
    },
    {
     "name": "y",
     "type": "number",
     "description": "Top-left Y in pixels."
    },
    {
     "name": "w",
     "type": "number",
     "description": "Width in pixels."
    },
    {
     "name": "h",
     "type": "number",
     "description": "Height in pixels."
    },
    {
     "name": "filled",
     "type": "boolean",
     "description": "true = filled, false = hollow border."
    },
    {
     "name": "r",
     "type": "number",
     "description": "Red 0 to 255."
    },
    {
     "name": "g",
     "type": "number",
     "description": "Green 0 to 255."
    },
    {
     "name": "b",
     "type": "number",
     "description": "Blue 0 to 255."
    },
    {
     "name": "a",
     "type": "number",
     "description": "Alpha 0 to 255."
    },
    {
     "name": "rounding",
     "type": "number?",
     "description": "Optional corner radius. Default: 0."
    },
    {
     "name": "thickness",
     "type": "number?",
     "description": "Optional border thickness. Default: 1.0."
    },
    {
     "name": "priority",
     "type": "number?",
     "description": "Optional draw order. Default: 0."
    }
   ],
   "returns": [],
   "notes": [
    "Rounding is approximated: a centre rectangle plus four corner disks.",
    "Commands stay queued until Snayl.DrawCommit (or Snayl.Wait)."
   ],
   "exampleLua": "Snayl.DrawRect(50, 50, 200, 100, false, 0, 200, 255, 255, 4, 2)\nSnayl.DrawRect(50, 50, 200, 100, true, 0, 0, 0, 180, 6)\nSnayl.DrawCommit()",
   "category": "draw"
  },
  "Snayl.DrawRectMultiColor": {
   "signature": "Snayl.DrawRectMultiColor(x, y, w, h, tl_r, tl_g, tl_b, tl_a, tr_r, tr_g, tr_b, tr_a, br_r, br_g, br_b, br_a, bl_r, bl_g, bl_b, bl_a, priority?)",
   "description": "Draws a filled rectangle with a distinct colour on each corner, interpolated across the surface.",
   "parameters": [
    {
     "name": "x",
     "type": "number",
     "description": "Top-left X."
    },
    {
     "name": "y",
     "type": "number",
     "description": "Top-left Y."
    },
    {
     "name": "w",
     "type": "number",
     "description": "Width."
    },
    {
     "name": "h",
     "type": "number",
     "description": "Height."
    },
    {
     "name": "tl_*, tr_*, br_*, bl_*",
     "type": "number",
     "description": "RGBA per corner: top-left, top-right, bottom-right, bottom-left."
    },
    {
     "name": "priority",
     "type": "number?",
     "description": "Optional draw order. Default: 0."
    }
   ],
   "returns": [],
   "notes": [
    "The gradient is rendered as an 8 x 8 cell grid, because no four-corner primitive exists.",
    "RGBA channels are clamped to 0..255."
   ],
   "exampleLua": "Snayl.DrawRectMultiColor(100, 100, 300, 200,\n    255, 0, 0, 255,\n    255, 255, 0, 255,\n    0, 255, 0, 255,\n    0, 0, 255, 255)\nSnayl.DrawCommit()",
   "category": "draw"
  },
  "Snayl.DrawCircle": {
   "signature": "Snayl.DrawCircle(x, y, radius, filled, r, g, b, a, segments?, thickness?, priority?)",
   "description": "Draws a circle centred on (x, y): a filled disk when filled is true, a ring otherwise.",
   "parameters": [
    {
     "name": "x",
     "type": "number",
     "description": "Center X in pixels."
    },
    {
     "name": "y",
     "type": "number",
     "description": "Center Y in pixels."
    },
    {
     "name": "radius",
     "type": "number",
     "description": "Radius in pixels."
    },
    {
     "name": "filled",
     "type": "boolean",
     "description": "true = filled disk, false = hollow ring."
    },
    {
     "name": "r",
     "type": "number",
     "description": "Red 0 to 255."
    },
    {
     "name": "g",
     "type": "number",
     "description": "Green 0 to 255."
    },
    {
     "name": "b",
     "type": "number",
     "description": "Blue 0 to 255."
    },
    {
     "name": "a",
     "type": "number",
     "description": "Alpha 0 to 255."
    },
    {
     "name": "segments",
     "type": "number?",
     "description": "Optional segment count. 0 auto-picks from the radius."
    },
    {
     "name": "thickness",
     "type": "number?",
     "description": "Optional ring thickness. Default: 1.0."
    },
    {
     "name": "priority",
     "type": "number?",
     "description": "Optional draw order. Default: 0."
    }
   ],
   "returns": [],
   "notes": [
    "A negative radius is clamped to 0.",
    "The ring is drawn one segment at a time."
   ],
   "exampleLua": "Snayl.DrawCircle(400, 300, 50, false, 255, 200, 0, 255, 32, 2)\nSnayl.DrawCircle(400, 300, 6, true, 0, 255, 100, 255)\nSnayl.DrawCommit()",
   "category": "draw"
  },
  "Snayl.DrawTriangle": {
   "signature": "Snayl.DrawTriangle(x1, y1, x2, y2, x3, y3, filled, r, g, b, a, thickness?, priority?)",
   "description": "Draws a triangle from its three corners: filled or outlined.",
   "parameters": [
    {
     "name": "x1, y1",
     "type": "number",
     "description": "First corner."
    },
    {
     "name": "x2, y2",
     "type": "number",
     "description": "Second corner."
    },
    {
     "name": "x3, y3",
     "type": "number",
     "description": "Third corner."
    },
    {
     "name": "filled",
     "type": "boolean",
     "description": "true = filled, false = outline."
    },
    {
     "name": "r",
     "type": "number",
     "description": "Red 0 to 255."
    },
    {
     "name": "g",
     "type": "number",
     "description": "Green 0 to 255."
    },
    {
     "name": "b",
     "type": "number",
     "description": "Blue 0 to 255."
    },
    {
     "name": "a",
     "type": "number",
     "description": "Alpha 0 to 255."
    },
    {
     "name": "thickness",
     "type": "number?",
     "description": "Optional border thickness. Default: 1.0."
    },
    {
     "name": "priority",
     "type": "number?",
     "description": "Optional draw order. Default: 0."
    }
   ],
   "returns": [],
   "notes": [
    "The filled triangle uses the game polygon primitive."
   ],
   "exampleLua": "Snayl.DrawTriangle(100, 200, 200, 100, 300, 200, false, 255, 255, 255, 255, 2)\nSnayl.DrawTriangle(100, 200, 200, 100, 300, 200, true, 255, 150, 0, 255)\nSnayl.DrawCommit()",
   "category": "draw"
  },
  "Snayl.DrawText": {
   "signature": "Snayl.DrawText(text, x, y, size, r, g, b, a, priority?)",
   "description": "Draws a text string at (x, y); the origin is the top-left of the first glyph.",
   "parameters": [
    {
     "name": "text",
     "type": "string",
     "description": "Text to draw."
    },
    {
     "name": "x",
     "type": "number",
     "description": "Top-left X in pixels."
    },
    {
     "name": "y",
     "type": "number",
     "description": "Top-left Y in pixels."
    },
    {
     "name": "size",
     "type": "number?",
     "description": "Font size in pixels. Default: 16."
    },
    {
     "name": "r",
     "type": "number",
     "description": "Red 0 to 255."
    },
    {
     "name": "g",
     "type": "number",
     "description": "Green 0 to 255."
    },
    {
     "name": "b",
     "type": "number",
     "description": "Blue 0 to 255."
    },
    {
     "name": "a",
     "type": "number",
     "description": "Alpha 0 to 255."
    },
    {
     "name": "priority",
     "type": "number?",
     "description": "Optional draw order. Default: 0."
    }
   ],
   "returns": [],
   "notes": [
    "Uses the game default font (font 0); the size is converted to a scale from the screen height.",
    "nil is drawn as nil."
   ],
   "exampleLua": "Snayl.DrawText('Hello world', 30, 30, 18, 255, 255, 255, 255)\nSnayl.DrawCommit()",
   "category": "draw"
  },
  "Snayl.DrawPushClip": {
   "signature": "Snayl.DrawPushClip(x, y, w, h)",
   "description": "Restricts the coroutine's subsequent drawing commands to the given rectangle. Nested clips intersect, and the clip stays attached to each shape even when priorities reorder the drawing.",
   "parameters": [
    {
     "name": "x",
     "type": "number",
     "description": "Top-left X."
    },
    {
     "name": "y",
     "type": "number",
     "description": "Top-left Y."
    },
    {
     "name": "w",
     "type": "number",
     "description": "Width."
    },
    {
     "name": "h",
     "type": "number",
     "description": "Height."
    }
   ],
   "returns": [],
   "notes": [
    "Pair each push with DrawPopClip before the next DrawCommit.",
    "Up to 16 nested rectangles; further pushes are ignored.",
    "Lines are cut at the clip edge, rectangles are cropped, and text outside the clip is skipped."
   ],
   "exampleLua": "Snayl.DrawPushClip(100, 100, 300, 200)\nSnayl.DrawCircle(120, 120, 80, true, 255, 0, 0, 220)\nSnayl.DrawPopClip()\nSnayl.DrawCommit()",
   "category": "draw"
  },
  "Snayl.DrawPopClip": {
   "signature": "Snayl.DrawPopClip()",
   "description": "Closes the last clipping rectangle of the coroutine. Does nothing when none is active.",
   "parameters": [],
   "returns": [],
   "notes": [],
   "exampleLua": "Snayl.DrawPopClip()",
   "category": "draw"
  },
  "Snayl.DrawCommit": {
   "signature": "Snayl.DrawCommit()",
   "description": "Publishes the coroutine's queued drawing commands and resets its clip stack. The published batch stays visible until that coroutine commits again or the resource clears its drawings.",
   "parameters": [],
   "returns": [],
   "notes": [
    "Snayl.Wait publishes automatically as well.",
    "An empty commit removes the coroutine's previous batch; other coroutines keep theirs.",
    "Up to 4096 commands are retained in total; further commands are ignored."
   ],
   "exampleLua": "Snayl.DrawLine(0, 0, 100, 100, 255, 255, 255, 255)\nSnayl.DrawCommit()",
   "category": "draw"
  },
  "Snayl.DrawClear": {
   "signature": "Snayl.DrawClear()",
   "description": "Clears every queued and displayed drawing of the resource, including its other coroutines. Other resources keep their drawings.",
   "parameters": [],
   "returns": [],
   "notes": [
    "Drawings are also removed when the resource stops, on Panic, and on disconnect.",
    "DrawClear also drops the clip stacks."
   ],
   "exampleLua": "Snayl.CreateThread(function()\n    for i = 1, 300 do\n        Snayl.DrawRect(50, 50, 200, 100, true, 30, 30, 30, 200)\n        Snayl.Wait(0)\n    end\n    Snayl.DrawClear()\nend)",
   "category": "draw"
  }
 },
 "categories": [
  {
   "id": "runtime",
   "name": "Lua Runtime",
   "description": "Run code, target the editor runtime, and restart the environment."
  },
  {
   "id": "resources",
   "name": "Client Resources",
   "description": "Create, destroy, inspect, and inject into client resources."
  },
  {
   "id": "natives",
   "name": "Natives",
   "description": "Call natives by hash, hook them, and remove hooks."
  },
  {
   "id": "http",
   "name": "HTTP",
   "description": "Synchronous GET and POST requests plus bridge diagnostics."
  },
  {
   "id": "input",
   "name": "Input",
   "description": "Keyboard state through Windows virtual-key codes."
  },
  {
   "id": "nui",
   "name": "NUI",
   "description": "Named browser surfaces, focus, visibility, and messages."
  },
  {
   "id": "damage",
   "name": "Damage",
   "description": "Check the damage bridge and trigger client-side damage events."
  },
  {
   "id": "server",
   "name": "Server",
   "description": "Address and endpoint of the connected server."
  },
  {
   "id": "clipboard",
   "name": "Clipboard",
   "description": "Read and write the Windows clipboard."
  },
  {
   "id": "draw",
   "name": "Draw",
   "description": "Screen-space drawing queue, clipping and world-to-screen projection."
  }
 ]
}
