local jumpThr
function runTo(x, y, z, runKey, xcam, plusChange)
repeat
local pX, pY, pZ = getCharCoordinates(playerPed)
local gg = fix(representIntAsFloat(readMemory(0xB6F258, 4, false)))
local wp = fix(representIntAsFloat(readMemory(0xB6F248, 4, false)))
local gg = gg + math.pi
local nad = GetAngleBeetweenTwoPoints(x,y)
local test = GetAngleBeetweenTwoPoints(x,y) - gg - math.pi
local dist = getDistanceBetweenCoords3d(x,y,z, pX, pY, pZ)
if plusChange == nil then plusChange = 0.0 end
local ot = 1.5
local waitTime = representIntAsFloat(readMemory(0xB7CB5C, 4, false))/42
wait(waitTime)
if runKey ~= nil then
setGameKeyState(1, -128)
else
setGameKeyState(1, -128)
end
if runKey == 1 then
setGameKeyState(16, 255)
elseif runKey == 2 then
setGameKeyState(21, 255)
elseif runKey == 3 then
if dist >= 5.4 then
if jumpThr == nil then
local x = math.random(1, 100000)
if x >= 94000 then
jumpThr = lua_thread.create(function()
wait(200)
setGameKeyState(14, 255) -- its not jump
jumpThr = nil
end)
end
end
end
elseif runKey == 4 then
setGameKeyState(17, 255)
end
local changeFloat = 0.04 --DEFAULT 0.04
if runKey == 1 then
if dist > 5.0 then changeFloat = 0.08 +plusChange
elseif dist > 3.0 then changeFloat = 0.1 +plusChange
elseif dist > 1.8 then changeFloat = 0.04 + plusChange
end
elseif runKey == 0 then
if dist > 5.0 then changeFloat = 0.08 + plusChange
elseif dist > 3.0 then changeFloat = 0.12 + plusChange
elseif dist > 1.8 then changeFloat = 0.14 +plusChange
end
elseif runKey == 3 then
if dist > 5.0 then changeFloat = 0.08 + plusChange
elseif dist > 3.0 then changeFloat = 0.12 + plusChange
elseif dist > 1.8 then changeFloat = 0.14 +plusChange
end
end
if dist > 1.8 then
if test > -0.1 and test < 0.03 then setCameraPositionUnfixed(xcam, GetAngleBeetweenTwoPoints(x,y))
elseif test < -5.7 and test > -5.93 then setCameraPositionUnfixed(xcam, GetAngleBeetweenTwoPoints(x,y))
elseif test < -6.0 and test > -6.4 then setCameraPositionUnfixed(xcam, GetAngleBeetweenTwoPoints(x,y))
elseif test > 0.04 then setCameraPositionUnfixed(xcam, fix(representIntAsFloat(readMemory(0xB6F258, 4, false)))+changeFloat)
elseif test < -3.5 and test > -5.67 then setCameraPositionUnfixed(xcam, fix(representIntAsFloat(readMemory(0xB6F258, 4, false)))+changeFloat)
else setCameraPositionUnfixed(xcam, fix(representIntAsFloat(readMemory(0xB6F258, 4, false)))-changeFloat)
end
else
setCameraPositionUnfixed(wp, GetAngleBeetweenTwoPoints(x,y))
end
until dist < ot
end
function GetAngleBeetweenTwoPoints(x2,y2)
local x1, y1, z1 = getCharCoordinates(playerPed)
local plus = 0.0
local mode = 1
if x1 < x2 and y1 > y2 then plus = math.pi/2; mode = 2; end
if x1 < x2 and y1 < y2 then plus = math.pi; end
if x1 > x2 and y1 < y2 then plus = math.pi*1.5; mode = 2; end
local lx = x2 - x1
local ly = y2 - y1
lx = math.abs(lx)
ly = math.abs(ly)
if mode == 1 then ly = ly/lx;
else ly = lx/ly; end
ly = math.atan(ly)
ly = ly + plus
return ly
end
function GetXAngle(startDist, dist, startXAngle, x,y,z)
local x1, y1, z1 = getCharCoordinates(playerPed)
local xAngle
if mnum(z) > mnum(z1) then
xAngle = 2
elseif -68 >= z and dist > 2.8 and z1 <= -67.0 then
xAngle = 0
else
local interest = (dist*100)/startDist
if interest == 0 then
interest = 100
end
if interest > 65 then
xAngle = 2*(100-interest)/100-2
else
xAngle = 2*interest/100-2
end
end
return xAngle
end
function mnum(number)
return (number - (number % 0.1))+0.1
end
function fix(angle) -- фикс, не помню у кого спиздил
while angle > math.pi do
angle = angle - (math.pi*2)
end
while angle < -math.pi do
angle = angle + (math.pi*2)
end
return angle
end