utils
The utils namespace contains engine utilities, system inputs, raycast tracers, and low-level reverse engineering helpers.
Engine & Input Utilities
Section titled “Engine & Input Utilities”| Function | Parameters | Returns | Description |
|---|---|---|---|
utils.console_exec |
command: string |
nil |
Executes a console command in the engine. |
utils.is_key_pressed |
vk: number |
boolean |
Checks if a Windows Virtual Key code is held down. |
utils.get_mouse_position |
(none) | vector |
Cursor position relative to the game viewport. |
utils.random_seed |
seed: number |
nil |
Seeds the engine RNG (used by bullet spread calculations). |
utils.random_int |
min: number, max: number |
number |
Returns a pseudo-random integer between [min, max]. |
utils.random_float |
min: number, max: number |
number |
Returns a pseudo-random float between [min, max]. |
utils.set_clantag |
text: string |
nil |
Sets the player’s clantag string. |
utils.get_net_channel |
(none) | net_channel_info_t | nil |
Returns active engine net channel info. |
utils.get_model_index |
path: string |
number |
Looks up model index for a .mdl path. |
utils.precache_model |
path: string |
boolean |
Precaches a model so it can be set on entities. |
utils.create_interface |
module: string, name: string |
number |
Retrieves interface pointer address (0 on fail). |
utils.pattern_scan |
module: string, pattern: string |
number |
Scans module for IDA-style byte pattern (0 on fail). |
utils.send_voice_message |
data: voice_data |
nil |
Transmits custom raw voice packet data. |
utils.crc32 |
data: string |
number |
Computes CRC32 checksum. |
utils.get_weapon_data |
index: number |
weapon_data_t | nil |
Looks up weapon data by item definition ID. |
utils.extract_archive |
path: string, dest: string |
boolean |
Decompresses zip/tar archive via Windows tar. |
World Tracing & Raycasting
Section titled “World Tracing & Raycasting”utils.trace_line
Section titled “utils.trace_line”local trace = utils.trace_line(from: vector, to: vector, mask: number, filter?: entity_t | function) --> trace_tTraces a ray through world geometry and hitboxes.
mask: Collision mask bitflags (e.g.MASK_SHOT = 0x4600400B).filter: An entity instance to ignore, or a predicate function(entity) -> booleanreturningtrueif the entity should be hit.
utils.trace_hull
Section titled “utils.trace_hull”local trace = utils.trace_hull(from: vector, to: vector, mins: vector, maxs: vector, mask: number, filter?: entity_t | function) --> trace_tTraces an axis-aligned bounding box (AABB) between two points.
utils.trace_bullet
Section titled “utils.trace_bullet”local bullet = utils.trace_bullet(attacker: player_t, from: vector, to: vector, target?: player_t) --> fire_bullet_tExecutes Aimsense’s autowall penetration solver from from to to.
- Returns
fire_bullet_t. bullet.damageis-1if the bullet cannot reach the destination.
local local_player = entity.get_local_player()if local_player and enemy then local eye_pos = local_player:get_eye_position() local target_pos = enemy:get_hitbox_position(0) -- Head hitbox
local shot = utils.trace_bullet(local_player, eye_pos, target_pos, enemy) if shot.damage > 0 then print(string.format("Penetration viable! Estimated Damage: %d", shot.damage)) endend