Appearance
Hook
Reference for the hook API.
Functions
hook.native
Hooks a script native.
lua
---@param event menu.event
---@param script string|integer
---@param options { pre: function(native_invoke), post: function(native_invoke) }
function hook.native(native_hash, script, options): native_hookhook.script
Hooks a script function.
lua
---@param script string|integer
---@param position integer
---@param options { pre: function(params, params_size, returns, returns_size), post: function(returns, returns_size) }
function hook.script(script, position, options): script_hookTypes
native_hook
| Field | Type |
|---|---|
enabled | bool |
script_hook
| Field | Type |
|---|---|
enabled | bool |
Constants
event
lua
hook.scripts.continue
hook.scripts.blockExamples
lua
function pre_hook_stat_set_int(context)
local script_name = invoker.call(0x442E0A7EDE4A738A).str -- get_this_script_name
print('setting stat ' .. tostring(context.params[0].int32) .. ' to ' .. tostring(context.params[1].int32) .. ' in ' .. script_name)
return hook.scripts.continue
end
function post_hook_stat_set_int(context)
print('set stat result: ' .. tostring(context.bool))
context.bool = true -- force it to always think it succeeded
end
function pre_network_request_cash_transaction(params, params_size, returns, returns_size)
local transaction_type = params[1].int32
local action_slot = params[2].int32
local category = params[3].int32
local service = params[4].int32
local cost = params[5].int32
print('NETWORK_REQUEST_CASH_TRANSACTION: type=' .. tostring(transaction_type) .. ' slot=' .. tostring(action_slot) .. ' category=' .. tostring(category) .. ' service=' .. tostring(service) .. ' cost=' ..tostring(cost))
return hook.scripts.continue
end
hook.script('freemode', 0xBEFF4, { pre=pre_network_request_cash_transaction })
-- empty script hash hooks every script
hook.native(0xB3271D7AB655B441, 0, { pre=pre_hook_stat_set_int, post=post_hook_stat_set_int })