CS2 AK-47 Anti-Recoil Training Scripts
A console-only AK-47 recoil compensation script for local servers: how sleep and exec_async work, why it needs 125 FPS and sv_cheats 1, and how to run it
The AK-47 spray pattern is one of the most studied things in CS2, and still nobody controls it perfectly in a real match. Movement, distance, stress and plain human reaction make every spray a bit different, even for good players.
This guide is about an AK-47 anti-recoil training script made only with console commands, for local or private servers. No third-party software. It shows how recoil compensation works when the pattern is known in advance and the timing is fixed. It's for training and analysis, not for real matches, and it only runs with sv_cheats 1 anyway.
What the CS2 AK-47 Anti-Recoil Script Does
The script uses two config files to replay a ready-made AK-47 recoil compensation. It doesn't touch game code, doesn't read memory and doesn't change how the weapon works. Everything is done with normal console commands and the way Source 2 runs config files.
The idea is simple. The AK-47 recoil pattern is the same every time, so it can be countered with camera movements calculated in advance. The script doesn't react to anything, it just plays a list of small corrections, one for each bullet, on a fixed schedule. You see what clean recoil control looks like without the human part: no reaction delay, no shaky hand, no uneven pull.
Timing is everything here. A correction only works if it lands at the right moment, in sync with the rate of fire. A little too early or too late and the pattern falls apart. That's why the script needs a stable frame rate and controlled conditions, and why it produces the same spray every time.
Watch how the camera should move during a full spray and compare it to your own pull.
See near-ideal recoil control on a local server and how CS2 handles timing and input.
It compensates recoil, not random spread. The script can't predict spread, so the spray is very tight, but not perfect.
How It Works: From wait to sleep, From exec to exec_async
Any script like this is built on two things: command automation and timing. The setup has two files, the main script ak47.cfg and loop.cfg, which runs on a timer in the background. To see why this works in CS2, look at how wait and exec changed over time.
Delay: wait vs sleep
In Counter-Strike 1.6 wait was the base of all scripting. It pauses for exactly one frame, so the engine has time to process each command separately. Without it, several actions on one line don't register properly and often only the first one works.
The problem: in CS 1.6 a frame lasts as long as your FPS allows. At 100 FPS one wait is about 10 ms, at 20 FPS about 50 ms. Same script, completely different timing on every PC. CS:GO disabled wait on official servers, and CS2 doesn't have it at all.
CS2 has sleep instead, inside configs run with exec_async. It counts milliseconds, not frames, so it doesn't stretch five times at low FPS like wait did. But it's not fully independent of FPS either: the console checks it once per frame, so the real pause is rounded up to whole frames. At 125 FPS sleep 10 takes noticeably longer than 10 ms. This is the reason the script locks FPS, more below.
Execution: exec vs exec_async
A normal exec reads a config top to bottom and runs everything at once. A config doesn't "live" over time, it fires in one burst. A big file (1,000+ lines) can cause a visible hitch until it's done, and a loop through exec simply freezes the game, because nothing can interrupt it. The main thread is fully busy with the script.
exec_async works differently. Its own description in the game is "Execute a cfg file over time": the config runs step by step alongside the game, without blocking the main loop. Even files with tens of thousands of lines run without freezes or FPS loss. With sleep inside, the console turns into a real automation tool that can keep a long loop going.
| Command | Behavior | In CS2 |
|---|---|---|
wait |
Pauses for one frame | Doesn't exist |
sleep |
Pauses for X ms, rounded to frames | Inside exec_async configs |
exec |
Runs the whole file at once | Works everywhere |
exec_async |
Runs the file over time, in the background | Only with sv_cheats 1 |
Why exec_async Only Works With sv_cheats 1
Commands like exec_async are powerful automation, same as wait used to be, so the game marks it as a cheat command. When it was new it worked without cheats, then Valve patched it to stop working with sv_cheats 0. That's why this script is only for local games, private servers and testing where cheats are on.
AK-47 Script Breakdown: ak47.cfg and loop.cfg
Here is a shortened ak47.cfg. It looks scary at first, but the logic is easy once you see how the aliases connect.
fps_max 125; sv_cheats 1; exec_async loop; alias "your_sens" "sensitivity 2.6" alias "+shot" "alias fp fp0; sensitivity 1.0; +attack" alias "-shot" "alias fp; -attack; your_sens" alias "trigger" "ON" alias "ON" "bind mouse1 +shot; alias trigger OFF; play weapons\auto_semiauto_switch_01" alias "OFF" "bind mouse1 +attack; alias trigger ON; play weapons\auto_semiauto_switch_02" bind "c" "trigger" alias fp; alias fp0 "pitch 0.000000 1 0; yaw 0.000000 1 0; alias fp fp1" alias fp1 "pitch 0.000000 1 0; yaw 0.000000 1 0; alias fp fp2" alias fp2 "pitch 10.940682 1 0; yaw -5.654227 1 0; alias fp fp3" alias fp3 "pitch 0.000000 1 0; yaw 0.000000 1 0; alias fp fp4" // fp4 ... fp124
- First line
- Locks FPS at 125, turns on sv_cheats and starts loop.cfg in the background with exec_async.
- your_sens
- Your normal sensitivity. Put your own value here. While firing, sensitivity is forced to 1.0 so the corrections are exact, on release your value comes back.
- C key
- A toggle. ON binds mouse1 to +shot (scripted firing), OFF back to normal +attack. The two switch sounds tell you which mode is on.
- fp0 ... fp124
-
The compensation steps. Each one moves the camera with
pitch(vertical) andyaw(horizontal), then pointsfpto the next step. Most steps are zero, a real correction comes every 3 to 5 steps, one per bullet.
loop.cfg is just one long list that calls fp again and again with a pause between:
sleep 10 fp sleep 10 fp // ... about 69,000 times
While you don't shoot, fp is empty and nothing happens. Press mouse1 and +shot points fp to fp0, so the loop starts walking through the steps in sync with the spray.
Why 11.5 Minutes?
Source 2 doesn't load a config bigger than 1 MB. loop.cfg is right at that limit: about 138,000 lines, 68,918 sleep 10 steps, which is 11.5 minutes on paper (in practice a bit longer, because each step takes more than 10 ms). You can make it run longer by chaining files, for example with exec_async loop2 at the end, for 23 minutes or more.
Why 125 FPS?
This is calculated, not random. At 125 FPS one frame is exactly 8 ms. The AK-47 fires 600 rounds per minute, one shot every 100 ms (cycle time 0.1 in the game files).
Since sleep is rounded up to whole frames, at 125 FPS each sleep 10 + fp step takes about 24 ms. You can see it in the script itself: the real corrections sit every 3 to 5 steps, about 4.2 steps per bullet, which is exactly 100 ms. The whole table of pitch and yaw values is built for this rhythm. At 124 or 126 FPS, or with an unlocked fps_max 0, the steps drift away from the shots and the aim starts to jitter. And if your PC can't hold a stable 125 FPS, the script won't work properly at all.
How to Run the AK-47 Script in CS2
- Download and extract AK47 Anti-Recoil scripts.rar . Inside are ak47.cfg and loop.cfg .
- Open ak47.cfg in Notepad and put your own sensitivity into the your_sens alias.
-
Copy both files into the CS2 cfg folder:
...\steamapps\common\Counter-Strike Global Offensive\game\csgo\cfg\
- Start CS2 and stay in the main menu. The script has to run before you load a map, so the binds and the loop start correctly.
-
Open the console and type:
exec ak47
- Start a local game with bots or join your own server with cheats on. Press C to switch to scripted firing, press it again to go back to normal.
If you want it to load every time, add +exec ak47 to your launch options or exec ak47 to your autoexec.cfg. I'd still keep it separate and run it only when you train.
If config files are new to you, read these first: CS2 config guide (how to create and run cfg files) and CS2 config location (which folder is which).
Conclusion
The AK-47 anti-recoil script is a technical experiment and a training reference, not a shortcut to winning. It shows what near-perfect recoil compensation looks like when the pattern is known in advance and every correction comes with mechanical timing. It also shows the limits of automation: it can't handle spread, it falls apart without a stable 125 FPS, and it only runs with cheats on. On a local or private server it's a good way to understand how Source 2 handles recoil, timing and input, and to see what your own spray should look like.
The timing idea comes from the experiments in the cs2-movement-issues repository by zer0k-z on GitHub.
AK-47 Anti-Recoil Script FAQ
Does this script work in matchmaking?
No. exec_async needs sv_cheats 1, and official servers don't allow it. The script is only for local games, private servers and training.
Can this script get me banned?
On official servers it simply doesn't run: sv_cheats is forced to 0 and exec_async stops working. On a local server with cheats on it's not a cheat by itself. But the author of the original script warns that people have been VAC banned in the past for spamming pitch and yaw to snap angles, which falsely triggered the anticheat. To be safe, start CS2 with -insecure: VAC is off completely and you can't join secured servers.
Why is timing so important?
AK-47 recoil is tied to its fire rate, one shot every 100 ms. If the corrections don't land with the shots, the pattern breaks. A few ms early or late is enough.
Why 125 FPS and not more?
sleep is rounded to whole frames, and the correction table is built for 8 ms frames. At any other FPS the steps drift away from the shots.
Why is sensitivity forced to 1.0 while firing?
A fixed value makes every correction the same size. Your normal sensitivity comes back when you release the button.
Why isn't the spray perfect?
The script compensates recoil, which is always the same, but not random spread. Real cheats that manipulate spread do something completely different.
Can I make it for other weapons?
Yes, but it's not copy and paste. Each gun has its own pattern and fire rate, so you need a new table of pitch and yaw steps. The M4A4, for example, fires every 90 ms instead of 100, so the corrections come about every 3.75 steps instead of 4.2.
What is the real value of this script?
Learning. It shows what near-perfect recoil control looks like, so you understand the pattern and the timing and can work on your own spray.

