- Basics
- Introduction
- Lua
- Native Hooking
- Resource Injection
- Graphics Programming
- Misc
- Macho DUI
- JavaScript
- NUI/DUI UI Injection
Native Hooking
Macho provides a set of APIs for hooking natives globally in the game. CitizenFX natives cannot be hooked but all regular game natives can be. Macho's isolated environment will not call into these hooks but resources will call directly into this.
MachoHookNative([integer] hash, [function] callback) -> void
This will hook a native given the 64-bit hash (not JOAAT hash). You provide a callback with the same arguments and choose to return the call to the original caller, or skip it. The callback should return a boolean, followed by the original return values. The boolean will indicate whether we should skip calling the original, if you return false we will not call the original, if you return true we will call the next lua hook until there are no more and then we will call the original (unless another lua hook returns false).
--
-- Install our GetPlayerName hook.
--
MachoHookNative(0x6D0DE6A7B5DA71F8, function (player_id)
--
-- This will execute isolated so that you don't risk getting flagged.
-- Print who called this hook, and print our real name, then give them a false name.
--
print(GetCurrentResourceName() .. "tried to get our real name: " .. GetPlayerName(player_id))
--
-- Set our name to "macho-man", and don't call the original.
--
return false, "macho-man"
end)
--
-- Test this actually worked:
--
MachoInjectResource("any", [[
--
-- What's our name?
--
print(GetPlayerName(PlayerId()))
]])