local ped = createPed(49,1491.0987548828, -1735.0596923828, 13.3828125 +1)
local dx,dy = guiGetScreenSize()
aimX ,aimY = dx*0.55 , dy*0.3991
function AimOnPosition()
local setToX,setToY = 0,0
local hx, hy, hz = getElementPosition(ped)
local sx,sy = getScreenFromWorldPosition(hx,hy,hz)
setToX = math.abs(dx/2-(aimX))
setToY = math.abs(dy/2-aimY)
local a1,a2,a3 = getPedBonePosition(ped, 6)
local a4,a5,a6 = getElementPosition(ped)
local b1,b2,b3 = getElementPosition(localPlayer)
local dist = getDistanceBetweenPoints3D(a1,a2,a3,b1,b2,b3)
setToX,setToY = getWorldFromScreenPosition(sx-setToX,sy+setToY,dist)
_,_,setToX1 = getWorldFromScreenPosition(dx/2,dy/2,dist)
_,_,setToX2 = getWorldFromScreenPosition(aimX,aimY,dist)
pos1 = (setToX2 - setToX1)
setCameraTarget(a4,a5,a6)
setCameraTarget(setToX - 0.19,setToY, b3 - pos1 + (a3-b3))
end
function drawStuff()
if getControlState("aim_weapon") then
AimOnPosition()
end
end
addEventHandler("onClientRender", root, drawStuff)
https://prnt.sc/138u4p9
I edited the automatic aiming script, but it keeps showing up in the debugscript (attempt to perform arithmetic on local 'sx' (a boolean value)) if someone knows for him to aim directly at the pedestrian or he just aims at the pedestrians who are on my screen
I've tried several things but none works