Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Complicated bunny hopping and air strafing script for CS:GO - different way of strafing script (mouse movement ---> press button)


  • Please log in to reply
16 replies to this topic
kelisbest
  • Members
  • 8 posts
  • Last active: Feb 09 2015 04:14 PM
  • Joined: 08 Feb 2015

Hello,

I know that there are a lot of similar questions. I want to have a script that bunny hops for me and helps me to do air strafing in CS:GO. I want to bunny hop while pressing space. The problem is that I want to be able to airstrafe at the same time using also the space bar. I don't know if it is possible to it with the same key because for bunny hopping it has to be spammed and for strafing held. It should look like this:

 

hold SpaceBar                                                     --->  spam SpaceBar: bunny hopping

hold SpaceBar + mouse movement to the right   --->   hold D + mouse movement to the right: strafe right  

hold SpaceBar + mouse movement to the left     --->   hold A + mouse movement to the left: strafe left

 

I hope this is possible if not it is also good if it works with seperate keys. Thank you ahead!

Best regards



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

This might be a bit tricky... I don't know how mouse coordinates are reported when playing CSGo (or any shooter in general)

 

But your general premise might be this:

 

$Space::
While GetKeyState("Space","P") ; While you hold down the Space bar Physically
{
MouseGetPos, X_f, Y_f
Sleep 40
MouseGetPos, X_s, Y_s
If (X_s > X_f)
{
Send {a up} ; If a was being held down, release it
Send {d down}
}
else if (X_s < X_f)
{
Send {d up} ; if d was being held down, release it
Send {a down}
}
else
{
Send {d up}
Send {a up}
Send {Space}
}
}
return

 

