hello guys , I'm trying to move a ped from a place to another, and when ped reach the specified destination, ped stop and outputChatBox say "You have reached your destination"
code is work but if not working where's the problem
function findRotation( x1, y1, x2, y2 )
local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) )
return t < 0 and t + 360 or t
end
function makePed()
local thePed = createPed(56, 2023.2751464844, 1544.3005371094, 10.820962905884)
setPedAnimation(thePed, "ped", "WOMAN_walknorm")
local x, y, z = 2024.2377929688,1543.8177490234,10.819551467896
local tx, ty, tz = 2030.9291992188,1544.3975830078,10.8203125
setPedRotation(thePed, findRotation(x, y, tx, ty))
local pedX ,pedY ,pedZ = getElementPosition(thePed)
if getDistanceBetweenPoints3D(pedX ,pedY ,pedZ , tx, ty, tz) <=0.1 then
setPedAnimation(thePed,false)
outputChatBox ("You have reached your destination")
end
end
addCommandHandler("ped", makePed)