/*

	aHop.lua
	
	Advanced bunnyhop v1.0
	
	"Simple, yet effective."
	
*/

/************************************/

local Enabled = true
local Jumps = 0
local aHop = {}

/*

	Helper functions
		
*/

function aHop.AddHook( Type, Function )
	Name = "[aHop] - " .. math.random( 1, 10000 )
	hook.Add( Type, Name, Function )
end

function aHop.AddCommand( Name, Function )
	concommand.Add( Name, Function )
end

/*

	Core functions
	
*/

function aHop.toggleBunnyhop()
	Enabled = !Enabled
	if Enabled == true then
		chat.AddText( Color( 255, 0, 0 ), "[aHop v1.0] ", Color( 255, 255, 255 ), "Bunnyhop enabled." )
	else
		chat.AddText( Color( 255, 0, 0 ), "[aHop v1.0] ", Color( 255, 255, 255 ), "Bunnyhop disabled." )
	end
end

function aHop.bunnyHop( cmd, u )
	if Enabled then
		if !LocalPlayer():IsOnGround() then
			cmd:SetButtons( bit.band( cmd:GetButtons(), bit.bnot( IN_JUMP ) ) )			
			Jumps = Jumps + 1
		end
	end
end

/*

	Hooks and command adding.
	
*/

aHop.AddCommand( "aHop", aHop.toggleBunnyhop )
aHop.AddHook( "CreateMove", aHop.bunnyHop )
chat.AddText( Color( 255, 255, 50 ), "[aHop v1.0] ", Color( 255, 255, 255 ), "Loaded script!" )
chat.AddText( Color( 255, 50, 255 ), "[aHop v1.0] ", Color( 255, 255, 255 ), "Type 'aHop' in console to toggle the script." )