Advertisement
LordOfGears2

Auto-Strafe and Bhop Gmod

Jul 25th, 2013
4,540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.52 KB | None | 0 0
  1. local bhop = { }
  2. bhop.MetaPlayer = FindMetaTable( "Player")
  3. bhop.oldKeyDown = bhop.MetaPlayer['KeyDown']
  4. bhop.On = true
  5. bhop.SOn = true
  6. bhop.Hooks = { hook = { }, name = { } }
  7. bhop.jump = false
  8. function bhop.AddHook(hookname, name, func)
  9.     table.insert( bhop.Hooks.hook, hookname )
  10.     table.insert( bhop.Hooks.name, name )
  11.     hook.Add( hookname, name, func ) --Hopefully you have something better
  12. end
  13. bhop.MetaPlayer['KeyDown'] = function( self, key )
  14.     if self ~= LocalPlayer() then return end
  15.    
  16.     if (key == IN_MOVELEFT) and bhop.left then
  17.         return true
  18.     elseif (key == IN_MOVERIGHT) and bhop.right then
  19.         return true
  20.     elseif (key == IN_JUMP) and bhop.jump then
  21.         return true
  22.     else
  23.         return bhop.oldKeyDown( self, key )
  24.     end
  25. end
  26.  
  27. local oldEyePos = LocalPlayer():EyeAngles()--This is to see where player is looking
  28. function bhop.CreateMove( cmd )
  29.     bhop.jump = false
  30.     if (cmd:KeyDown( IN_JUMP )) then
  31.    
  32.         if (not bhop.jump) then
  33.             if (bhop.On and not LocalPlayer():OnGround()) then --Bhop here
  34.                 cmd:RemoveKey( IN_JUMP )
  35.             end
  36.         else
  37.             bhop.jump = false
  38.         end
  39.  
  40.         if(bhop.SOn ) then--auto strafer
  41.             local traceRes = LocalPlayer():EyeAngles()
  42.                                    
  43.             if( traceRes.y > oldEyePos.y ) then --If you move your mouse left, walk left, if you're jumping
  44.                 oldEyePos = traceRes
  45.                 cmd:SetSideMove( -1000000 )
  46.                 bhop.left = true
  47.                 bhop.right = false
  48.             elseif( oldEyePos.y > traceRes.y )  then --If you move your mouse right, move right,  while jumping
  49.                 oldEyePos = traceRes
  50.                 cmd:SetSideMove( 1000000 )
  51.                 bhop.right = true
  52.                 bhop.left = false
  53.             end
  54.         end
  55.     elseif (not bhop.jump) then
  56.         bhop.jump = true
  57.     end      
  58. end
  59.            
  60. bhop.AddHook( "CreateMove", tostring(math.random(0, 133712837)), bhop.CreateMove )--add the hook
  61.  
  62. concommand.Add( "bhop", function () --Toggler
  63.     bhop.On = not bhop.On  
  64.     local state = "off"
  65.     if bhop.On then state = "on" end
  66.     print("Bhop ".. state)
  67. end)
  68.    
  69. concommand.Add( "bhop_strafe",  function ()
  70.     bhop.SOn = not bhop.SOn
  71.     local state = "off"
  72.     if bhop.SOn then state = "on" end
  73.     print("Strafe ".. state)
  74. end)
  75.  
  76. concommand.Add("bhop_unload", function()
  77.     for i = 1, #bhop.Hooks.hook do
  78.         hook.Remove( bhop.Hooks.hook[i], bhop.Hooks.name[i] )
  79.         print( "Unhooked "..bhop.Hooks.hook[i].." using name "..bhop.Hooks.name[i] )
  80.     end
  81.    
  82.     concommand.Remove("bhop_strafe")
  83.     concommand.Remove("bhop")
  84.     concommand.Remove( "bhop_unload" )
  85.     bhop = nil
  86.    
  87.     print("Bhop unloaded")
  88. end)
  89.            
  90. print("Bhop loaded\nMade by LordOfGears2, enjoy. \nLeave feedback, please\n\n\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement