Resource Injection
Kazo.InjectResource
Executes Lua code inside a target resource's environment.
Syntax
Kazo.InjectResource(mode, resource_name, lua_code)Parameters
modenumber (optional)0 = new thread (default), 1 = existing threadresource_namestringTarget resource, or "any" for randomlua_codestringLua source to executeReturns
nilnilThis function does not return a value.Notes
Mode 0: creates a new Citizen thread and runs your code inside it.
Mode 1: injects into an already running thread. No new thread is created.
Examples
New thread inside spawnmanager
Kazo.InjectResource(0, "spawnmanager", [[
print("running in a fresh thread")
]])Existing thread inside es_extended
Kazo.InjectResource(1, "es_extended", [[
print("running inside an existing thread")
]])Random resource
Kazo.InjectResource(0, "any", [[
print(GetCurrentResourceName())
]])Register a custom command
Kazo.InjectResource(0, "es_extended", [[
RegisterCommand("mycommand", function(source, args, rawCommand)
print("Command executed by: " .. source)
print("Arguments: " .. table.concat(args, ", "))
end, false)
]])