Skip to content

Conversation

@FileEX
Copy link
Member

@FileEX FileEX commented Nov 13, 2025

Fixed #488

This PR fixes an old bug where holding the crouch key (default: C) causes the ped to stand up after a while, even though the key is still pressed. This behavior prevents the ped from staying crouched and requires manually releasing the key to keep the ped from standing.

image

@FileEX FileEX added the bugfix Solution to a bug of any kind label Nov 13, 2025
@FileEX FileEX requested a review from a team as a code owner January 17, 2026 19:53
@qaisjp
Copy link
Member

qaisjp commented Jan 18, 2026

This behavior prevents the ped from staying crouched and requires manually releasing the key to keep the ped from standing.

Do you mean:

This behavior prevents the ped from standing up and requires manually releasing the key to keep the ped from crouching.

}

// Disable double crouching (another anim cut)
if (ulNow - m_ulLastTimeBeganCrouch < 500 * fSpeedRatio)
Copy link
Member

@qaisjp qaisjp Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

m_ulLastTimeBeganCrouch >= ulNow - 400.0f * fSpeedRatio

is equivalent to

ulNow - m_ulLastTimeBeganCrouch < 500 * fSpeedRatio

But can you explain the change from 400.0f500

Why did you change this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw I think your new code is clearer so you should change line 3115 too

if (m_ulLastTimeBeganCrouch >= ulNow - 400.0f * fSpeedRatio)
{
// Disable double crouching (another anim cut)
if (g_pClientGame->IsUsingAlternatePulseOrder())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really know how alternate pulse order works but it looks like this code was introduced here: cd9473b

According to https://web.archive.org/web/20200809114050/https://bugs.mtasa.com/view.php?id=7250

Description
When the server's configuration parameter <vehext_percent> is greater than zero, then all players can not crouch always

Steps to reproduce

  • Add or set in mtaserver.conf parameter <vehext_percent> to 1-100
  • Start the server and to try crouch

However those repro steps will not work today because the implementation of IsUsingAlternatePulseOrder has changed.

Today, IsUsingAlternatePulseOrder is managed by the latency_reduction setting (default 0).


Please can you confirm that this code does not break crouching when using <latency_reduction>1</latency_reduction>?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am testing this now

Copy link
Member

@qaisjp qaisjp Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your patch? latency_reduction = 0 latency_reduction = 1
Not applied Holding crouch immediately stands up Holding crouch works properly
Applied Holding crouch works properly Holding crouch works properly

Which means that your patch works with any latency_reduction state, great.

But we should also test to make sure we've haven't reintroduced this exploit:

// If we started crouching less than some time ago, make sure we can't jump or sprint.
// This fixes the exploit both locally and remotely that enables players to abort
// the crouching animation and shoot quickly with slow shooting weapons. Also fixes
// the exploit making you able to get crouched without being able to move and shoot
// with infinite ammo for remote players.

Does anyone know how to trigger this exploit?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found info on https://gta.fandom.com/wiki/Desert_Eagle

It is possible to use a bug to make the gun shoot faster by doing this: Aim, fire, release both fire and aim, click the crouch button, and repeat. This bug also works via the "free aim" option in the controls menu. Choosing this, the player can rapidly tap the fire button over and over, making the weapon fire far faster. This applies to the other pistols as well.

I can't test this right now but someone should test to make sure we haven't unintentionally restored that exploit

@qaisjp qaisjp force-pushed the bugfix/crouching-state branch from 95a1bb5 to 194a2e8 Compare January 18, 2026 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Solution to a bug of any kind

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't make ped crouch

2 participants