Volt

oth.is_hook_thread

Returns true if the current thread is a hook thread.

Syntax

oth.is_hook_thread() -> boolean

Returns

TypeDescription
booleanTrue if running in a hook thread, false otherwise

Description

oth.is_hook_thread checks whether the current code is executing within a hook thread created by oth.hook. This allows you to detect hook context and behave differently.

Example

local originalPrint = oth.hook(print, function(...)
    if oth.is_hook_thread() then
        print("[HOOK THREAD]", ...)
    else
        print("[MAIN THREAD]", ...)
    end
    return originalPrint(...)
end)

print("Test") -- Output: [HOOK THREAD] Test

Conditional Behavior

local originalFunc = oth.hook(someCFunction, function(...)
    if oth.is_hook_thread() then
        -- Running in hook thread
        print("Hook context detected")
        -- Do hook-specific logic
    end
    return originalFunc(...)
end)

Notes

  • Returns true only when executing within a hook created by oth.hook
  • Returns false on the main thread or in other contexts
  • Useful for implementing hook-specific behavior

On this page