Why simple spacebar spam fails in CS2 sub-tick:
CS2 samples movement flags at sub-tick precision. If you jump on the wrong sub-tick slice, the ground friction (sv_friction 5.2) decelerates the pawn instantly.
Optimal Jump Logic:
void AutoBunnyhop(CUserCmd* pCmd, C_CSPlayerPawn* pLocal) {
uint32_t flags = pLocal->m_fFlags();
Vector3 vel = pLocal->m_vecVelocity();
float horizontalSpeed = sqrt(vel.x * vel.x + vel.y * vel.y);
// FL_ONGROUND is bit 0 (0x1)
bool bOnGround = (flags & (1 << 0)) != 0;
if (bOnGround && pCmd->buttons.has_flag(IN_JUMP)) {
pCmd->buttons.set_flag(IN_JUMP);
} else {
pCmd->buttons.unset_flag(IN_JUMP);
}
}