Can't seem to get bhop to work while crouching

Posts 114 of 14 · Page 1 of 1
Can't seem to get bhop to work while crouching
Right, so i'm reading if the player is on the ground, if they are, force a jump. Pretty basic, standard bhop hack. It's external in C#. However, if I'm crouching, it doesn't work at all, and If I have it check if the player is just not in the air, so it should, in theory, work while they're crouching on the ground, it's delayed. Like it takes a second or so to bhop after landing.

Here's what the code for it looks like.

Code:
if (GetAsyncKeyState(0x20) != 0)
{
    byte onGround = ReadByte(LP + mFlags);
    if (onGround != 0)
    {
	WriteInt(Client + oForceJump, 5);
        Thread.Sleep(100);
	WriteInt(Client + oForceJump, 4);
    }
}
'ReadByte' and 'WriteInt' are methods I wrote, didn't think it was really necessary to post them, since it's just RPM and WPM.
I believe when reading the player's on ground, if they're crouching it returns a different value than if they're standing. Try looking into that, if I'm not mistaken that should be right.
Quote Originally Posted by Buttars0070 View Post
I believe when reading the player's on ground, if they're crouching it returns a different value than if they're standing. Try looking into that, if I'm not mistaken that should be right.
I think if you read it as Byte it should be 0 in ground and in air 1.
Quote Originally Posted by DarknzNet View Post


I think if you read it as Byte it should be 0 in ground and in air 1.
I still believe it is different for crouching. It always has been but I am not sure what you can do with reading a byte.

Maybe if you just read the integer instead and get the different flags?
Quote Originally Posted by OhStarQ View Post
I still believe it is different for crouching. It always has been but I am not sure what you can do with reading a byte.

Maybe if you just read the integer instead and get the different flags?
Yes it is different.
Those states are saved as bitflags, which means that each bit is representing a certain state.

For instance, the least significant bit is indicating if the entity is on the ground. 0000000000000001.

You can see a full list of those states here: https://github.com/pmrowla/hl2sdk-cs...c/const.h#L105

m_fFlags is defined as an int which contains 32 bits, each one of those represent a state. Since they are bitflags, they can also be combined. You could be ducking ( 1 << 1 ) and on the ground ( 1 << 0 ) at the same time, which would result in 0000000000000011. If you would read the flags as an integer, you would get the result of 3, while if you're only on the ground, you would get 1. That's why you bitmask the result of m_fFlags to get the state of a specific bit.

m_fFlags & 1 // 1 << 0

You can read m_fFlags as a BYTE since we are not interested in all of those other states.

Now, if you only check for the result not being 0, it could also jump when you are crouching, even though you are not on the ground.

Use bitflags to get the result you want.
Quote Originally Posted by WasserEsser View Post
m_fFlags & 1 // 1 << 0

You can read m_fFlags as a BYTE since we are not interested in all of those other states.

Now, if you only check for the result not being 0, it could also jump when you are crouching, even though you are not on the ground.

Use bitflags to get the result you want.
hmm. So would I do something like this?

Code:
const int whatever = 0x011;


