Clientside Bunnyhop

Well, here is clientside bunnyhop. When you land, you jump again! Wow!
Bunnyhopping is the act of jumping once you hit the ground. As Garry’s Mod 10 does not really slow you down when you jump, bunnyhopping has no real use, except for coolness.

There are 3 console commands you SHOULD know,
and 2 you COULD know.

The important 3 are:
[ul]bunnyhopon[/ul]
Turns bunnyhopping on. Hold “e” to bunnyhop.
[ul]bunnyhopoff[/ul]
Turns bunnyhopping off.
[ul]lua_openscript_cl bunnyhop.lua[/ul]
Opens the script. (requires cheats to be on)

The other 2 are:
[ul]bind e usetoggle[/ul]
After running the script, this makes it so that e toggles bunnyhopping.
[ul]bind e +use[/ul]
Reverts e back to it’s normal behavior.

Installation instructions:
Place the following lua code into a file named “bunnyhop.lua” in /garrysmod/lua/

[lua]if(CLIENT) then // This is clientside only…
function bunnyhop()
self=LocalPlayer() //store the player
if(self:KeyDown(IN_USE)) then //if they are holding e…
local foottrace={}
foottrace.start=self:GetShootPos() //start at head
foottrace.endpos=foottrace.start-Vector(0,0,75) //to just below feet
foottrace.filter=k //ignore the player
res=util.TraceLine(foottrace) //and trace the line
if(res.Fraction<1) then //if they are touching the ground
self:ConCommand("+jump; wait; wait; -jump;") //jump!
end
end
end
hook.Add(“Think”,“Bunnyhop Think”,bunnyhop) //and hook it.

//This makes it so “usetoggle” toggles “+use” and “-use”
LocalPlayer():ConCommand(“alias useon “+use; alias usetoggle useoff”
alias useoff “-use; alias usetoggle useon”
alias usetoggle useoff”)

function cc_bunnyhopon() //I know this is crude, but it works
hook.Add(“Think”,“Bunnyhop Think”,bunnyhop)
LocalPlayer():ConCommand(“echo Bunnyhop on.”)
end
function cc_bunnyhopoff()
hook.Remove(“Think”,“Bunnyhop Think”)
LocalPlayer():ConCommand(“echo Bunnyhop off. Type ‘bind e +use’ to fully disable it.”)
end
function cc_usetoggle()
//Nothing here, just to add it to the auto command list
end

concommand.Add(“bunnyhopon”,cc_bunnyhopon) //Here is the console commands
concommand.Add(“bunnyhopoff”,cc_bunnyhopoff)
concommand.Add(“usetoggle”,cc_usetoggle)
end[/lua]

Notes:
**USING “bind e usetoggle” MAKES IT SO THAT BUTTONS ACT ODDLY. “bind e +use” WILL FIX THIS.

THE COMMANDS GO INTO THE CONSOLE (~)
IF YOU CANNOT USE THEM I DO NOT RECOMMEND THIS SCRIPT TO YOU.**

Is it better than manually bunny-hopping?

Well, eh, ahem, umm, yeah, it can’t miss a jump…
It also does slopes and crouching. And reduces wear on the space bar.

Counter strike fans would be happy!

I don’t use the space bar to jump :downs:

(Kind of a noob at this stuff…) how could i edit this to a different key instead of the use key? The only line I’m finding is “Bind e +use”

[lua]self:KeyDown(IN_USE)[/lua]

And this is triggered by +use, and turned off by -use, so if you rebound the use key it would change it.

Nifty! I use cfg already for one but nicely done anyhow.

How do you use a CFG? When I try it just makes my controls unresponsive.

This is better for SP Gmod10, because bunnyhopping works the way it should.

i cant see the code in the post?

Well done! You have proved my theory that the code in [lua][/lu****a] tags work quite a lot like The Emperor’s New Clothes.

Does this work for CSS too? If not, can someone make this for CSS?

CSS doesn’t use Lua, it can’t ever happen, ever.

http://www.overvprojects.nl/?page=blogentry&id=26

Oh that’s cool.

battle bott’s bhop script is pretty old and needlessly complicated. here’s a more modern and simpler one to use :v:
[lua]-- bhop by ninjers y’all

local bhopenabled = false
local bhoptoggle = true

local function bhopon()
bhopenabled = true
end
concommand.Add("+bhop", bhopon)

local function bhopoff()
bhopenabled = false
bhoptoggle = true
RunConsoleCommand("-jump")
end
concommand.Add("-bhop", bhopoff)

local function bhop()
if not bhopenabled then return end
RunConsoleCommand((bhoptoggle and “+” or “-”)…“jump”,"")
bhoptoggle = not bhoptoggle
end
hook.Add(“Think”, “jamhopper”, bhop)[/lua]
obviously just bind your key to +bhop and you’re ready to go.

[lua]
concommand.Add("+bounce", function()
hook.Add(“CreateMove”, “Bouncy bouncing!”, function(ucmd)
RunConsoleCommand(LocalPlayer():IsOnGround() and “+jump” or “-jump”)
end)
end)
concommand.Add("-bounce", function()
hook.Remove(“CreateMove”, “Bouncy bouncing!”)
end)
[/lua]



bind space +bounce


Enjoy!

hey i want a script for jump say i hold down c and i am constantly jumping and i need it to work on any server without being a hack just a script thanks

Some of your code is a bit…odd. For example, ply:OnGround() works better than a trace, and you can just PrintMessage() rather than concommanding echo. I redid some of it as my workplace is currently boring.

[lua]if(CLIENT) then // This is clientside only…
BunnyhopOn = false;
function bunnyhop()
if( BunnyhopOn ) then
if(LocalPlayer():KeyDown(IN_USE)) then //if they are holding e…
if(LocalPlayer():OnGround()) then //if they are touching the ground
self:ConCommand("+jump; wait; wait; -jump;") //jump!
end
end
end
end
hook.Add(“Think”,“Bunnyhop Think”,bunnyhop) //and hook it.

function cc_bunnyhopon() //I know this is crude, but it works
BunnyhopOn = true
LocalPlayer():PrintMessage( 3, “Bunnyhop on.” )
end
function cc_bunnyhopoff()
BunnyhopOn = false
LocalPlayer():PrintMessage( 3, “Bunnyhop off. Type ‘bind e +use’ to fully disable it.”)
end

concommand.Add("+bhop_on",cc_bunnyhopon) //Here is the console commands
concommand.Add("-bhop_on",cc_bunnyhopoff)
end[/lua]

Untested

E: Oh shit, didn’t see post date :byodood: