Scooby API Reference — RedM
Documentation
Reference for the Scooby executor surface and the CitizenFX scripting helpers the in-game console exposes. Each entry shows the signature, a short description, and a runnable Lua/JavaScript example.
Scooby Executor
ScoobyShowDui(url, w, h)
Spawn a DUI surface at the given URL. Returns a duiId for the other Scooby* DUI helpers.
Example
local dui = ScoobyShowDui('https://example.com', 1280, 720)
ScoobyHideDui(duiId)
Hide a DUI surface. Keeps it alive — use ScoobyDestroyDui to free.
Example
ScoobyHideDui(dui)
ScoobyShowDuiAgain(duiId)
Re-show a previously hidden DUI surface.
Example
ScoobyShowDuiAgain(dui)
ScoobyDestroyDui(duiId)
Tear down a DUI surface and free its resources.
Example
ScoobyDestroyDui(dui)
ScoobySetDuiUrl(duiId, url)
Navigate the DUI to a new URL.
Example
ScoobySetDuiUrl(dui, 'https://new.url/')
ScoobyExecuteDuiScript(duiId, jsSource)
Run arbitrary JavaScript inside the DUI surface.
Example
ScoobyExecuteDuiScript(dui, 'document.body.style.background="red"')
ScoobyReloadDui(duiId)
Reload the DUI surface's current page.
Example
ScoobyReloadDui(dui)
ScoobySendDuiMessage(duiId, msgTable)
postMessage into the DUI's window.
Example
ScoobySendDuiMessage(dui, { action = 'show' })
ScoobyNotify(title, body, type)
Push a toast through Scooby's notification system. type ∈ Info / Success / Warning / Error.
Example
ScoobyNotify('My Script', 'Hello!', 'Info')
ScoobyLog(line)
Write a line to the Scooby Lua console.
Example
ScoobyLog('Hello from script')
ScoobyGetVersion()
Returns the menu version string.
Example
ScoobyGetVersion()
ScoobyIsKeyDown(vkCode)
Polled keyboard state. Use VK_* codes (0x70 = F1).
Example
if ScoobyIsKeyDown(0x74) then end -- F5
ScoobyOpenMenu()
Force the Scooby menu open from script.
Example
ScoobyOpenMenu()
ScoobyCloseMenu()
Force the Scooby menu closed from script.
Example
ScoobyCloseMenu()
ScoobyToggleMenu()
Toggle the Scooby menu.
Example
ScoobyToggleMenu()
ScoobyIsMenuOpen()
true while the Scooby menu is open.
Example
ScoobyIsMenuOpen()
ScoobyExecuteCode(luaSource)
Run another Lua snippet through the exec pipeline.
Example
ScoobyExecuteCode([[ print('nested') ]])
ScoobyStopResource(name)
Stops a target resource by name (same path as the Uninject button).
Example
ScoobyStopResource('targetResource')
ScoobyInjectInto(name, luaSource)
Run code inside an existing resource's lua_State (true injection, not masquerade).
Example
ScoobyInjectInto('targetResource', [[ print(GetCurrentResourceName()) ]])
ScoobyGetResources()
Table of every currently-running resource name.
Example
for _,n in ipairs(ScoobyGetResources()) do print(n) end
ScoobyHttpGet(url, headers)
Blocking HTTP GET. Returns body string; nil on failure.
Example
local body = ScoobyHttpGet('https://api.example.com/data')
ScoobyHttpPost(url, body, headers)
Blocking HTTP POST.
Example
ScoobyHttpPost('https://api.example.com', '{}', { ['Content-Type'] = 'application/json' })
ScoobyReadFile(path)
Read a file from disk (sandboxed to C:\scooby\redm\lua\).
Example
local s = ScoobyReadFile('mydata.json')
ScoobyWriteFile(path, content)
Write a file (sandboxed).
Example
ScoobyWriteFile('mydata.json', s)
ScoobyFileExists(path)
Returns true if the sandboxed file exists.
Example
ScoobyFileExists('mydata.json')
ScoobyShowImage(path, x, y, w, h)
Render a PNG/JPG overlay. Returns an imgId. Stubbed today — drawing pipeline integration pending.
Example
local img = ScoobyShowImage('logo.png', 100, 100, 256, 256)
ScoobyHideImage(imgId)
Hide a previously-shown image overlay (paired with ScoobyShowImage). No-op while the overlay pipeline is stubbed.
Example
ScoobyHideImage(img)
ScoobyDrawText(text, x, y, size, color)
One-frame text draw. Call every tick to keep on-screen.
Example
ScoobyDrawText('Hello', 200, 200, 16, 0xFFFFFFFF)
ScoobyDrawRect(x, y, w, h, color, filled)
One-frame rectangle.
Example
ScoobyDrawRect(100,100,200,80,0x80FF0000,true)
ScoobyDrawLine(x1, y1, x2, y2, color, thick)
One-frame line.
Example
ScoobyDrawLine(0,0,400,400,0xFFFFFFFF,1.5)
ScoobyDrawCircle(x, y, r, color, segments)
One-frame circle (filled).
Example
ScoobyDrawCircle(300,300,50,0x8000FF00,32)
ScoobyGetScreenSize()
Returns w, h of the current backbuffer.
Example
local w, h = ScoobyGetScreenSize()
ScoobyWorldToScreen(x, y, z)
Returns sx, sy or nil if off-screen.
Example
local sx, sy = ScoobyWorldToScreen(0.0, 0.0, 0.0)
ScoobyGetFps()
Current frames-per-second (smoothed).
Example
ScoobyGetFps()
ScoobyTimeMs()
Monotonic millisecond timestamp.
Example
ScoobyTimeMs()
ScoobyRandom(min, max)
Uniform random integer in [min, max].
Example
ScoobyRandom(1, 100)
ScoobyHash(str)
joaat hash of the input.
Example
ScoobyHash('weapon_pistol')
ScoobyOnTick(fn)
Per-frame callback. Returns a handle for ScoobyOffTick.
Example
local t = ScoobyOnTick(function(dt) end)
ScoobyOffTick(handle)
Detach a tick callback.
Example
ScoobyOffTick(t)
ScoobyOnKey(vk, fn)
Edge-triggered key callback.
Example
ScoobyOnKey(0x74, function() ScoobyNotify('F5','pressed') end)
ScoobyDrawTextOutlined(text, x, y, size, color, outlineColor)
One-frame text with a 1px outline for readability over busy backgrounds. Call every tick.
Example
ScoobyDrawTextOutlined('HP', 200, 200, 16, 0xFFFFFFFF, 0xFF000000)
ScoobyDrawRectGradient(x, y, w, h, colTop, colBottom)
One-frame vertical-gradient rectangle.
Example
ScoobyDrawRectGradient(0,0,200,40,0xFF00D4FF,0x000E1016)
ScoobyMeasureText(text, size) -> (w, h)
Pixel size of a string at the given font size. Free function alias of Scooby.UI.MeasureText.
Example
local w, h = ScoobyMeasureText('Hello', 16)
ScoobyGetAsyncKeyState(vk) -> (down, pressed)
Polled keyboard state — first return is the live level (held), second is the press edge (true on the frame the key goes down).
Example
local down, pressed = ScoobyGetAsyncKeyState(0x74)
if pressed then ScoobyNotify('F5','tapped') end
ScoobyIsAvailable() -> boolean
true once the Scooby script API runtime has finished registering its handlers. Use to gate paste-compatible scripts before calling Scooby.* helpers.
Example
if ScoobyIsAvailable() then ScoobyNotify('hi','ready','Info') end
Scooby.UI.MeasureText(text, size) -> px
Pixel width of a string at the given ImGui font size. Mirrors Susano.GetTextWidth.
Example
local w = Scooby.UI.MeasureText('Hello', 14)
Scooby.UI.BeginFrame()
No-op today — placeholder for the deferred draw queue. Accepted so Susano-style frame lifecycle scripts run silently.
Example
Scooby.UI.BeginFrame()
Scooby.UI.SubmitFrame()
No-op today (pair with BeginFrame).
Example
Scooby.UI.SubmitFrame()
Scooby.UI.ResetFrame()
No-op today (clear the in-flight frame).
Example
Scooby.UI.ResetFrame()
User & Session
Scooby.User.GetId()
Numeric account id of the signed-in user.
Example
local uid = Scooby.User.GetId()
Scooby.User.GetName()
Display name of the signed-in user.
Example
local name = Scooby.User.GetName()
Scooby.User.GetSubscription()
Subscription tier string (e.g. 'lifetime' / 'monthly' / nil).
Example
local tier = Scooby.User.GetSubscription() or 'N/A'
Scooby.User.GetDiscordAccount(type)
Linked Discord id. type ∈ Account (loader-linked) / Game (currently launched).
Example
local d = Scooby.User.GetDiscordAccount('Account')
Scooby.User.GetDefaultLanguage()
ISO 639-1 language string the user picked in the loader.
Example
local lang = Scooby.User.GetDefaultLanguage()
Scooby.Server.GetName()
Current FiveM/RedM server name.
Example
local s = Scooby.Server.GetName()
Scooby.Server.GetCode()
cfx.re join code (e.g. 'xz3vrk').
Example
local c = Scooby.Server.GetCode()
Scooby.Server.GetPlayerCount()
Current player count reported by the server.
Example
local n = Scooby.Server.GetPlayerCount()
Scooby.Client.GetCurrentBranch()
Game client branch / build number string.
Example
local b = Scooby.Client.GetCurrentBranch()
Scooby.Client.AreEventsEnabled()
true when client-side CitizenFX events are flowing (off during disconnect).
Example
if Scooby.Client.AreEventsEnabled() then end
Scooby.System.GetClipboard()
Returns the Windows clipboard as UTF-8 text.
Example
local txt = Scooby.System.GetClipboard()
Scooby.System.SetClipboard(text)
Write a UTF-8 string into the Windows clipboard.
Example
Scooby.System.SetClipboard('hello')
Scooby.System.OpenUrl(url)
Open a URL in the default browser.
Example
Scooby.System.OpenUrl('https://example.com')
Scooby.Input.IsKeyPressed(vk)
Polled keyboard state (level, not edge). Mirrors GetAsyncKeyState.
Example
if Scooby.Input.IsKeyPressed(0x74) then end
Scooby.Input.SetControlMode(mode)
Globally gate input. mode ∈ Keyboard / Mouse / Both / Disabled.
Example
Scooby.Input.SetControlMode('Disabled')
Scooby.UI.LoadFontFromData(bytes, size, ...)
Load a TTF/OTF blob into the menu's font atlas. Returns a font handle.
Example
local f = Scooby.UI.LoadFontFromData(bytes, 16)
Scooby.UI.LoadImageFromData(bytes)
Decode a PNG/JPG blob and return an imageId usable with the Scooby.UI.Draw* helpers.
Example
local img = Scooby.UI.LoadImageFromData(pngBytes)
Memory (RedM-only)
Scooby.Memory.Scan(pattern, moduleName) -> addr
IDA-style byte-pattern scan. Returns the matching address or 0. moduleName defaults to the main game module.
Example
local addr = Scooby.Memory.Scan('48 8B 05 ?? ?? ?? ?? 48 85 C0', 'GTA5.exe')
Scooby.Memory.ModuleBase(name) -> addr
Base address of a loaded module. Pass the exact filename (e.g. 'scooby.dll').
Example
local base = Scooby.Memory.ModuleBase('scooby.dll')
Scooby.Memory.Rip(addr) -> addr
Follow a 32-bit RIP-relative offset at addr. Equivalent to *(int32*)(addr) + addr + 4.
Example
local target = Scooby.Memory.Rip(addr + 3)
Scooby.Memory.Add(addr, offset) -> addr
Pointer arithmetic. Returns addr + offset as a 64-bit integer.
Example
local field = Scooby.Memory.Add(struct, 0x28)
Scooby.Memory.IsValid(addr) -> boolean
True if the address is committed and readable. Always check before a Read* call.
Example
if Scooby.Memory.IsValid(addr) then end
Scooby.Memory.ReadU8(addr) -> int
Read a uint8 from addr.
Example
local b = Scooby.Memory.ReadU8(addr)
Scooby.Memory.ReadU16(addr) -> int
Read a uint16 from addr.
Example
local s = Scooby.Memory.ReadU16(addr)
Scooby.Memory.ReadU32(addr) -> int
Read a uint32 from addr.
Example
local v = Scooby.Memory.ReadU32(addr)
Scooby.Memory.ReadU64(addr) -> int
Read a uint64 from addr. Returned as a Lua integer (Lua 5.4 / LuaJIT cdata).
Example
local v = Scooby.Memory.ReadU64(addr)
Scooby.Memory.ReadF32(addr) -> number
Read an IEEE-754 single from addr.
Example
local f = Scooby.Memory.ReadF32(addr)
Scooby.Memory.ReadF64(addr) -> number
Read an IEEE-754 double from addr.
Example
local d = Scooby.Memory.ReadF64(addr)
Scooby.Memory.ReadString(addr, maxLen) -> string
Read a NUL-terminated UTF-8 string. maxLen caps the scan (defaults to 256).
Example
local s = Scooby.Memory.ReadString(addr, 128)
Scooby.Memory.WriteU8(addr, v)
Write a uint8 to addr.
Example
Scooby.Memory.WriteU8(addr, 0x90)
Scooby.Memory.WriteU16(addr, v)
Write a uint16 to addr.
Example
Scooby.Memory.WriteU16(addr, 0x9090)
Scooby.Memory.WriteU32(addr, v)
Write a uint32 to addr.
Example
Scooby.Memory.WriteU32(addr, 0xDEADBEEF)
Scooby.Memory.WriteU64(addr, v)
Write a uint64 to addr.
Example
Scooby.Memory.WriteU64(addr, 0)
Scooby.Memory.WriteF32(addr, v)
Write an IEEE-754 single to addr.
Example
Scooby.Memory.WriteF32(addr, 1.0)
Scooby.Memory.WriteF64(addr, v)
Write an IEEE-754 double to addr.
Example
Scooby.Memory.WriteF64(addr, 1.0)
Scooby.Memory.Nop(addr, n)
Patch n bytes at addr with 0x90 (x86 NOP). Use to disable an instruction in-place.
Example
Scooby.Memory.Nop(addr, 5)
Scooby.Memory.ResolveExport(dll, symbol) -> addr
GetModuleHandleA + GetProcAddress wrapper. Returns 0 if the module isn't loaded or the symbol is missing — primarily a building block for Lua-side runtime hooks.
Example
local addr = Scooby.Memory.ResolveExport('kernel32.dll', 'GetTickCount')
Camera
Scooby.Camera.Lock(on)
Pin the camera to a script-owned transform. Pass false to release.
Example
Scooby.Camera.Lock(true)
Scooby.Camera.SetPos(x, y, z)
Set the locked camera's world position. Only takes effect while Scooby.Camera.Lock is on.
Example
Scooby.Camera.SetPos(0.0, 0.0, 100.0)
Scooby.Camera.SetRot(x, y, z)
Set the locked camera's rotation (pitch/roll/yaw). Same lifecycle as SetPos.
Example
Scooby.Camera.SetRot(0.0, 0.0, 90.0)
Vehicle
Scooby.Vehicle.SpawnSpoofed(model, x, y, z, h, isNetwork, missionEntity, p7)
Spawn a vehicle with network sync + mission-entity flags set. Streams the model first; returns the handle (or 0 on failure).
Example
local veh = Scooby.Vehicle.SpawnSpoofed('horse_appaloosa', 0.0, 0.0, 70.0, 0.0, true, true, false)
Native UI
Scooby.NativeUI.notify(text, opts) -> void
Push a feed notification (icon dict/tex, title, subtitle, flash). Queues onto the script fiber.
Example
Scooby.NativeUI.notify('Hello!', { title = 'Scooby', subtitle = 'API tour' })
Scooby.NativeUI.subtitle(text, durationMs, useUnderscore) -> void
Show centred subtitle text for durationMs (default 3000).
Example
Scooby.NativeUI.subtitle('Mission ready', 2500, false)
Scooby.NativeUI.help(text, durationMs, beep) -> void
Show the corner help prompt; durationMs=-1 keeps it up until clear_help.
Example
Scooby.NativeUI.help('Press ~INPUT_CONTEXT~ to interact', -1, false)
Scooby.NativeUI.clear_help() -> void
Hide the help prompt now.
Example
Scooby.NativeUI.clear_help()
Scooby.NativeUI.instructional_buttons(rows, owner) -> void
Render a button bar from { {ctlId,'Label'}, ... }. owner is a script-side cleanup tag.
Example
Scooby.NativeUI.instructional_buttons({ { 22, 'Jump' }, { 23, 'Enter' } })
Scooby.NativeUI.blip_add(opts) -> id
Spawn a coord blip. opts: { coord={x,y,z}, sprite, color, scale, short_range, label, owner }.
Example
local b = Scooby.NativeUI.blip_add({ coord = { 0, 0, 75 }, sprite = 1, color = 4, label = 'Spot' })
Scooby.NativeUI.blip_remove(id) -> bool
Remove a blip handle returned by blip_add / blip_attach_entity.
Example
Scooby.NativeUI.blip_remove(b)
Scooby.NativeUI.blip_attach_entity(oldId, entity) -> newId
Replace a coord-blip with one bound to an entity. Returns the new blip handle.
Example
local nb = Scooby.NativeUI.blip_attach_entity(b, PlayerPedId())
Scooby.NativeUI.blip_set_route(id, on) -> bool
Toggle the GPS line to a blip.
Example
Scooby.NativeUI.blip_set_route(b, true)
Scooby.NativeUI.blips_clear(owner) -> bool
Remove every blip tagged with owner (0 = all script blips).
Example
Scooby.NativeUI.blips_clear(0)
Scooby.NativeUI.scaleform.load(name, owner) -> id
REQUEST_SCALEFORM_MOVIE by name. Poll scaleform.handle(id) until non-zero before .call.
Example
local sf = Scooby.NativeUI.scaleform.load('mp_big_message_freemode')
Scooby.NativeUI.scaleform.call(id, method, sig, ...) -> bool
Typed call: sig is per-arg chars i/f/s/b. Up to 8 args.
Example
Scooby.NativeUI.scaleform.call(sf, 'SHOW_SHARD_CENTERED_MP_MESSAGE', 'ss', 'WASTED', '')
Scooby.NativeUI.scaleform.render_fullscreen(id) -> bool
One-frame fullscreen draw. Call every tick while the movie should be visible.
Example
Scooby.NativeUI.scaleform.render_fullscreen(sf)
Scooby.NativeUI.show_mission_passed(text, timeMs) -> void
Play the GTAV-style mission-passed shard.
Example
Scooby.NativeUI.show_mission_passed('JOB COMPLETE', 4000)
Scooby.NativeUI.show_warning_message({ title, prompt, buttons }, cb) -> id
Modal warning panel. cb(buttonIdx) fires when the user picks; idx 0 = timed out.
Example
Scooby.NativeUI.show_warning_message({ title='WARNING', prompt='Continue?', buttons=17 }, function(i) print(i) end)
Scooby.NativeUI.play_sound(name, set, network) -> void
Frontend SFX. Default set 'HUD_FRONTEND_DEFAULT_SOUNDSET'.
Example
Scooby.NativeUI.play_sound('CHECKPOINT_PERFECT', 'HUD_MINI_GAME_SOUNDSET')
Scooby.NativeUI.play_screen_flash(color, ms) -> void
Screen-flash effect. color is the named flash style.
Example
Scooby.NativeUI.play_screen_flash('RedFlash', 600)
Scooby.NativeUI.cleanup_owner(owner) -> void
Free every NativeUI handle (blips, scaleforms, warnings) tagged with owner.
Example
Scooby.NativeUI.cleanup_owner(myScriptId)
Scooby.NativeUI.docs_url(nativeName) -> string
Returns the docs.fivem.net anchor for a native name.
Example
Scooby.NativeUI.docs_url('SET_BLIP_SPRITE')
JSON
Scooby.JSON.Encode(value) -> string
Encode a Lua table to JSON. Routes through dkjson; cycles raise.
Example
local s = Scooby.JSON.Encode({ a = 1, b = { 2, 3 } })
Scooby.JSON.Decode(jsonString) -> table | nil
Decode JSON to a Lua table.
Example
local t = Scooby.JSON.Decode('{"a":1}')
Scooby.JSON.IsValid(s) -> bool
Cheap shallow balance check; true if s looks complete.
Example
if Scooby.JSON.IsValid(body) then end
Scooby.JSON.PrettyEncode(value) -> string
JSON with 2-space indent and sorted keys.
Example
print(Scooby.JSON.PrettyEncode(obj))
HTTP (Binary)
Scooby.HTTP.GetBinary(url, onComplete, headers) -> void
Async HTTP GET that preserves raw bytes. cb(ok, body, status).
Example
Scooby.HTTP.GetBinary('https://example.com/icon.png', function(ok, body, st) end)
Scooby.HTTP.PostBinary(url, body, onComplete, headers) -> void
Async HTTP POST with raw-byte body + response.
Example
Scooby.HTTP.PostBinary(url, raw, function(ok, body, st) end)
Scooby.HTTP.GetBinarySync(url, timeoutMs) -> body | nil
Blocking variant; up to timeoutMs (default 5000).
Example
local bytes = Scooby.HTTP.GetBinarySync('https://example.com/icon.png', 8000)
Native Hooks
ScoobyHookNative(nativeHash64, fn)
Install a global hook on a non-CFX native. Callback receives the same args. Return (false, overrides...) to short-circuit, (true, ...) to chain.
Example
ScoobyHookNative(0x6D0DE6A7B5DA71F8, function(pid)
-- GetPlayerName(pid)
return false, 'scooby'
end)
Scooby.Hook.Add(nativeHash64, argc, fn)
Argc-aware variant. Returns a table whose elements are pushed as the overridden return values.
Example
Scooby.Hook.Add(0x8ACD366038D14505, 5, function()
local ret = {} ret[1] = 0 return ret
end)
ScoobyUnhookNative(nativeHash64)
Remove a previously-installed native hook.
Example
ScoobyUnhookNative(0x6D0DE6A7B5DA71F8)
ScoobyListHooks()
Returns a table of every active hook hash.
Example
for _,h in ipairs(ScoobyListHooks()) do print(string.format('%X', h)) end
Resource Injection
ScoobyInjectResource(resource, code)
Run code inside a target resource's Lua state. Convenience wrapper; equivalent to ScoobyInjectInto.
Example
ScoobyInjectResource('any', [[ print('Hello') ]])
ScoobyInjectResource2(mode, resource, code)
Modal injection. mode: 0 new-thread+helpers, 1 new-thread plain, 2 host-thread+helpers, 3 host-thread plain. Use 3 unless you need the helper table.
Example
ScoobyInjectResource2(3, 'any', [[ print('Hello from existing thread') ]])
ScoobyInjectThread(0, resource, threadName, code)
Inject into a specific thread of the target resource by sub-string match on the thread name. Lets you read thread-local upvalues.
Example
ScoobyInjectThread(0, 'someResource', 'mainThread', [[ print("in mainThread") ]])
ScoobyIsolatedInject(code)
Run code inside the executor's isolated Lua state. The Scooby* helpers are in scope; CFX exports/events are not.
Example
ScoobyIsolatedInject([[ ScoobyNotify('iso', 'hi', 'Info') ]])
ScoobyResourceInjectable(resource)
Returns true if the resource is running and has a Lua runtime we can target.
Example
if ScoobyResourceInjectable('myResource') then end
ScoobyResourceStart(resource)
Start a resource that was previously stopped through Scooby.
Example
ScoobyResourceStart('myResource')
ScoobyResourceRestart(resource)
Stop + start in one call.
Example
ScoobyResourceRestart('myResource')
Layout & Containers
ScoobyMenuBeginColumns(group, nColumns, border) -> handle
Start an ImGui columns layout inside the group. Subsequent widgets flow into column 0 until NextColumn is called. border draws 1px column separators.
Example
ScoobyMenuBeginColumns(g, 2, true)
ScoobyMenuNextColumn(group) -> handle
Advance to the next column. Wraps back to column 0 after the last.
Example
ScoobyMenuNextColumn(g)
ScoobyMenuEndColumns(group) -> handle
Close the column block opened by BeginColumns. Mandatory for every Begin.
Example
ScoobyMenuEndColumns(g)
ScoobyMenuSetColumnWidth(group, colIdx, width) -> handle
Force a fixed pixel width on a specific column. Pass 0 to auto-size.
Example
ScoobyMenuSetColumnWidth(g, 0, 180)
ScoobyMenuSameLine(group, spacing) -> handle
Keep the next widget on the same line as the previous one. spacing = -1 uses the default item spacing.
Example
ScoobyMenuSameLine(g, -1)
ScoobyMenuNewLine(group) -> handle
Force a line break / vertical advance.
Example
ScoobyMenuNewLine(g)
ScoobyMenuIndent(group, amount) -> handle
Push the cursor right by amount pixels. 0 uses the default indent step.
Example
ScoobyMenuIndent(g, 12)
ScoobyMenuUnindent(group, amount) -> handle
Pop a previous Indent. amount should match the value passed to Indent.
Example
ScoobyMenuUnindent(g, 12)
ScoobyMenuSpacing(group) -> handle
Insert vertical whitespace (one item-height gap).
Example
ScoobyMenuSpacing(g)
ScoobyMenuSeparator(group) -> handle
Horizontal 1px separator line.
Example
ScoobyMenuSeparator(g)
ScoobyMenuBeginChild(parent, name, width, height, border) -> handle
Open a scrollable child region. width/height = 0 auto-fits remaining space. border draws a 1px outline.
Example
ScoobyMenuBeginChild(g, 'list', 0, 240, true)
ScoobyMenuEndChild(group) -> handle
Close the child region opened by BeginChild.
Example
ScoobyMenuEndChild(g)
ScoobyMenuBeginPanel(parent, name, width, height) -> handle
Bordered titled panel — like BeginChild but with a built-in title bar (uses name).
Example
ScoobyMenuBeginPanel(g, 'Stats', 0, 0)
ScoobyMenuEndPanel(group) -> handle
Close the panel opened by BeginPanel.
Example
ScoobyMenuEndPanel(g)
ScoobyMenuSetCursorPos(group, x, y) -> handle
Move the layout cursor to (x, y) inside the current region. Useful for absolute placement.
Example
ScoobyMenuSetCursorPos(g, 10, 40)
ScoobyMenuGetCursorPos() -> x, y
Read the current layout cursor. Two-phase: returns x then y. Values are one frame stale (sampled on render thread).
Example
local x, y = ScoobyMenuGetCursorPos()
ScoobyMenuGetContentRegionAvail() -> w, h
Remaining width/height inside the current region. Two-phase getter.
Example
local w, h = ScoobyMenuGetContentRegionAvail()
ScoobyMenuGetItemRect() -> x, y, w, h
Bounding box of the last rendered widget. Four-phase getter (sequential InvokeNative calls).
Example
local x, y, w, h = ScoobyMenuGetItemRect()
Advanced Widgets
ScoobyMenuTreeNode(group, label) -> handle
Collapsible tree node. Children rendered between this call and the matching TreePop are hidden when collapsed.
Example
ScoobyMenuTreeNode(g, 'Advanced')
ScoobyMenuCheckbox(g, 'Flag', function() end, function() end)
ScoobyMenuTreePop(g)
ScoobyMenuTreePop(group) -> handle
Close the tree branch opened by TreeNode.
Example
ScoobyMenuTreePop(g)
ScoobyMenuSelectable(group, label, selected, onToggle) -> handle
Clickable label that paints a highlight when selected is true. onToggle fires on click; manage the selected flag yourself.
Example
ScoobyMenuSelectable(g, 'Item A', state, function() state = not state end)
ScoobyMenuProgressBar(group, fraction, overlay) -> handle
Filled bar; fraction is 0..1. overlay is optional text drawn on top (e.g. '70%').
Example
ScoobyMenuProgressBar(g, 0.42, '42%')
ScoobyMenuListBox(group, label, items, currentIdx, heightItems, onSelect) -> handle
Scrollable list. items is a Lua array of strings; currentIdx is 1-based; heightItems is the visible row count.
Example
ScoobyMenuListBox(g, 'Modes', { 'A', 'B', 'C' }, 1, 4, function(i) end)
ScoobyMenuColorPicker(group, label, r, g, b, a, onChange) -> handle
Inline color swatch. Click opens a hue-wheel popup with alpha bar. onChange fires with (r, g, b, a) as 0..255 ints.
Example
ScoobyMenuColorPicker(g, 'Accent', 230, 60, 60, 255, function(r,g,b,a) end)
ScoobyMenuMultiSlider(group, label, values, minV, maxV, onChange) -> handle
1-4 component float slider. values is a 1..4-element Lua array; rendered count scales with table length.
Example
ScoobyMenuMultiSlider(g, 'XYZ', { 0.0, 0.0, 0.0 }, -100, 100, function(t) end)
ScoobyMenuImage(group, imageHandle, w, h) -> handle
Inline image. imageHandle comes from ScoobyLoadImageFromFile / ScoobyLoadImageFromData.
Example
ScoobyMenuImage(g, logoH, 128, 32)
Style Stack & Tooltips
ScoobyMenuPushStyleColor(group, idx, rgba) -> handle
Push one ImGui color onto the style stack. idx is ImGuiCol_* (e.g. 0 = Text, 21 = Button). rgba is packed 0xAARRGGBB.
Example
ScoobyMenuPushStyleColor(g, 21, 0xFF34A8EB)
ScoobyMenuButton(g, 'Tinted', function() end)
ScoobyMenuPopStyleColor(g, 1)
ScoobyMenuPopStyleColor(group, count) -> handle
Pop count colors off the style stack. count defaults to 1.
Example
ScoobyMenuPopStyleColor(g, 1)
ScoobyMenuPushStyleVar(group, idx, x, y) -> handle
Push one style var. idx is ImGuiStyleVar_*. Scalar vars use x; ImVec2 vars use both x and y.
Example
ScoobyMenuPushStyleVar(g, 14, 8, 8) -- FramePadding
ScoobyMenuPopStyleVar(group, count) -> handle
Pop count style vars. count defaults to 1.
Example
ScoobyMenuPopStyleVar(g, 1)
ScoobyMenuTooltip(text, widget?)
Attach a tooltip to a widget. widget defaults to the most recently created widget handle.
Example
ScoobyMenuButton(g, 'Save', function() end)
ScoobyMenuTooltip('Persist current settings')
ScoobyMenuIsItemHovered(widget?) -> bool
True while the mouse hovers the widget. widget defaults to the last-created handle.
Example
if ScoobyMenuIsItemHovered() then end
ScoobyMenuIsItemClicked(button?, widget?) -> bool
True on the frame the user clicks the widget. button = 0 left, 1 right, 2 middle. widget defaults to last-created.
Example
if ScoobyMenuIsItemClicked(1) then end
Text Utilities
ScoobyMenuTextColored(group, r, g, b, a, text) -> handle
Text run in any RGBA color (0..255 components).
Example
ScoobyMenuTextColored(g, 255, 60, 60, 255, 'Warning')
ScoobyMenuTextWrapped(group, text) -> handle
Soft-wrap long text to the current panel width.
Example
ScoobyMenuTextWrapped(g, 'A long paragraph that wraps to fit the panel.')
ScoobyMenuBulletText(group, text) -> handle
Text prefixed with the ImGui bullet glyph.
Example
ScoobyMenuBulletText(g, 'First point')
Window & UI
ScoobyOverlayWindow(name, x, y, w, h)
Floating overlay window — no title bar, no tab bar, no chrome. HUD-style; survives the main menu toggle.
Example
local hud = ScoobyOverlayWindow('HUD', 20, 20, 240, 100)
ScoobyMenuSetTheme(handle, theme)
Per-window theme override. theme keys: accent, bgColor, headerColor, textColor, buttonColor, toggleOnColor, toggleOffColor — all packed 0xAARRGGBB. Unset keys fall through to global theme.
Example
ScoobyMenuSetTheme(win, { accent = 0xFF34A8EB, bgColor = 0xFF0E0E12 })
ScoobyMenuSetDraggable(handle, bool)
Toggle drag-by-title-bar. Position auto-updates on move.
Example
ScoobyMenuSetDraggable(win, true)
ScoobyMenuSetResizable(handle, bool)
Toggle grip resize. Size constrained to 200x100..1920x1080.
Example
ScoobyMenuSetResizable(win, true)
ScoobyMenuSetBorderless(handle, bool)
Overlay-only: drop the 1px outline + background panel for a fully transparent HUD container.
Example
ScoobyMenuSetBorderless(hud, true)
ScoobyMenuGetPosition(handle)
Returns (x, y) of the window's top-left corner in screen-space.
Example
local x, y = ScoobyMenuGetPosition(win)
ScoobyMenuGetSize(handle)
Returns (w, h) of the window in pixels.
Example
local w, h = ScoobyMenuGetSize(win)
ScoobyMenuIsOpen(handle)
Returns true if the window is currently open.
Example
if ScoobyMenuIsOpen(win) then end
ScoobyMenuSetOpen(handle, bool)
Programmatically open or close a window (e.g. for tutorial scripts).
Example
ScoobyMenuSetOpen(win, false)
ScoobyMenuFocus(handle)
Bring a window to the top of the z-order. Last-Begin'd ImGui window wins.
Example
ScoobyMenuFocus(win)
ScoobyMenuShowDialog(title, message, buttons, cb)
Modal dialog centred on screen. buttons = up to 4 labels; cb(idx) fires with 1-based pick. Blocks input until dismissed.
Example
ScoobyMenuShowDialog('Confirm', 'Spawn this horse?', { 'Yes', 'No' }, function(i) print(i) end)
Image & Theming
ScoobyLoadImageFromFile(path) -> handle
Decode a PNG/JPG/GIF from disk. Cached by path; nil on failure.
Example
local logo = ScoobyLoadImageFromFile('C:/scooby/redm/lua/logo.png')
ScoobyLoadImageFromUrl(url, cb)
Async URL load through ScoobyHttpGet. cb(handle, err) fires on a Citizen thread once decoded.
Example
ScoobyLoadImageFromUrl('https://i.imgur.com/abc.png', function(img, err) if img then ScoobyMenuSetBadge(win, img, 'New') end end)
ScoobyLoadImageFromData(bytes) / ScoobyLoadImageFromData(key, bytes)
Decode raw bytes. One-arg form auto-keys by content; two-arg form lets the caller name the cache key.
Example
local img = ScoobyLoadImageFromData(pngBlob)
ScoobyUnloadImage(handle) -> bool
Drop a cached image and release its GPU texture.
Example
ScoobyUnloadImage(img)
ScoobyImageInfo(handle) -> (w, h, frameCount)
Pixel dimensions + GIF frame count (1 for static).
Example
local w, h, frames = ScoobyImageInfo(img)
ScoobyAdvanceGifFrame(handle) -> frameHandle
Texture handle of the GIF's current frame (wall-clock indexed). Pass into menu setters to animate.
Example
ScoobyMenuSetHeaderImage(win, ScoobyAdvanceGifFrame(gifH), 120)
ScoobyMenuSetHeaderImage(win, handle, height)
Image banner pinned to the top of a window, stretched to window width.
Example
ScoobyMenuSetHeaderImage(win, banner, 120)
ScoobyMenuSetBackgroundImage(win, handle, opacity255)
Stretched background image at the given alpha (0..255).
Example
ScoobyMenuSetBackgroundImage(win, bg, 96)
ScoobyMenuSetBadge(win, handle | 0, label)
Small badge below the header — icon + short text. Pass 0 for image to render text-only.
Example
ScoobyMenuSetBadge(win, icon, 'ADMIN')
ScoobyMenuSetFooter(win, text, version)
Footer strip anchored to window bottom. text on left, version on right.
Example
ScoobyMenuSetFooter(win, 'HACK THE PLANET!', 'V1')
ScoobyMenuToggleWithImage(group, label, imgOff, imgOn, onEnable, onDisable)
Checkbox variant. imgOff renders when off, imgOn when on. Falls back to a dot if images missing.
Example
ScoobyMenuToggleWithImage(g, 'Notifications', offH, onH, function() end, function() end)
ScoobyMenuButtonWithIcon(group, label, handle, onClick)
Button with an 18x18 icon to the left of the label.
Example
ScoobyMenuButtonWithIcon(g, 'Open', folderIcon, function() end)
ScoobyMenuRowWithIcon(group, label, handle, onClick)
Full-width 'menu row' with icon, label, hover background, and chevron. Use for sidebar/list layouts.
Example
ScoobyMenuRowWithIcon(g, 'SELF OPTIONS', iconH, function() end)
Scooby.UI.DrawImage(handle, x, y, w, h, tint)
One-frame image draw onto the foreground draw list. Call every tick to keep on-screen.
Example
Scooby.UI.DrawImage(img, 100, 100, 64, 64, 0xFFFFFFFF)
Scooby.UI.LoadTextureFromBuffer(bytes) -> (handle, w, h)
Decode raw bytes into a texture handle suitable for Scooby.UI.DrawImage. Alternate path that returns dimensions in one call.
Example
local id, w, h = Scooby.UI.LoadTextureFromBuffer(pngBytes)
Logger
ScoobyGetLoggerState()
Returns the logger's current state as an integer.
Example
local s = ScoobyGetLoggerState()
ScoobySetLoggerState(state)
Pause/resume the event logger. Wait a tick before issuing async triggers.
Example
ScoobySetLoggerState(0)
-- do noisy stuff
ScoobySetLoggerState(1)
ScoobyLockLogger(state)
Hard-lock the logger until the cheat is restarted.
Example
ScoobyLockLogger(0)
Auth / HTTP
ScoobyAuthenticationKey()
Returns the current authentication key string.
Example
local k = ScoobyAuthenticationKey()
ScoobyWebRequest(url)
Blocking HTTP GET — returns the response body or nil.
Example
local body = ScoobyWebRequest('https://example.com/keys.txt')
ScoobyOnKeyUp(fn)
Callback fires once on every key release; argument is the VK code.
Example
ScoobyOnKeyUp(function(vk) print('up', vk) end)
ScoobyOnKeyDown(fn)
Callback fires once on every key press; argument is the VK code.
Example
ScoobyOnKeyDown(function(vk) print('down', vk) end)
NUI / DUI (Lua)
SendNUIMessage(table)
Push JSON to the NUI page (window.addEventListener('message')).
Example
SendNUIMessage({ action = 'show' })
RegisterNUICallback(name, fn)
Lua handler for fetch('https://res/name', ...) from the page.
Example
RegisterNUICallback('click', function(data, cb)
cb({ ok = true })
end)
SetNuiFocus(hasFocus, hasCursor)
Hand input from game → page.
Example
SetNuiFocus(true, true)
SetNuiFocusKeepInput(keep)
Keep WASD going to the game while NUI is focused.
Example
SetNuiFocusKeepInput(true)
CreateDui(url, w, h)
Native DUI surface creation. Returns a handle.
Example
local dui = CreateDui('https://example.com', 1280, 720)
DestroyDui(duiObject)
Free a DUI surface.
Example
DestroyDui(dui)
SetDuiUrl(duiObject, url)
Navigate the DUI to a new URL.
Example
SetDuiUrl(dui, 'https://new.url/')
SendDuiMessage(duiObject, jsonStr)
postMessage into the DUI's window.
Example
SendDuiMessage(dui, json.encode({ action = 'show' }))
GetDuiHandle(duiObject)
Returns the txd-style handle the DUI renders to.
Example
GetDuiHandle(dui)
NUI / DUI (JS)
SendNUIMessage(obj)
Push an object to the NUI page from JS. Page receives via window.addEventListener('message').
Example
SendNUIMessage({ action: 'show', payload: 42 });
RegisterNUICallback(name, (data, cb) => {...})
JS handler for fetch('https://res/name', ...) calls from the page.
Example
RegisterNUICallback('click', (data, cb) => {
cb({ ok: true });
});
SetNuiFocus(hasFocus, hasCursor)
Hand input from game → page.
Example
SetNuiFocus(true, true);
const dui = CreateDui(url, w, h)
Native DUI surface creation from JS.
Example
const dui = CreateDui('https://example.com', 1280, 720);
DestroyDui(dui)
Free a DUI surface.
Example
DestroyDui(dui);
SetDuiUrl(dui, url)
Navigate the DUI to a new URL.
Example
SetDuiUrl(dui, 'https://new.url/');
SendDuiMessage(dui, JSON.stringify(obj))
postMessage into the DUI's window.
Example
SendDuiMessage(dui, JSON.stringify({ action: 'show' }));
GetDuiHandle(dui)
Returns the txd-style handle the DUI renders to.
Example
const h = GetDuiHandle(dui);
Scooby.ShowDui(url, w, h) / ScoobyShowDui(...)
Scooby helper exposed under both global Scooby.* and ScoobyXxx free functions from JS.
Example
const dui = ScoobyShowDui('https://example.com', 1280, 720);
ScoobyExecuteDuiScript(duiId, jsSource)
Eval arbitrary JS inside the DUI surface.
Example
ScoobyExecuteDuiScript(dui, "document.body.style.background='red'");
ScoobySendDuiMessage(duiId, obj)
Object → postMessage on the DUI page.
Example
ScoobySendDuiMessage(dui, { action: 'show' });
fetch(`https://${GetParentResourceName()}/cb`, { method:'POST', body:JSON.stringify({}) })
Standard NUI → script callback path. Receiver is RegisterNUICallback.
Example
fetch(`https://${GetParentResourceName()}/myCallback`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ value: 1 })
}).then(r => r.json()).then(data => console.log(data));
window.addEventListener('message', e => {...})
On the page side: receive SendNUIMessage / postMessage payloads.
Example
window.addEventListener('message', (e) => {
if (e.data.action === 'show') {
document.body.style.display = 'block';
}
});
DUI (Screenshot-Proof)
ScoobyCreateDui(url)
Spawn a DUI window at the game's current resolution. Hidden by default — call ScoobyShowDui to display.
Example
local dui = ScoobyCreateDui('https://example.com')
ScoobyCreateDuiSized(url, w, h)
Same as ScoobyCreateDui but with explicit dimensions.
Example
local dui = ScoobyCreateDuiSized('https://example.com', 1280, 720)
ScoobyShowDui(duiHandle)
Display a DUI window.
Example
ScoobyShowDui(dui)
ScoobyHideDui(duiHandle)
Hide a DUI window without freeing it.
Example
ScoobyHideDui(dui)
ScoobyDestroyDui(duiHandle)
Free a DUI surface.
Example
ScoobyDestroyDui(dui)
ScoobySendDuiMessage(duiHandle, jsonString)
postMessage payload into the DUI's window — page receives via window.addEventListener('message').
Example
ScoobySendDuiMessage(dui, '{"action":"show"}')
ScoobyExecuteDuiScript(duiHandle, jsSource)
Eval arbitrary JS inside the DUI surface. Useful when you want the whole UI defined inline.
Example
ScoobyExecuteDuiScript(dui, 'document.body.style.background="red"')
ScoobyReloadDui(duiHandle)
Force the DUI surface to reload its current URL.
Example
ScoobyReloadDui(dui)
NUI / DUI Inject (JS)
ScoobyInjectJavaScript(jsSource)
Eval JS into the global NUI/CEF context. Affects every page the browser is currently rendering.
Example
ScoobyInjectJavaScript([[ console.log('Hello from Scooby') ]])
ScoobyInjectJavaScriptInFrame(frameUrl, jsSource)
Same as ScoobyInjectJavaScript but scoped to frames whose URL contains the substring.
Example
ScoobyInjectJavaScriptInFrame('inventory', [[ document.body.style.opacity=0.5 ]])
ScoobyOnNuiMessage(fn)
Listen to every SendNUIMessage payload going from any resource → its page. fn(resource, jsonString).
Example
ScoobyOnNuiMessage(function(res, payload) print(res, payload) end)
ScoobyOnDuiMessage(fn)
Listen to every SendDuiMessage payload across all DUIs.
Example
ScoobyOnDuiMessage(function(dui, payload) print(payload) end)
Citizen / Threads
Citizen.CreateThread(fn) / CreateThread(fn)
Spawn a green thread. Use Wait() inside to yield.
Example
Citizen.CreateThread(function()
while true do
Wait(0)
-- ...
end
end)
Citizen.Wait(ms) / Wait(ms)
Yield for `ms` milliseconds. Wait(0) = next frame.
Example
Wait(0)
Citizen.InvokeNative(hash, ...)
Direct native call by 0x... hash.
Example
Citizen.InvokeNative(0x00000000, )
Citizen.ResultAsInteger() / Float / String / Vector / Object
Cast InvokeNative return — passed as the last arg.
Example
, Citizen.ResultAsInteger()
SetTimeout(ms, fn)
One-shot delayed call.
Example
SetTimeout(1000, function()
end)
GetGameTimer() -> int
Milliseconds since the game started. Use for cooldowns / timers.
Example
local t0 = GetGameTimer()
-- ...
local elapsed = GetGameTimer() - t0
GetHashKey(str) -> int
joaat hash of a string (models, weapons, anims). Same as `joaat`.
Example
local h = GetHashKey('player_zero')
joaat(str) -> int
Alias for GetHashKey — Jenkins one-at-a-time hash.
Example
local h = joaat('weapon_revolver_cattleman')
GetFrameTime() -> number
Delta time of the last frame in seconds. Multiply per-frame deltas by this.
Example
local speed = 5.0 * GetFrameTime()
GetFrameCount() -> int
Total rendered frame count since startup.
Example
if GetFrameCount() % 30 == 0 then end
while GetGameTimer() < deadline do Wait(0) end
Busy-yield pattern until a deadline. Always Wait inside the loop.
Example
local deadline = GetGameTimer() + 2000
while GetGameTimer() < deadline do Wait(0) end
Citizen.Trace(str)
Write a line to the client console (F8). Cheaper than print for hot loops.
Example
Citizen.Trace('tick\n')
Players & Peds
PlayerId()
Local player id (script-side index).
Example
PlayerId()
PlayerPedId()
Ped handle for the local player.
Example
PlayerPedId()
GetPlayerPed(playerId)
Ped handle for any player by script index.
Example
GetPlayerPed(playerId)
GetPlayerName(playerId)
Display name for any player.
Example
GetPlayerName(playerId)
GetPlayerServerId(playerId)
Server id for any player.
Example
GetPlayerServerId(playerId)
GetPlayerFromServerId(serverId)
Reverse of GetPlayerServerId.
Example
GetPlayerFromServerId(serverId)
GetActivePlayers()
Array of currently-active player script ids.
Example
for _, id in ipairs(GetActivePlayers()) do
end
GetEntityCoords(entity)
Vector3 world position.
Example
GetEntityCoords(entity)
SetEntityCoords(entity, x, y, z, ...)
Teleport an entity.
Example
SetEntityCoords(PlayerPedId(), 0.0, 0.0, 0.0, false, false, false, false)
DoesEntityExist(entity)
Always-check before any other entity native.
Example
DoesEntityExist(entity)
GetEntityHeading(entity)
Compass heading (0-360 degrees) of an entity.
Example
local h = GetEntityHeading(PlayerPedId())
SetEntityHeading(entity, heading)
Rotate an entity to face the given heading.
Example
SetEntityHeading(PlayerPedId(), 90.0)
GetEntityHealth(entity)
Current health. RDR2 peds use a wider range than GTAV (cores).
Example
local hp = GetEntityHealth(PlayerPedId())
SetEntityHealth(entity, value)
Set ped/vehicle health.
Example
SetEntityHealth(PlayerPedId(), 200)
GetDistanceBetweenCoords(x1,y1,z1,x2,y2,z2,useZ)
Euclidean distance between two points.
Example
local d = GetDistanceBetweenCoords(a.x,a.y,a.z, b.x,b.y,b.z, true)
IsPedDeadOrDying(ped, unk)
True if the ped is dead or dying. Pass true for the second arg.
Example
if IsPedDeadOrDying(PlayerPedId(), true) then end
GetVehiclePedIsIn(ped, lastVehicle)
Vehicle/mount handle the ped occupies. 0 if on foot.
Example
local veh = GetVehiclePedIsIn(PlayerPedId(), false)
NetworkGetPlayerIndexFromPed(ped)
Reverse of GetPlayerPed — player index that owns a ped (or -1).
Example
local pid = NetworkGetPlayerIndexFromPed(ped)
IsControlPressed(group, control)
True while a control input is held. group 0 = standard.
Example
if IsControlPressed(0, 0xC1989F95) then end -- ATTACK
Events & Commands
TriggerEvent(name, ...)
Fire a client-side event handler.
Example
TriggerEvent('myEvent', arg1)
TriggerServerEvent(name, ...)
Send an event to the server.
Example
TriggerServerEvent('myEvent', arg1)
RegisterNetEvent(name)
Allow a net-event name to be received from the server.
Example
RegisterNetEvent('myEvent')
AddEventHandler(name, fn)
Subscribe to an event by name.
Example
AddEventHandler('myEvent', function(arg1)
end)
RemoveEventHandler(handle)
Detach a handler returned by AddEventHandler.
Example
RemoveEventHandler(handle)
RegisterCommand(name, fn, restricted)
/cmd handler. Restricted=false for client commands.
Example
RegisterCommand('mycmd', function(src, args, raw)
end, false)
RegisterKeyMapping(cmd, desc, io, key)
Keybind tied to a registered command — polyfilled by exec.
Example
RegisterKeyMapping('+mycmd', 'My binding', 'keyboard', 'F5')
TriggerLatentServerEvent(name, kbps, ...)
Bandwidth-limited variant for large payloads.
Example
TriggerLatentServerEvent('bigEvent', 1024, payload)
TriggerClientEvent(name, target, ...)
Server-side: send a net event to a client (or -1 for all).
Example
-- server side
TriggerClientEvent('myEvent', source, payload)
RegisterNetEvent(name, handler)
Modern form: register + subscribe in one call.
Example
RegisterNetEvent('myEvent', function(arg)
end)
ExecuteCommand(commandString)
Run a console command as if typed (e.g. 'quit', 'connect ...').
Example
ExecuteCommand('say hello')
CancelEvent()
Inside an event handler: cancel propagation. Check WasEventCanceled().
Example
AddEventHandler('weaponDamageEvent', function() CancelEvent() end)
GetInvokingResource() -> string
Resource name that triggered the current event/export. nil if local.
Example
local from = GetInvokingResource()
Resources
GetCurrentResourceName()
Returns this resource's name (post-masquerade if set).
Example
GetCurrentResourceName()
GetResourceState(resourceName)
'missing' / 'started' / 'stopping' / 'starting' / 'stopped'.
Example
GetResourceState('someResource')
GetNumResources()
Count of loaded resources.
Example
GetNumResources()
GetResourceByFindIndex(i)
Iterate all resources by index.
Example
GetResourceByFindIndex(i)
exports.resource:funcName(...)
Call an export defined by another resource.
Example
exports.someResource:someExport()
exports('name', fn)
Define an export this resource provides to others.
Example
exports('GetData', function() return 42 end)
AddTextEntry(key, value)
Register / replace a GXT entry at runtime.
Example
AddTextEntry('MY_KEY', 'My label')
LoadResourceFile(resource, file) -> string
Read a file shipped in a resource. nil if missing.
Example
local cfg = LoadResourceFile(GetCurrentResourceName(), 'config.json')
SaveResourceFile(resource, file, data, len)
Write a file into a resource folder (server-side).
Example
SaveResourceFile(GetCurrentResourceName(), 'data.json', json, -1)
GetResourceMetadata(resource, key, index)
Read a key from the resource manifest (fxmanifest.lua).
Example
local ver = GetResourceMetadata(GetCurrentResourceName(), 'version', 0)
JavaScript
addEventListener('event', fn)
Subscribe to a JS-side CFX event.
Example
addEventListener('myEvent', (...args) => {})
on('event', fn)
Shorthand for addEventListener.
Example
on('myEvent', (...args) => {})
onNet('event', fn)
Subscribe to a net (server-originated) event.
Example
onNet('serverHello', (text) => console.log(text))
emit('event', ...)
TriggerEvent equivalent.
Example
emit('myEvent', arg1)
emitNet('event', ...)
TriggerServerEvent equivalent.
Example
emitNet('myEvent', arg1)
setTick(fn)
JS Citizen.CreateThread — returns a tick id you can clearTick().
Example
const t = setTick(() => {});
clearTick(id)
Stop a setTick.
Example
clearTick(t)
setImmediate(fn)
Run on the next CFX tick (without polling).
Example
setImmediate(() => console.log('next tick'))
Citizen.invokeNative(hashStr, ...args)
Low-level native call. hashStr is the 0x... string of the joaat or 64-bit hash.
Example
Citizen.invokeNative('0xDEAD3001', 'Hello', 'world', 'Success')
await Wait(ms) / await new Promise(r => setTimeout(r, ms))
JS-side coroutine yield. Equivalent to Lua's Wait().
Example
await new Promise(r => setTimeout(r, 100));
GetHashKey(str)
joaat hash, identical across Lua/JS.
Example
GetHashKey('weapon_pistol')
exports.resource.fnName(...)
JS export-import. Same surface as Lua exports.x:y().
Example
exports.someResource.someExport()
global.source
Server-side: numeric source of the player who triggered the event.
Example
onNet('event', () => console.log(global.source))
console.log(...)
Routes to FiveM/RedM client console (F8). Captured by Scooby's NUI tap.
Example
console.log('hello from JS');
JSON.stringify(obj)
Reused for SendDuiMessage / SendNUIMessage payloads.
Example
JSON.stringify({ action: 'show', n: 1 })
ScoobyNotify(title, body, type) -> void
Push a Scooby toast notification.
Example
ScoobyNotify('My Script', 'Hello from JS', 'Success');
ScoobyLog(line) -> void
Write a line to the Scooby Lua console.
Example
ScoobyLog('hello from JS');
ScoobyGetVersion() -> string
Returns the menu version string.
Example
const v = ScoobyGetVersion();
ScoobyHash(str) -> int
Same as GetHashKey, exposed under the Scooby namespace for parity.
Example
const h = ScoobyHash('weapon_pistol');
ScoobyTimeMs() -> int
Monotonic millisecond timestamp.
Example
const t = ScoobyTimeMs();
ScoobyGetFps() -> number
Current frames-per-second (smoothed average).
Example
const fps = ScoobyGetFps();
ScoobyHttpGet(url, headers) -> string|null
Blocking GET — set headers via the standard `Accept: 'application/json'` style key/value object.
Example
const body = ScoobyHttpGet('https://httpbin.org/get');
ScoobyHttpPost(url, body, headers) -> string|null
Blocking POST.
Example
const resp = ScoobyHttpPost('https://api/x', '{}', { 'Content-Type': 'application/json' });
ScoobyOpenMenu() / ScoobyCloseMenu() / ScoobyToggleMenu()
Programmatic menu visibility from JS.
Example
ScoobyToggleMenu();
ScoobyIsMenuOpen() -> boolean
true while the Scooby menu is open.
Example
if (ScoobyIsMenuOpen()) { /* ... */ }
Scooby.System.OpenUrl(url)
Open a URL in the default browser.
Example
Scooby.System.OpenUrl('https://example.com');
Scooby.System.GetClipboard() -> string
Win32 clipboard text.
Example
const txt = Scooby.System.GetClipboard();
Scooby.System.SetClipboard(text)
Write the Windows clipboard.
Example
Scooby.System.SetClipboard('hello');
ScoobyGetResources() -> string[]
Currently-running resource names.
Example
ScoobyGetResources().forEach(r => console.log(r));
ScoobyInjectInto(resource, luaSource) -> boolean
True Lua injection into another resource's state — Lua source as a string, run from JS.
Example
ScoobyInjectInto('any', 'print(GetCurrentResourceName())');
ScoobyStopResource(name) -> boolean
Stop a target resource by name.
Example
ScoobyStopResource('badscript');
ScoobyOnTick(fn) -> handle
JS-side per-frame callback. Cheaper than setTick if you already use Scooby's tick pump.
Example
const t = ScoobyOnTick((dt) => { /* ... */ });
ScoobyOnKey(vk, fn) -> handle
Edge-triggered key callback.
Example
ScoobyOnKey(0x74, () => ScoobyNotify('F5','down'));
ScoobyInjectJavaScript(jsSource)
Eval JS into the global NUI/CEF context.
Example
ScoobyInjectJavaScript("document.title = 'hacked'");
JavaScript — Page
fetch(`https://${GetParentResourceName()}/name`, opts)
Page-side call into the Lua RegisterNUICallback handler. opts.method = 'POST', body = JSON.stringify(...).
Example
fetch(`https://${GetParentResourceName()}/click`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ value: 1 })
})
.then(r => r.json())
.then(resp => console.log(resp));
GetParentResourceName() -> string
Page-side helper that returns the resource the page is mounted under.
Example
const res = GetParentResourceName();
window.addEventListener('message', (e) => {...})
Receive SendNUIMessage / postMessage payloads sent from Lua / JS.
Example
window.addEventListener('message', (e) => {
switch (e.data.action) {
case 'show': showUi(); break;
case 'hide': hideUi(); break;
}
});
const api = (name, body) => fetch(...)
Compact wrapper to avoid repeating the URL boilerplate.
Example
const api = (name, body = {}) =>
fetch(`https://${GetParentResourceName()}/${name}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body)
}).then(r => r.json());
api('click', { value: 1 }).then(r => console.log(r));
const sleep = ms => new Promise(r => setTimeout(r, ms))
Page-side wait. setTimeout works inside CEF.
Example
const sleep = ms => new Promise(r => setTimeout(r, ms));
(async () => {
await sleep(1000);
console.log('one second later');
})();
fetch via NUI callback → ScoobyNotify
Pattern: page calls fetch('https://<res>/notify'); Lua handler calls ScoobyNotify.
Example
// page side:
fetch(`https://${GetParentResourceName()}/notify`, {
method: 'POST',
body: JSON.stringify({ title: 'UI', body: 'Hello' })
});
// Lua side:
RegisterNUICallback('notify', function(data, cb)
ScoobyNotify(data.title, data.body, 'Info')
cb({ ok = true })
end)
fetch then NUI focus
Combine SetNuiFocus + page-side keyboard handlers for a modal UI.
Example
// Lua: SetNuiFocus(true, true)
// Page: window.addEventListener('keydown', (e) => {
// if (e.key === 'Escape') fetch(`https://${GetParentResourceName()}/close`, { method: 'POST' });
// });
Safe Mode
Scooby.SafeMode.IsEnabled() -> bool
Returns true when stealth mode is on (risky features auto-abort, leaky actions blocked).
Example
if Scooby.SafeMode.IsEnabled() then print('safe mode on') end
Scooby.SafeMode.Enable() -> bool
Flip Safe Mode ON. Mirrors the in-menu shield toggle.
Example
Scooby.SafeMode.Enable()
Scooby.SafeMode.Disable() -> bool
Flip Safe Mode OFF. Caller is responsible for any risky-feature fallout.
Example
Scooby.SafeMode.Disable()
Player Scanner
Scooby.PlayerScanner.Start() -> bool
Enable the scanner. Equivalent to pressing the bound key (F7 by default).
Example
Scooby.PlayerScanner.Start()
Scooby.PlayerScanner.Stop() -> bool
Disable the scanner; the menu restores the original coords on the next tick.
Example
Scooby.PlayerScanner.Stop()
Scooby.PlayerScanner.IsActive() -> bool
Returns true if G::playerScannerEnabled is set.
Example
if Scooby.PlayerScanner.IsActive() then end
Scooby.PlayerScanner.GetWaypointName() -> string
Most recent hop label (cached from the C++ sweep loop). Empty when idle.
Example
print(Scooby.PlayerScanner.GetWaypointName())
Scooby.PlayerScanner.GetNearbyCount(radius?) -> int
Count of remote-player peds within `radius` metres of the local ped (default 200m).
Example
local n = Scooby.PlayerScanner.GetNearbyCount(200.0)
Diagnostics
Scooby.Diagnostics.WriteDump() -> bool
Trigger the same diagnostic-dump pipeline as Settings > Diagnostics. Writes crash-YYYYMMDD-HHMMSS.txt.
Example
if Scooby.Diagnostics.WriteDump() then print('dump written') end
Scooby.Diagnostics.OpenFolder() -> bool
ShellExecute the crash log folder (C:\scooby\redm\crash_logs).
Example
Scooby.Diagnostics.OpenFolder()
Profiler
Scooby.Profiler.Snapshot() -> array<{name, last_us, avg_us, max_us, count}>
Atomic snapshot of perf_profiler's per-feature aggregate stats.
Example
for _, r in ipairs(Scooby.Profiler.Snapshot()) do print(r.name, r.last_us, r.avg_us) end
Scooby.Profiler.Reset() -> bool
Clear every per-feature ring buffer.
Example
Scooby.Profiler.Reset()
Config (Export/Import)
Scooby.Config.Export(path) -> bool
Write the live scooby_config.json to `path` with user-specific keys stripped.
Example
Scooby.Config.Export('C:\\scooby\\redm\\exports\\my.json')
Scooby.Config.Import(path) -> bool
Atomically overwrite the live config from `path`, then reload in-memory state.
Example
Scooby.Config.Import('C:\\scooby\\redm\\exports\\my.json')