Source Code [CSGO | Internal] Autostrafe

  • CSGO recently moved logic from 'client_panorama.dll' to 'client.dll', you must update all code that uses 'client_panorama.dll' and replace it with 'client.dll' or the code will not work.
Hexui Undetected CSGO Cheats PUBG Accounts

KF1337

*copies code from tutorials, then breaks it.*
Dank Tier Donator
Full Member
Nobleman
Jan 30, 2020
158
3,603
0
Tutorial Link
N/A
How long you been coding/hacking?
since early 2019
Coding Language
C++
Requirements:
- hooking CreateMove
- know what your UserCMD is for.


What is autostrafe?
Strafing in CSGO means pressing your left/right key when you are moving your mouse in-air. This gives you extra movement speed.
We are going to automate "pressing" your keys by manipulating the UserCMD accordingly.


Inside your CreateMove hook:
C++:
bool __stdcall hooks::hkCreateMove(float flInputSampleTime, UserCMD* cmd)
{
    if (IsOnGround) // check if FL_ONGROUND is set..
        return;

    if ((GetAsyncKeyState(VK_SPACE) & 0x8000))
    {
        if (cmd->mousedeltaX > 0)
            cmd->sidemove = 450.0f; // strafe right

        if (cmd->mousedeltaX < 0)
            cmd->sidemove = -450.0f; // strafe left
    }

    return oCreateMove(flInputSampleTime, cmd);
}
TODO:
- combine this with a nice Bhop hack
- be phoon
 
  • Like
  • Love
Reactions: SPQR, Rake and obdr

Kekz

Maybe Pasting
Meme Tier VIP
Trump Tier Donator
Dank Tier Donator
Jan 10, 2020
221
6,703
29
Small suggestions:
Inside your UserCMD struct there is an attribute called buttons which is a bit field where each flag represents one "button" (1 => button is pressed).
So instead of
C++:
if ((GetAsyncKeyState(VK_SPACE) & 0x8000))
which would only work if the player has jump bound to spacebar, you can do:
C++:
if (cmd->buttons & IN_JUMP)
C++:
enum buttonFlags
{
    IN_ATTACK = (1 << 0),
    IN_JUMP = (1 << 1),
    IN_DUCK = (1 << 2),
    IN_FORWARD = (1 << 3),
    IN_BACK = (1 << 4),
    IN_USE = (1 << 5),
    IN_CANCEL = (1 << 6),
    IN_LEFT = (1 << 7),
    IN_RIGHT = (1 << 8),
    IN_MOVELEFT = (1 << 9),
    IN_MOVERIGHT = (1 << 10),
    IN_ATTACK2 = (1 << 11),
    IN_RUN = (1 << 12),
    IN_RELOAD = (1 << 13),
    IN_ALT1 = (1 << 14),
    IN_ALT2 = (1 << 15),
    IN_SCORE = (1 << 16),
    IN_SPEED = (1 << 17),
    IN_WALK = (1 << 18),
    IN_ZOOM = (1 << 19),
    IN_WEAPON1 = (1 << 20),
    IN_WEAPON2 = (1 << 21),
    IN_BULLRUSH = (1 << 22),
    IN_GRENADE1 = (1 << 23),
    IN_GRENADE2 = (1 << 24),
    IN_ATTACK3 = (1 << 25),
};

You'll probably also want to add a check for your movetype, in order to not strafe when on a ladder / noclipping.
Hint: Look at hazedumper's netvar m_MoveType, it is also a bit field.
C++:
// Taken from Valve's SDK, don't have a link anymore
enum MoveTypes : uint8_t
{
    MOVETYPE_NONE = 0,
    // never moves
    MOVETYPE_ISOMETRIC,
    // For players -- in TF2 commander view, etc.
    MOVETYPE_WALK,
    // player only - moving on the ground
    MOVETYPE_STEP,
    // gravity, special edge handling -- monsters use this
    MOVETYPE_FLY,
    // No gravity, but still collides with stuff
    MOVETYPE_FLYGRAVITY,
    // flies through the air + is affected by gravity
    MOVETYPE_VPHYSICS,
    // uses VPHYSICS for simulation
    MOVETYPE_PUSH,
    // no clip to world, push and crush
    MOVETYPE_NOCLIP,
    // No gravity, no collisions, still do velocity/avelocity
    MOVETYPE_LADDER,
    // Used by players only when going onto a ladder
    MOVETYPE_OBSERVER,
    // Observer movement, depends on player's observer mode
    MOVETYPE_CUSTOM,
    // Allows the entity to describe its own physics
    MOVETYPE_LAST = MOVETYPE_CUSTOM,
    // should always be defined as the last item in the list
    MOVETYPE_MAX_BITS = 4
};
 
Last edited:

KF1337

*copies code from tutorials, then breaks it.*
Dank Tier Donator
Full Member
Nobleman
Jan 30, 2020
158
3,603
0
Yeah that is the better approach of course. I just wanted to point out the code that lets you autostrafe.

In an actual hack, one definitely should check for all the things you mentioned.
 

SPQR

Trump Tier Donator
Dank Tier Donator
Full Member
Apr 6, 2020
31
928
0
Thank you for this. Just made my bhop a bit better.

Curious though, do you know how 450 was arrived at as the optimal value? I'm reading that anything higher will lead to untrusted, but haven't found how it was arrived at yet.
 

KF1337

*copies code from tutorials, then breaks it.*
Dank Tier Donator
Full Member
Nobleman
Jan 30, 2020
158
3,603
0
Thank you for this. Just made my bhop a bit better.

Curious though, do you know how 450 was arrived at as the optimal value? I'm reading that anything higher will lead to untrusted, but haven't found how it was arrived at yet.
I opened the address of the UserCMD in reclass and looked at the values when running. Simple as that
 
  • Like
Reactions: SPQR and Rake

bigtasty

Dank Tier Donator
Dec 31, 2018
36
738
3
Curious though, do you know how 450 was arrived at as the optimal value?
It is the default value of cl_sidespeed, which would be more "proper" to use here as
C++:
cmd->sidemove = cmd->mousedeltaX > 0 ? sidespeed->getFloat() : -sidespeed->getFloat()
 
  • Like
Reactions: SPQR
Community Mods