function runToPoint(tox, toy)
local x, y, z = getCharCoordinates(PLAYER_PED)
local angle = getHeadingFromVector2d(tox - x, toy - y)
local xAngle = math.random(-50, 50)/100
setCameraPositionUnfixed(xAngle, math.rad(angle - 90))
stopRun = false
while getDistanceBetweenCoords2d(x, y, tox, toy) > 0.8 do
setGameKeyState(1, -255)
setGameKeyState(16, 1)
wait(1)
x, y, z = getCharCoordinates(PLAYER_PED)
angle = getHeadingFromVector2d(tox - x, toy - y)
setCameraPositionUnfixed(xAngle, math.rad(angle - 90))
if stopRun then
stopRun = false
break
end
end
end
-- Функцию выше не трогай, просто вставь её в начало своего скрипта
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand('run', hzzz) -- Добавление новой команды
wait(-1) -- Бесконечное ожидание
end
function hzzz()
lua_thread.create(function() -- Создаём новый поток (Обязательно для вызова функции)
runToPoint(1488, -1337) -- Вызов функции
sampAddChatMessage('Скрипт успешно работает!', -1) -- Ненужная херня
end) -- Тут наш поток заканчивается
end