Advertisement
Guest User

Simple Gmod lua aimbot

a guest
Jan 25th, 2015
4,859
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | None | 0 0
  1. local res = {
  2.     "weapon_physgun",
  3.     "weapon_physcannon",
  4.     "gmod_tool",
  5.     "gmod_camera"
  6. }
  7. local playere = FindMetaTable("Player")
  8. function playere:EyeVisible(ent)
  9.     if (not IsValid(ent)) then
  10.         return
  11.     end
  12.  
  13.     local trace = { start = self:LocalToWorld(self:OBBCenter()), endpos = ent:LocalToWorld(ent:OBBCenter()), filter = { self, ent }, mask = 1174421507 }
  14.     local tr = util.TraceLine(trace)
  15.     return (tr.Fraction == 1)
  16. end
  17.  
  18. local target = NULL
  19. local lock = false
  20. hook.Remove("CreateMove", "lel")
  21. hook.Add("CreateMove", "lel", function( cmd )
  22.     local wep = LocalPlayer():GetActiveWeapon()
  23.         if IsValid(wep) then
  24.         if not table.HasValue(res, wep:GetClass()) then
  25.             local wep = LocalPlayer():GetActiveWeapon()
  26.             if IsValid(wep) and wep.Primary != nil then
  27.                 wep.Primary.Recoil = 0
  28.                 wep.Primary.Cone = 0
  29.             end
  30.             if lock == false and target == NULL then
  31.                 target = LocalPlayer():GetEyeTrace().Entity
  32.                 lock = true
  33.             end
  34.             if not LocalPlayer():EyeVisible(target) then
  35.                 lock = false
  36.                 target = NULL
  37.             end
  38.             if target ~= NULL then  
  39.                 if target:Health() <= 0 then
  40.                     lock = false
  41.                     target = NULL
  42.                 end
  43.             end
  44.             if target ~= NULL and target:IsPlayer() or target:IsNPC() then
  45.                 local targethead = target:LookupBone("ValveBiped.Bip01_Spine")
  46.                     if targethead != nil and lock == true then
  47.                         local targetheadpos, targetheadang = target:GetBonePosition(targethead)
  48.                         cmd:SetViewAngles((targetheadpos-LocalPlayer():GetShootPos()):Angle()) 
  49.                     end
  50.             elseif not IsValid(target) then
  51.                 lock = false
  52.                 target = NULL
  53.             end
  54.         end
  55.     end
  56. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement