Some variables are from other scripts, anyway, this strafes for you automatically.
If you're in a sandbox server, for some reason you go really fast with backwards hop enabled.
The convars are:
draw_gui [1] by default
autostrafe_enabled [1] by default
bhop_enabled [1] by default
backwards_hop [0] by default
There may some bugs if you're trying to surf or crouch jump.
Code:
local GUI_ENABLED = CreateClientConVar('draw_gui', 1, true, false)
local A_S = CreateClientConVar('autostrafe_enabled', 1, true, false)
local B_S = CreateClientConVar('bhop_enabled', 1, true, false)
local BWH = CreateClientConVar('backwards_hop', 0, true, false)
local G = {}
G.tbl_Copy = table.Copy
G.mtbl_Find = FindMetaTable
local Meta_UCMD = G.mtbl_Find("CUserCmd")
local Meta_ENT = G.mtbl_Find("Entity")
local GetMouseY = Meta_UCMD.GetMouseY
local GetMouseX = Meta_UCMD.GetMouseX
local SetSideMove = Meta_UCMD.SetSideMove
local RemoveKey = Meta_UCMD.RemoveKey
local SetButtons = Meta_UCMD.SetButtons
local GetButtons = Meta_UCMD.GetButtons
local OnGround = Meta_ENT.IsOnGround
local WaterLevel = Meta_ENT.WaterLevel
local GetMoveType = Meta_ENT.GetMoveType
local JUMP = IN_JUMP
hook.Add('HUDPaint', 'BHOP_ENABLED_TEXT', function()
if GUI_ENABLED:GetBool() then
draw.DrawText('AutoStrafe ' .. (A_S:GetBool() == true and 'Enabled' or 'Disabled') ..
'\n BunnyHop ' ..(B_S:GetBool() == true and 'Enabled' or 'Disabled') ..
'\n Backwards ' .. (BWH:GetBool() == true and 'Enabled' or 'Disabled'),
'TargetID', ScrW() * .5, ScrH() *.1, Color(255,100,100,255), TEXT_ALIGN_CENTER)
end
end)
hook.Add('CreateMove', 'AutoStrafe', function(cmd)
if (A_S:GetBool() and cmd:KeyDown(IN_JUMP)) then
if (OnGround(LocalPlayer()) and B_S:GetBool()) then
SetButtons(cmd, GetButtons(cmd), JUMP)
elseif (WaterLevel(LocalPlayer()) < 2 && GetMoveType(LocalPlayer()) ~= MOVETYPE_LADDER && !OnGround(LocalPlayer()) and not string.find(gmod.GetGamemode().Name,'Bunny Hop')) then
RemoveKey(cmd, JUMP)
end
if (GetMouseX(cmd) < 0) then
if BWH:GetBool() then
SetSideMove(cmd, 10000)
else
SetSideMove(cmd, -10000)
end
elseif (GetMouseX(cmd) > 0) then
if BWH:GetBool() then
SetSideMove(cmd, -10000)
else
SetSideMove(cmd, 10000)
end
end
if (LocalPlayer():IsOnGround() and not gmod.GetGamemode().Name:find'Bunny Hop') then
cmd:SetButtons(bit.bor(cmd:GetButtons(), IN_JUMP));
return;
end
end
--cmd:RemoveKey(IN_JUMP);
end)