Code:
fov = 30
local lp = LocalPlayer()
local shootpos = ply:GetShootPos()
function IsVisible(ply, pos)
local trace = {
start = LocalPlayer():EyePos(),
endpos = pos,
filter = {ply, LocalPlayer()},
mask = MASK_SHOT,
};
if (util.TraceLine(trace).Fraction == 1 ) then
return true;
end
return false;
end
function FovCheck(pos)
if isvector(pos) then
np = pos:ToScreen()
pos = np
h = false
w = false
if pos.x > ScrW()/2-fov and pos.x < ScrW()/2+fov then
w = true
end
if pos.y > ScrH()/2-fov then
if pos.y < ScrH()/2+fov then
h = true
end
end
if h and w then
return true
else
return false
end
else
print("Vector expected, got "..tostring(type(pos)))
end
end
function GetNextTarget()
for i,v in pairs(ents.GetAll()) do
if IsVisible(v:GetPos()) then
if v:IsPlayer() or v:IsNPC() then
if FovCheck(v:GetBonePosition(v:LookupBone('ValveBiped.Bip01_Head1')) or v:GetPos()) then
return (v:GetBonePosition(v:LookupBone('ValveBiped.Bip01_Head1')) or v:GetPos())
end
end
end
end
end
function aimbot()
lp:SetEyeAngles((GetNextTarget()-shootpos):Angle())
end
hook.Add('CreateMove','aimbutt',aimbot)
the part that doesnt work is
Code:
function aimbot()
lp:SetEyeAngles((GetNextTarget()-shootpos):Angle())
end
hook.Add('CreateMove','aimbutt',aimbot)
everything else works. glhf