vector.New(x:number, y:number, z:number):Vector3Create a new vector from components.
Vector math helpers.
vector.New(x:number, y:number, z:number):Vector3Create a new vector from components.
vector.Add(a:Vector3, b:Vector3):Vector3Add two vectors.
vector.Subtract(a:Vector3, b:Vector3):Vector3Subtract two vectors.
vector.Multiply(v:Vector3, s:number):Vector3Scale the vector by a scalar.
vector.Divide(v:Vector3, s:number):Vector3Divide the vector by a scalar.
vector.Length(v:Vector3):numberLength of the vector.
vector.LengthSqr(v:Vector3):numberSquared length of the vector.
vector.Distance(a:Vector3, b:Vector3):numberDistance between two vectors.
vector.Normalize(v:Vector3):Vector3Return a normalized copy of the vector.
vector.Angles(v:Vector3):Vector3Convert a direction vector to Euler angles.
vector.AngleForward(a:Vector3):Vector3Forward vector from angles.
vector.AngleRight(a:Vector3):Vector3Right vector from angles.
vector.AngleUp(a:Vector3):Vector3Up vector from angles.
vector.AngleVectors(a:Vector3):Vector3, Vector3, Vector3Forward, right and up vectors from angles.
vector.AngleNormalize(a:Vector3):Vector3Normalize each angle to the -180 to 180 range.
While holding the aim key, points your view at the closest living enemy head.
local AIM_KEY = 0x51 -- VK_Q
callbacks.Register("CreateMove", function(cmd)
if not client.IsKeyDown(AIM_KEY) then return end
local me = client.GetLocalPlayer()
if not me:IsValid() then return end
local best, bestDist = nil, math.huge
for _, ent in pairs(entities.GetPlayers()) do
if ent:IsValid() and ent:IsAlive() and ent:GetTeam() ~= me:GetTeam() then
local d = vector.Distance(me:GetAbsOrigin(), ent:GetAbsOrigin())
if d < bestDist then best, bestDist = ent, d end
end
end
if not best then return end
local to = vector.Subtract(best:GetEyePosition(), me:GetEyePosition())
cmd.viewangles = vector.Angles(to)
end)