The potential problem in this approach is that you might not be moving the mouse in those 40ms intervals... And it also means that any mouse movement to the left or right which you may not intend to do can cause you to air strafe rather than bunny hop. We can address that issue somewhat by doing this if ((x_s - x_f) > 10) would mean If the second coordinate is more than 10 pixels greater than the first coordinate, then we have moved the mouse more than 10 pixels to the right. (This will go with the {a up}{d down}.

 

That reminds me, technically all of those Send lines can go in the same line for each block of code (Which can remove the squiggly brackets to shorten the code). But I wrote it like that just for the sake of clarity and to add my comments in there.



kelisbest
  • Members
  • 8 posts
  • Last active: Feb 09 2015 04:14 PM
  • Joined: 08 Feb 2015

This might be a bit tricky... I don't know how mouse coordinates are reported when playing CSGo (or any shooter in general)

 

But your general premise might be this:

$Space::
While GetKeyState("Space","P") ; While you hold down the Space bar Physically
{
MouseGetPos, X_f, Y_f
Sleep 40
MouseGetPos, X_s, Y_s
If (X_s > X_f)
{
Send {a up} ; If a was being held down, release it
Send {d down}
}
else if (X_s < X_f)
{
Send {d up} ; if d was being held down, release it
Send {a down}
}
else
{
Send {d up}
Send {a up}
Send {Space}
}
}
return

The potential problem in this approach is that you might not be moving the mouse in those 40ms intervals... And it also means that any mouse movement to the left or right which you may not intend to do can cause you to air strafe rather than bunny hop. We can address that issue somewhat by doing this if ((x_s - x_f) > 10) would mean If the second coordinate is more than 10 pixels greater than the first coordinate, then we have moved the mouse more than 10 pixels to the right. (This will go with the {a up}{d down}.

 

That reminds me, technically all of those Send lines can go in the same line for each block of code (Which can remove the squiggly brackets to shorten the code). But I wrote it like that just for the sake of clarity and to add my comments in there.

 

 

Thank you for helping me. Both functions work ingame. But there is one problem: In CS:GO (not on the desktop) the A and D keys are keeping pressed for some reason. I tried to fix that by deleting the bunny hop function and doing it seperatly with another script or just without bunny hopping but that didn't help.

 

 

EDIT: I found out that I only have this problem when I release SpaceBar before my mouse is perfectly still.



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

I wrote the part below the "-----" first, but had another idea I want you to try before that.

 

8::Send {a up}
9::Send {d up}

 

I'm curious if the {a up} and {d up} commands are triggering actions in CS:GO. If that's the case, we'll need a different approach to ensuring that the keys don't get stuck down or pressed down together.

 

--------

 

Can you run this script for a little bit? It won't do bunnyhopping, but it can help us figure some stuff out.

 

space::
While GetKeyState("Space","P")
{
MouseGetPos, x, y
FileAppend, X:%x% Y:%y%`n,spaceLog.txt
Sleep 100
}
return

 

Try to hold space for 3 seconds and have this script run once. In the first second, don't move the mouse. In the second second, move the mouse to the left as steadily as you can for 1 second. Then finally move the mouse to the right as steadily as you can. Then release the Space bar.

 

If you can go to where your script is saved, open up spaceLog.txt, and copy and paste it's contents here I might be able to figure something out.



kelisbest
  • Members
  • 8 posts
  • Last active: Feb 09 2015 04:14 PM
  • Joined: 08 Feb 2015

8 and 9 end the movement. When I release 8 or 9 but keep A or D pressed the movement doesn't start. To do so I have to repress A or D.



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Alright, so that first part means the keys are functioning as expected.

 

I'd like you to try out the second bit so I can try to evaluate if the lines for Send {a down} and Send {d down} are being triggered.

 

First, let's actually try to change the code with the "buffer" I suggested. if ((x_s - x_f) > 10)

 

What you have going on right now is that if there's even a 1 pixel difference between the x_s and x_f values, then you will get the air strafing. Using the above code instead will mean there needs to be at least an 11 pixel difference to air strafe. That should mean you won't need your mouse perfectly still. You can change 10 into something else to see what feels best for you in your gameplay.



kelisbest
  • Members
  • 8 posts
  • Last active: Feb 09 2015 04:14 PM
  • Joined: 08 Feb 2015

Alright, so that first part means the keys are functioning as expected.

 

I'd like you to try out the second bit so I can try to evaluate if the lines for Send {a down} and Send {d down} are being triggered.

 

First, let's actually try to change the code with the "buffer" I suggested. if ((x_s - x_f) > 10)

 

What you have going on right now is that if there's even a 1 pixel difference between the x_s and x_f values, then you will get the air strafing. Using the above code instead will mean there needs to be at least an 11 pixel difference to air strafe. That should mean you won't need your mouse perfectly still. You can change 10 into something else to see what feels best for you in your gameplay.

 

Then I'm bunny hopping all the time because it is always spamming SpaceBar. I tried to remove bunny hopping but the mousemovent still is almost not recognized. I only realize that A or D are pressed when I stand still. But I have to spin the mouse very fast and only move a very little bit on the ground. However when I release the SpaceBar in that moment A or D are still being pressed and the character continues to walk sideways until I have pressed both, A and D to release or press Space again, stop moving the mouse and then release space. I have a feeling that the UP command do not work in that case.



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Walk me through the steps of what you do in CS:GO. I have never played it.

 

You want these three actions in one:

 

1) When Space is held, and the mouse is not moving, simulate pressing the spacebar rapidly

2) When Space is held, and the mouse is moving to the right, press D until the mouse stops moving?

3) When Space is held, and the mouse is moving to the left, press A until the mouse stops moving?

 

Let's try this...

;In the auto-execute section
SetTimer, Check_Mouse, 50
return
 
Check_Mouse:
MouseGetPox, x_s ; I refreshed myself on documentation and noticed I don't need to retrieve the Y values
Sleep 40
MouseGetPos, x_f
If (x_s > x_f) ; If the starting value is larger than the final value
Direction:=Left
If (x_s < x_f)
Direction:=Right
If (x_s = x_f)
Direction:=None
return
 
$Space::
While GetKeyState("Space","P")
{
If Direction=None
    Send {Space}
else if Direction=Left
   {
    While Direction=Left
        Send {a down}
    Send {a up}
   }
else if Direction=Right
   {
    While Direction=Right
         Send {d down}
     Send {d up}
   }
}
return

You're going to need to toy with the Timer speed and Sleep duration to get something that is acceptable for you. You're going to be looking to strike a balance between how quickly the script responds and making sure that it doesn't respond unexpectedly. If you move don't move your mouse for 40ms while you try to move your mouse to the left or right (like if you had to physically lift your mouse off the table to move it back to the opposite side of your mousepad, or just mouse area if you don't have a pad), it'll end up spending Space..



kelisbest
  • Members
  • 8 posts
  • Last active: Feb 09 2015 04:14 PM
  • Joined: 08 Feb 2015

1) When Space is held, and the mouse is not moving, simulate pressing the spacebar rapidly

2) When Space is held, and the mouse is moving to the right, press D until the mouse stops moving?

3) When Space is held, and the mouse is moving to the left, press A until the mouse stops moving?

 

In CS:GO you are able to change your direction during a jump by pressing a movement key like A or D and moving your mouse to the same direction. Combined with bunny hopping it somehow allows you to slightly acceIlerate in mid air which can be useful to move faster and reach certain spots (I know it's weird).I need to be able to do 1) at the same time as I do 2) and 3). I realize that this won't be possible. So I have already a script for bunny hopping (1) when holding the SpaceBar. I think it is better to do a seperate script for strafing (2 and 3) on another key like B for example. What I have already tried modifying your script:

 

1)

*space::
Loop
{
GetKeyState,state,space,P
if state = U
break
Send,{space}
Sleep,20
}
return

2+3)

$b::
While GetKeyState("b","P") ; While you hold down the Space bar Physically
{
MouseGetPos, X_f, Y_f
Sleep 40
MouseGetPos, X_s, Y_s
If (X_s > X_f)
{
Send {a up} ; If a was being held down, release it
Send {d down}
}
else if (X_s < X_f)
{
Send {d up} ; if d was being held down, release it
Send {a down}
}
else
{
}
}
return

That seems to be better because the two actions don't block each other. It allows me to strafe and bunny hop at the same time. But there is still the main problem: When I release B while moving the mouse A or D are still pressed so I keep walking after I landed on the ground.



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

on your b hotkey, add this... which may actually fix the script from before and make it possible to combine the hotkeys... I may have goofed...

 

While GetKeyState("Space","P")
 {
...... blah blah blah
 }
Send {a up}{d up}
return

 

When you release space it'll release those keys as well. Might be problematic if you physically intended to hold those keys down, in which case, we can do this outside of the while-loop instead

 

If !GetKeyState("a","p") ; if you're not holding a down physically
  Send {a up}

 

And same with d.



kelisbest
  • Members
  • 8 posts
  • Last active: Feb 09 2015 04:14 PM
  • Joined: 08 Feb 2015

How can I remove a post?



kelisbest
  • Members
  • 8 posts
  • Last active: Feb 09 2015 04:14 PM
  • Joined: 08 Feb 2015

I don't know that much about writing scripts but this is what i have tried:

$b::
While GetKeyState("b","P") ; While you hold down the Space bar Physically
{
MouseGetPos, X_f, Y_f
Sleep 40
MouseGetPos, X_s, Y_s
If (X_s > X_f)
{
Send {a up} ; If a was being held down, release it
Send {d down}
}

else If !GetKeyState("a","p") ; if you're not holding a down physically
{   
Send {a up}
}
else if (X_s < X_f)
{
Send {d up} ; if d was being held down, release it
Send {a down}
}
else If !GetKeyState("d","p") ; if you're not holding a down physically
{
  Send {a up}
}
}
return     

Unfortunatly it does not fix the main problem, the buttons are being held down.



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Let's walk through the logic of the script.

 

If expression_a

else if expression_b

else if expression_c

else if expression_d

 

If any of those evaluate as true, none of the ones below it are checked. That's the purpose of the else statement.

 

It's like

 

if something is a penny
   You have $0.01
else if something is a dime
   You have $0.10
else if something is a nickel
   You have $0.05
else if something is a quarter
   You have $0.25

 

If you have a dime and a nickel, you're be told it's only a dime. If you dropped the else statements, then you would be told you have X money for every type of coin you have.

 

Spoiler

 

Only one color of block will ever be executed whenever you hold down the b key.

 

If your mouse moved to the right, the yellow block is executed. Then it goes back to the top, where it's bolded in dark blue.

If you did not move your mouse to the right, and you are also not holding the a key physically, then it executes the orange/salmon block. Then it goes back to the bolded dark blue at the top.

Only if you did not move your mouse to the right and you are holding down the a key, can the green or pink blocks be chosen. The green block will execute if you instead moved the mouse to the left. The pink block will execute only if you didn't move the mouse at all, were holding down a, and you did not hold down d.

 

So, the corrected script should be something like this:

 

$b::
While GetKeyState("b","P") ; While you hold down the Space bar Physically
{
MouseGetPos, X_f, Y_f
Sleep 40
MouseGetPos, X_s, Y_s
If (X_s > X_f)
{
Send {a up} ; If a was being held down, release it
Send {d down}
}
If (X_s < X_f)
{
Send {d up} ; if d was being held down, release it
Send {a down}
}
} ; We are now out of the loop. The code below this line will only execute when you release the "b" key
If !GetKeyState("a","p") ; if you're not holding a down physically
{   
Send {a up}
}
If !GetKeyState("d","p") ; if you're not holding a down physically
{
  Send {d up}
}
; We did not use else statements on these last 2 If statements because we want to check both of them, and both of them could be true. If both are true, we want both actions to be executed.
return     


kelisbest
  • Members
  • 8 posts
  • Last active: Feb 09 2015 04:14 PM
  • Joined: 08 Feb 2015

With your latest version this issue is fixed but the script is still not like I want it to be. I always use the speed and hop on one spot. I made a short YouTube video showcasing my problem as it is hard to describe. It should be uploaded in about 30 minutes.

 



MilesGC1999
  • Members
  • 1 posts
  • Last active: Nov 02 2015 12:49 AM
  • Joined: 31 Oct 2015

how do i imput this into the game?