Injection & Execution¶
Run code in contexts other than the injected console — the FiveM isolated runtime, another resource's environment, or a resource's NUI.
All of these take code as a string
code is Lua (or, for InjectJS, JavaScript) passed as
a string, usually via a [[ long bracket ]]. It runs in the target context,
so your outer script's locals are not available inside it.
Asterion.Isolated¶
Runs code inside the FiveM isolated Lua runtime — the same environment as
your own resource. Use it when natives must run in a real Citizen thread rather
than the injected context.
| Argument | Type | Description |
|---|---|---|
code |
string |
Lua source to run in the isolated runtime. |
Example¶
Asterion.InjectResource¶
Injects Lua code into the running resource name through its scripting
environment. The code shares the resource's global table, so it can read and
write existing globals and call the resource's functions.
| Argument | Type | Description |
|---|---|---|
name |
string |
The target resource name. |
code |
string |
Lua source to run inside it. |
Example¶
Asterion.InjectResource2¶
Like InjectResource, but a safer, stealthier variant.
| Argument | Type | Description |
|---|---|---|
name |
string |
The target resource name. |
code |
string |
Lua source to run inside the resource. |
Example¶
Asterion.InjectThread¶
Injects code as a new Citizen thread inside resource, attributed to
file (used for stack traces / identification).
| Argument | Type | Description |
|---|---|---|
resource |
string |
The target resource name. |
file |
string |
A filename the thread is attributed to (e.g. "client.lua"). |
code |
string |
Lua source to run as the new thread. |
Example¶
Asterion.HijackResource¶
Replaces the next execution tick of resource with code. Runs with the
resource's full environment and permissions.
| Argument | Type | Description |
|---|---|---|
resource |
string |
The target resource name. |
code |
string |
Lua source to run in place of the next tick. |
Example¶
One-shot
HijackResource only affects the next tick. For something that must run
continuously, use InjectThread or wrap it in an
Asterion.Thread.
Asterion.InjectJS¶
Executes JavaScript code in the NUI context of resource.
| Argument | Type | Description |
|---|---|---|
resource |
string |
The resource whose NUI frame to target. |
code |
string |
JavaScript source to run in the NUI. |