Automatically adjusts aim speed based on how far the target is from center — slower when close, faster when far.
Complete reference for the AimSync Lua scripting engine. Write custom scripts to control aim behavior, input, recoil, detection filtering, and more — all streamed live from the webmenu.
Lua scripts give you full programmatic control over AimSync's behavior. Scripts are written in Lua 5.4 and executed inside the AimSync hardware client.
Use the Lua Script Editor in the webmenu (Lua tab). Write or paste your code in the editor.
Click "Stream to AimSync". The script is sent to the server as a pending payload. Within ~2 seconds, the AimSync client picks it up and loads it live.
Your script's global code runs once on load. Then your callback functions (like on_tick, on_pre_aim, on_frame) are called automatically every frame or event.
The Lua engine runs inside the same process as AimSync. Scripts have direct access to all internal systems via bound API tables.
All functions are organized into tables (namespaces). Call them as table.function().
Read and write webmenu configuration values. Most weapon-specific functions accept an optional weapon parameter (1–8); defaults to the current weapon.
| Function | Parameters | Returns | Description |
|---|---|---|---|
get_aimbot_enabled() | — | boolean | Whether aimbot is enabled |
get_confidence() | — | integer | Confidence slider value (0–100) |
get_current_weapon() | — | integer | Active weapon preset (1–8) |
get_fov_x([weapon]) | opt int | integer | Horizontal FOV in pixels |
get_fov_y([weapon]) | opt int | integer | Vertical FOV in pixels |
get_smoothing_x1([weapon]) | opt int | number | Smoothing X for aimkey 1 |
get_smoothing_y1([weapon]) | opt int | number | Smoothing Y for aimkey 1 |
get_smoothing_x2([weapon]) | opt int | number | Smoothing X for aimkey 2 |
get_smoothing_y2([weapon]) | opt int | number | Smoothing Y for aimkey 2 |
get_acceleration_x1([weapon]) | opt int | number | Acceleration X for aimkey 1 |
get_acceleration_y1([weapon]) | opt int | number | Acceleration Y for aimkey 1 |
get_acceleration_x2([weapon]) | opt int | number | Acceleration X for aimkey 2 |
get_acceleration_y2([weapon]) | opt int | number | Acceleration Y for aimkey 2 |
get_aimbot_key([weapon]) | opt int | integer | Virtual key code for aimkey 1 |
get_aimbot_key2([weapon]) | opt int | integer | Virtual key code for aimkey 2 |
get_aimbot_mode([weapon]) | opt int | integer | Aim mode for aimkey 1 |
get_aimbot_mode2([weapon]) | opt int | integer | Aim mode for aimkey 2 |
get_aim_stop_key([weapon]) | opt int | integer | Key code for aim stop |
get_recoil_enabled() | — | boolean | Whether recoil control is on |
get_recoil_x([weapon]) | opt int | number | Recoil X compensation value |
get_recoil_y([weapon]) | opt int | number | Recoil Y compensation value |
get_recoil_multiplier([weapon]) | opt int | integer | Recoil pattern multiplier |
get_triggerbot_enabled() | — | boolean | Whether triggerbot is enabled |
get_triggerbot_key() | — | integer | Triggerbot activation key |
get_triggerbot_first_delay_min() | — | integer | First shot delay minimum (ms) |
get_triggerbot_first_delay_max() | — | integer | First shot delay maximum (ms) |
get_triggerbot_next_delay_min() | — | integer | Follow-up shot delay min (ms) |
get_triggerbot_next_delay_max() | — | integer | Follow-up shot delay max (ms) |
get_triggerbot_positions() | — | string | Triggerbot target positions |
get_video_mode() | — | string | "capture_card" or "udp" |
get_capture_device() | — | string | Capture device name / ID |
Write config values. Changes are applied immediately and synced to the webmenu. Weapon-specific setters default to the current weapon if weapon is omitted.
| Function | Parameters | Returns | Description |
|---|---|---|---|
set_aimbot_enabled(val) | req boolean | — | Enable or disable aimbot |
set_confidence(val) | req integer | — | Set confidence slider value (0–100) |
set_current_weapon(val) | req integer | — | Set active weapon preset (1–8) |
set_recoil_enabled(val) | req boolean | — | Enable or disable recoil control |
set_triggerbot_enabled(val) | req boolean | — | Enable or disable triggerbot |
set_video_mode(val) | req string | — | Set video mode: "capture_card" or "udp" |
set_capture_device(val) | req string | — | Set capture device name / ID |
set_triggerbot_key(val) | req integer | — | Set triggerbot activation key |
set_triggerbot_first_delay_min(val) | req integer | — | Set first shot delay minimum (ms) |
set_triggerbot_first_delay_max(val) | req integer | — | Set first shot delay maximum (ms) |
set_triggerbot_next_delay_min(val) | req integer | — | Set follow-up shot delay min (ms) |
set_triggerbot_next_delay_max(val) | req integer | — | Set follow-up shot delay max (ms) |
set_triggerbot_positions(val) | req string | — | Set triggerbot target positions |
set_recoil_key(val) | req integer | — | Set recoil activation key |
set_recoil_stop_mode(val) | req integer | — | Set recoil stop mode |
set_fov_x([weapon,] val) | opt int, req int | — | Set horizontal FOV in pixels |
set_fov_y([weapon,] val) | opt int, req int | — | Set vertical FOV in pixels |
set_smoothing_x1([weapon,] val) | opt int, req number | — | Set smoothing X for aimkey 1 |
set_smoothing_y1([weapon,] val) | opt int, req number | — | Set smoothing Y for aimkey 1 |
set_smoothing_x2([weapon,] val) | opt int, req number | — | Set smoothing X for aimkey 2 |
set_smoothing_y2([weapon,] val) | opt int, req number | — | Set smoothing Y for aimkey 2 |
set_acceleration_x1([weapon,] val) | opt int, req number | — | Set acceleration X for aimkey 1 |
set_acceleration_y1([weapon,] val) | opt int, req number | — | Set acceleration Y for aimkey 1 |
set_acceleration_x2([weapon,] val) | opt int, req number | — | Set acceleration X for aimkey 2 |
set_acceleration_y2([weapon,] val) | opt int, req number | — | Set acceleration Y for aimkey 2 |
set_aimbot_key([weapon,] val) | opt int, req int | — | Set virtual key code for aimkey 1 |
set_aimbot_key2([weapon,] val) | opt int, req int | — | Set virtual key code for aimkey 2 |
set_aim_stop_key([weapon,] val) | opt int, req int | — | Set key code for aim stop |
set_aim_stop_mode([weapon,] val) | opt int, req int | — | Set aim stop mode |
set_aimbot_mode([weapon,] val) | opt int, req int | — | Set aim mode for aimkey 1 |
set_aimbot_mode2([weapon,] val) | opt int, req int | — | Set aim mode for aimkey 2 |
set_recoil_x([weapon,] val) | opt int, req number | — | Set recoil X compensation value |
set_recoil_y([weapon,] val) | opt int, req number | — | Set recoil Y compensation value |
Control the PID controllers used for aim smoothing. Axis parameter: "x", "y", or "both".
| Function | Parameters | Returns | Description |
|---|---|---|---|
set_kp(axis, value) | req string, number | — | Set proportional gain |
set_ki(axis, value) | req string, number | — | Set integral gain |
set_kd(axis, value) | req string, number | — | Set derivative gain |
set_max_output(axis, value) | req string, number | — | Clamp maximum PID output |
set_integral_limit(axis, value) | req string, number | — | Limit integral accumulation |
set_filter_alpha(axis, value) | req string, number | — | Derivative low-pass filter (0–1) |
set_derivative_on_measurement(axis, bool) | req string, boolean | — | Use D-on-measurement vs D-on-error |
get_kp(axis) | req string | number | Current Kp value |
get_ki(axis) | req string | number | Current Ki value |
get_kd(axis) | req string | number | Current Kd value |
get_max_output(axis) | req string | number | Current max output |
get_integral_limit(axis) | req string | number | Current integral limit |
reset(axis) | req string | — | Reset integral accumulator |
Direct hardware mouse control via the Makcu device. Button is an integer 0–4 matching MouseButton: LEFT = 0, RIGHT = 1, MIDDLE = 2, SIDE1 = 3, SIDE2 = 4.
| Function | Parameters | Returns | Description |
|---|---|---|---|
move(dx, dy) | req int, int | — | Move mouse by relative delta |
down(button) | req int | — | Press and hold a mouse button |
up(button) | req int | — | Release a mouse button |
click(button [, holdMs]) | req int, opt int | — | Click (press + delay + release). Default hold: 30ms |
is_pressed(button) | req int | boolean | Check if button is currently held |
Control the recoil compensation system.
| Function | Parameters | Returns | Description |
|---|---|---|---|
start() | — | — | Begin recoil compensation pattern |
stop() | — | — | Stop recoil compensation |
is_active() | — | boolean | Whether pattern is currently playing |
is_finished() | — | boolean | Whether pattern has completed |
set_fire_rate(rpm) | req int | — | Set fire rate in rounds per minute |
set_micro_steps(n) | req int | — | Interpolation steps between points |
set_screen_scale(scale) | req number | — | Scale factor for screen resolution |
set_step_interval(ms) | req int | — | Set interval between recoil steps (ms) |
load_pattern(steps [, scaleX [, scaleY]]) | req table, opt number, opt number | integer | Load a recoil pattern from a Lua table. Each entry is {dx=N, dy=N} or {N, N}. Returns step count. |
clear_pattern() | — | — | Clear the loaded recoil pattern |
get_step_count() | — | integer | Number of steps in the loaded pattern |
get_current_step() | — | integer | Index of the currently executing step |
Read screen and capture dimensions.
| Function | Returns | Description |
|---|---|---|
width() | number | Monitor screen width |
height() | number | Monitor screen height |
capture_width() | integer | Capture card resolution width |
capture_height() | integer | Capture card resolution height |
Override aim behavior at runtime. These overrides persist until changed or until a new script is loaded (which resets them).
| Function | Parameters | Description |
|---|---|---|
set_enabled(bool|nil) | req boolean or nil | Force aimbot on/off. Pass nil to restore webmenu setting. |
set_delta_scale(scaleX, scaleY) | req number, number | Multiply aim deltas by these factors (1.0 = normal) |
set_target_override(x, y) | req number, number | Force aim target to specific screen coordinates |
clear_target_override() | — | Remove target override, return to normal targeting |
Filter which detections the aimbot processes.
| Function | Parameters | Description |
|---|---|---|
set_min_confidence(value|nil) | req number or nil | Override minimum confidence threshold (0.0–1.0). Pass nil to use webmenu value. |
filter_class(classId|nil) | req int or nil | Only aim at a specific class ID. Pass nil to disable filter. |
Query information about the currently loaded ONNX model.
| Function | Returns | Description |
|---|---|---|
get_name() | string | Full path of the loaded model file |
get_width() | integer | Model input width (e.g., 640) |
get_height() | integer | Model input height (e.g., 640) |
get_class_count() | integer | Number of detection classes |
get_class_names() | table | Array of class name strings (1-indexed) |
Extended math utilities. Named math2 to avoid shadowing Lua's built-in math library.
| Function | Parameters | Returns | Description |
|---|---|---|---|
distance(x1, y1, x2, y2) | req number ×4 | number | Euclidean distance between two points |
lerp(a, b, t) | req number ×3 | number | Linear interpolation: a + t*(b-a) |
clamp(value, min, max) | req number ×3 | number | Clamp value to [min, max] range |
Immediate-mode drawing API. Call these from on_frame or on_tick to render custom overlays on the detection preview window. Commands are rendered once per frame — call them every frame to persist.
| Function | Parameters | Returns | Description |
|---|---|---|---|
text(x, y, text [, r, g, b [, fontSize [, thickness]]]) | req num, num, string, opt int ×3, num, int | — | Draw text on the detection preview. Default: white, 0.5 scale, 1px. |
rect(x, y, w, h [, r, g, b [, thickness]]) | req num ×4, opt int ×3, int | — | Draw rectangle outline. Default: green, 2px. |
filled_rect(x, y, w, h [, r, g, b [, alpha]]) | req num ×4, opt int ×3, num | — | Draw filled rectangle. alpha 0.0–1.0 for transparency. |
circle(x, y, radius [, r, g, b [, thickness]]) | req num ×3, opt int ×3, int | — | Draw circle outline. Default: green, 2px. |
filled_circle(x, y, radius [, r, g, b]) | req num ×3, opt int ×3 | — | Draw filled circle. |
line(x1, y1, x2, y2 [, r, g, b [, thickness]]) | req num ×4, opt int ×3, int | — | Draw line segment. Default: green, 2px. |
clear() | — | — | Manually clear all pending draw commands. |
Colors use RGB values (0–255). If omitted, defaults are: text = white (255,255,255), shapes = green (0,255,0).
Available at the top level — no table prefix needed.
| Function | Parameters | Returns | Description |
|---|---|---|---|
log(message) | req string | — | Write message to AimSync log file (prefixed [Lua]) |
print(...) | any values | — | Print to console (overrides default Lua print) |
sleep(ms) | req int | — | Sleep for up to 5000ms. Caution: blocks the calling thread. |
time() | — | number | High-resolution monotonic time in seconds (steady_clock) |
get_tick_count() | — | integer | Milliseconds since system boot (GetTickCount64) |
Define these functions in your script and they will be called automatically by the engine. All callbacks are optional — only define the ones you need.
Called before aim movement is applied. Receives a context table and can return modified deltas.
| Field | Type | Description |
|---|---|---|
delta_x | number | Calculated horizontal aim delta |
delta_y | number | Calculated vertical aim delta |
target_x | number | Target screen X coordinate |
target_y | number | Target screen Y coordinate |
center_x | number | Screen center X |
center_y | number | Screen center Y |
Return a table with delta_x and delta_y to override the aim deltas. Return nil to use default behavior.
Called after aim movement is sent to the device. Useful for logging or analytics.
| Parameter | Type | Description |
|---|---|---|
movedX | number | Actual horizontal pixels moved |
movedY | number | Actual vertical pixels moved |
Called every frame with all current detections. Receives a Lua array of detection tables.
| Field | Type | Description |
|---|---|---|
x | number | Bounding box X position |
y | number | Bounding box Y position |
width | number | Bounding box width |
height | number | Bounding box height |
class_id | integer | Detection class index |
confidence | number | Detection confidence (0.0–1.0) |
label | string | Human-readable class name |
Called when the triggerbot evaluates whether to fire. Return true/false to override, or nil to use default logic.
| Parameter | Type | Description |
|---|---|---|
inCrosshair | boolean | Whether a target is in the crosshair zone |
Called once per main loop iteration — ideal for continuous input checks, state machines, or per-frame logic.
Called every time the config polling thread refreshes settings from the webmenu (approximately every 2 seconds). Use it to react to config changes dynamically.
Ready-to-use scripts you can paste into the webmenu Lua editor.
Automatically adjusts aim speed based on how far the target is from center — slower when close, faster when far.
Automatically adjusts PID gains when the weapon preset changes.
Locks detection to head-only (class 0) with a higher confidence threshold.
Counts total detections per class and logs stats periodically.
A complete script combining per-weapon PID tuning, distance-based aim scaling, ADS-only triggerbot, recoil control, detection logging, and auto-start recoil on fire.
| Limit | Value | Details |
|---|---|---|
| Instruction Limit | 1,000,000 | Maximum VM instructions per hook call. Prevents infinite loops from freezing AimSync. |
| Sleep Maximum | 5000 ms | sleep() is capped at 5 seconds. Values outside 1–5000 are ignored. |
| Script Reload | Automatic | Loading a new script resets all overrides (aim, detection, delta scale, target) to defaults. |
| Thread Safety | Recursive mutex | All Lua calls are guarded by a recursive mutex. Callbacks run on different threads (main loop, aim worker, config thread) but never concurrently. |
| Error Handling | Protected calls | All callbacks use lua_pcall. Errors are printed and logged — they never crash AimSync. |