if (GetAsyncKeyState(0x20)
{
    byte crouching = ReadByte(LP + whatever);
    if (crouching == 77) // not sure why this is 77, but when i have it output the value when crouching, that's what it says.
    {
        WriteInt(client + oForceJump, 5);
        Thread.Sleep(5);
        WriteInt(client + oForceJump, 4);
    }
}
or more like this?

Code:
const int mflags = 0x100;
const int whatever = mflags & 1;

if (GetAsyncKeyState(0x20))
{
    byte crouching = ReadByte(LP + whatever);
    if (crouching == 192) // This one shows up as 192.
    {
        WriteInt(Client + oForceJump, 5);
        Thread.Sleep(5);
        WriteInt(Client + oForceJump, 4);
    }
}

Edit:

Actually, could I just do this?

Code:
if (GetAsyncKeyState(0x20) != 0)
{
    byte onGround = ReadByte(LP + mFlags);
    if (onGround == 1 || onGround == 7)
    {
	WriteInt(Client + oForceJump, 5);
        Thread.Sleep(100);
	WriteInt(Client + oForceJump, 4);
    }
}
The 'onGround' variable seems to output 7 when I'm crouching.
Quote Originally Posted by sumfuknrando View Post
hmm. So would I do something like this?

Code:
const int whatever = 0x011;


if (GetAsyncKeyState(0x20)
{
    byte crouching = ReadByte(LP + whatever);
    if (crouching == 77) // not sure why this is 77, but when i have it output the value when crouching, that's what it says.
    {
        WriteInt(client + oForceJump, 5);
        Thread.Sleep(5);
        WriteInt(client + oForceJump, 4);
    }
}
or more like this?

Code:
const int mflags = 0x100;
const int whatever = mflags & 1;

if (GetAsyncKeyState(0x20))
{
    byte crouching = ReadByte(LP + whatever);
    if (crouching == 192) // This one shows up as 192.
    {
        WriteInt(Client + oForceJump, 5);
        Thread.Sleep(5);
        WriteInt(Client + oForceJump, 4);
    }
}

Edit:

Actually, could I just do this?

Code:
if (GetAsyncKeyState(0x20) != 0)
{
    byte onGround = ReadByte(LP + mFlags);
    if (onGround == 1 || onGround == 7)
    {
	WriteInt(Client + oForceJump, 5);
        Thread.Sleep(100);
	WriteInt(Client + oForceJump, 4);
    }
}
The 'onGround' variable seems to output 7 when I'm crouching.

Code:
if (GetAsyncKeyState(0x20) & 1 << 15)
{
    byte onGround = ReadByte(LP + mFlags);
    if (onGround & 1)
    {
	WriteInt(Client + oForceJump, 6);
    }
}
Quote Originally Posted by WasserEsser View Post
if (GetAsyncKeyState(0x20) & 1 << 15)
{
byte onGround = ReadByte(LP + mFlags);
if (onGround & 1)
{
WriteInt(Client + oForceJump, 6);
}
}
I get "Cannot implicitly convert type 'int' to 'bool'" on the if statements. what values am i supposed to be checking for?

Edit: ok so I just checked for onGround & 1 to be 1 and that works. Why the 6 instead of 5 or 4 though? TBH, I never really figured out what those meant. And what is the 'onGround & 1' actually doing?

Forgive my noobiness, just trying to understand it a bit more.
Quote Originally Posted by sumfuknrando View Post
I get "Cannot implicitly convert type 'int' to 'bool'" on the if statements. what values am i supposed to be checking for?

Edit: ok so I just checked for onGround & 1 to be 1 and that works. Why the 6 instead of 5 or 4 though? TBH, I never really figured out what those meant. And what is the 'onGround & 1' actually doing?

Forgive my noobiness, just trying to understand it a bit more.
When you write a 5 to the jump offset, that sends a +jump, 4 = -jump. If you opened cs go, and hooked cheat engine, located the jump offset, and wrote a 5 to it, you would jump, then, to be able to jump again, you would have to -jump, 4. Well, when you bind your mwheel to +jump, what the game does is, it uses 6, so, when you write a 6 to the jump offset, it will +jump and -jump instantly so you dont have to write 5/4. I explained that horribly, sorry, im tired.
Quote Originally Posted by sumfuknrando View Post
Why the 6 instead of 5 or 4 though?
As nexcat already said, it will jump once.

"Cannot implicitly convert type 'int' to 'bool'"
Looks like C# is a really dumb language.

Edit: ok so I just checked for onGround & 1 to be 1 and that works.
Do you mean
Code:
onGround & 1 == 1
?

And what is the 'onGround & 1' actually doing?
It is bitmasking the result. As said before, flags are bits, each bit is representing a number. Since a char / byte is the smallest addressable unit and you cannot "just get that one bit", you have to bitmask the result. Let's say you are currently crouching and on the ground. m_fFlags will be 3 if you read it as an integer. In bits it will be 0000000000000011. The 1 on the very right is the one that indicates if the player is on the ground, the one next to it if he is crouching. If you only want to know if he is on the ground, you can bitmask it.

0000000000000011 // Value of m_fFlags
0000000000000001 & // 1
0000000000000001 // Result

A bitwise AND ( & ) will result flip a bit in the result to 1 if both of the values provided are 1. I'm bad at explaining this, you might want to look it up.
For instance, you want to compare the following:

0000010010000010
1000110001000011 &
0000010000000010 // Result

Both, the one at the top aswell as the one in the middle have to be 1 in order to result in 1.

This way you can query individual bits out of the m_fFlags variable in order to get as much information as possible.
Quote Originally Posted by WasserEsser View Post
I'm bad at explaining this, you might want to look it up.
This actually helped a lot, thanks.
Quote Originally Posted by nexcat View Post
When you write a 5 to the jump offset, that sends a +jump, 4 = -jump. If you opened cs go, and hooked cheat engine, located the jump offset, and wrote a 5 to it, you would jump, then, to be able to jump again, you would have to -jump, 4. Well, when you bind your mwheel to +jump, what the game does is, it uses 6, so, when you write a 6 to the jump offset, it will +jump and -jump instantly so you dont have to write 5/4. I explained that horribly, sorry, im tired.
Ok, I see, thanks. Explanation was fine
/Solved & closed.
Posts 114 of 14 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?