Adding a table to my aimbot
For efficiency reasons, I want to add a table to my aimbot. I currently am using basic ones but I want to create a table, insert every player online into it, and then find the closest one and aim. I have a working aimbot script me and my friend came up with but we're stuck on how to integrate thistable w/o major changing or breaking the code. We're kind a new to Lua. Here's the code..
I'm pretty proud of what we've got so far, but we really need help with this one :P
Code:
hook.Add( "Think", "ThinkAboutIt", function()
if GetConVarNumber(rook.."Aimbot") == 1 then
if input.IsButtonDown(12) then
local closest = nil
local NearestTarget = 0
for k, v in pairs( player.GetAll() ) do
local Target = ( Vector( v:GetPos() ):Distance( Vector( LocalPlayer():GetPos() ) ) )
if Target ~= 0 then
if Target < NearestTarget or NearestTarget == 0 then
NearestTarget = Target
if NearestTarget == Target then
closest = v
end
end
if closest == nil then end
if closest:LookupBone("ValveBiped.Bip01_Head1") == nil then
LocalPlayer():SetEyeAngles( (closest:EyePos()-LocalPlayer():GetShootPos()):Angle() )
else
local closesthead = closest:LookupBone("ValveBiped.Bip01_Head1")
local closestheadpos,closestheadang = closest:GetBonePosition(closesthead)
LocalPlayer():SetEyeAngles((closestheadpos - LocalPlayer():GetShootPos()):Angle())
end
end
end
end
end
end)
