local hedef = Target(10)
function GetCoordsFromCam(distance)
local rot = GetGameplayCamRot(2)
local coord = GetGameplayCamCoord()
local tZ = rot.z * 0.0174532924
local tX = rot.x * 0.0174532924
local num = math.abs(math.cos(tX))
newCoordX = coord.x + (-math.sin(tZ)) * (num + distance)
newCoordY = coord.y + (math.cos(tZ)) * (num + distance)
newCoordZ = coord.z + (math.sin(tX) * 8.0)
return newCoordX, newCoordY, newCoordZ
end
function Target(Distance)
local Entity = nil
local camCoords = GetGameplayCamCoord()
local farCoordsX, farCoordsY, farCoordsZ = GetCoordsFromCam(Distance)
local RayHandle = StartShapeTestRay(camCoords.x, camCoords.y, camCoords.z, farCoordsX, farCoordsY, farCoordsZ, -1, PlayerPedId(), 0)
local A,B,C,D,Entity = GetRaycastResult(RayHandle)
return Entity, farCoordsX, farCoordsY, farCoordsZ
end