Бег туды сюды

Dewize

Известный
Автор темы
432
88
Версия MoonLoader
.027.0-preview
Крч есть такой код

кпа:
--Переменые--
local dist = 9999
local Bool = false
------------------------------

--Гл.Функция--
function main()
    --Начало каждого Main Function--
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    ------------------------------

    sampAddChatMessage('Script loaded!!!',-1)
    sampRegisterChatCommand('cmds',function() Bool = not Bool sampAddChatMessage(Bool and 'Вкл' or 'Выкл',-1) end)

    --Бесконечный цикл--
    while true do wait(0)
        if Bool then
            for i=0, 2048 do
                if sampIs3dTextDefined(i) then
                    local text, color, posX, posY, posZ, distance, ignoreWalls, playerId, vehicleId = sampGet3dTextInfoById(i)
                    local x, y, z = getCharCoordinates(playerPed)
                    if string.match(text,'Место') then
                        local res = getDistanceBetweenCoords3d(posX,posY,posZ,x, y, z)
                        if dist > res then
                            dist = (res >= 1 and res or 9999)
                            if runToPoint(posX, posY) then
                                -- действие
                                Bool = false
                            end
                        end
                    end
                end
            end
        end

    end
end
------------------------------

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
    return true
end
Суть его такова, что когда он доходит до надписи Bool = false, а он дальше бежит к другой, чо делать?
 
  • Вау
  • Ха-ха
Реакции: IlyaHL2 и Dmitry Code

IlyaHL2

Активный
210
53
в функе runToPoint есть переменная stopRun, работай с ней
либо поменяй на свою

примерно так

Lua:
--Переменые--
local dist = 9999
local stopRun = false
------------------------------

--Гл.Функция--
function main()
    --Начало каждого Main Function--
    while not isSampAvailable() do wait(100) end
    ------------------------------

    sampAddChatMessage('Script loaded!!!',-1)
    sampRegisterChatCommand('cmds',function() Bool = not Bool sampAddChatMessage(Bool and 'Вкл' or 'Выкл',-1) end)

    --Бесконечный цикл--
    while true do wait(0)
        if Bool then
            for i=0, 2048 do
                if sampIs3dTextDefined(i) then
                    local text, color, posX, posY, posZ, distance, ignoreWalls, playerId, vehicleId = sampGet3dTextInfoById(i)
                    local x, y, z = getCharCoordinates(playerPed)
                    if string.match(text,'Место') then
                        local res = getDistanceBetweenCoords3d(posX,posY,posZ,x, y, z)
                        if dist > res then
                            dist = (res >= 1 and res or 9999)
                            if runToPoint(posX, posY) then
                                -- действие
                                stopRun = true
                            end
                        end
                    end
                end
            end
        end

    end
end
------------------------------

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
    return true
end