Совет Мини гайд/шаблон для бота пешком

copypaste_scripter

Известный
Автор темы
1,218
223
Здравствуйте.
Тему создал для тех, кто не хочет скачать бот мейкер от @SR_team по разным причинам (код взят со скрипта, созданным его бот мейкера, я всего лишь вырезал ненужную часть и прокоментировал).
Ссылка на его тему, вдруг вы просто не знали о нем: https://www.blast.hk/threads/13346/

И так. Сам код, который при активации на команду будет начинать выполнение маршрута. Нажатие клавиш, количество точек - на ваше усмотрение.
Каждую точку означает: BeginToPoint(x, y, z, 1.000000, -255, true)

Код 1:
require "lib.moonloader"
local keys = require "vkeys"

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    sampRegisterChatCommand("KOMANDAAKTIVACII", cmd_bot) -- вместо KOMANDAAKTIVACII ставим нужную команду

    local saveX = {}
    local saveY = {}
    local saveZ = {}
    while true do
        wait(0)
        if isPlayerPlaying(playerHandle) and enabled then
            local posX, posY, posZ = GetCoordinates()
            BeginToPoint(x, y, z, 1.000000, -255, true) -- true будет быстро бежать, false будет слегка бежать
            wait(500)
            setVirtualKeyDown(VK_H, true) -- нажмет H
                wait(100)
            setVirtualKeyDown(VK_H, false) -- отожмет H
            wait(500)
            BeginToPoint(x, y, z, 1.000000, -255, true)
            wait(500)
            BeginToPoint(x, y, z, 1.000000, -255, true)
            wait(500)
            setVirtualKeyDown(VK_N, true)
                wait(100)
            setVirtualKeyDown(VK_N, false)
            wait(500)
            BeginToPoint(x, y, z, 1.000000, -255, true)
            wait(500)
            BeginToPoint(x, y, z, 1.000000, -255, true)
            wait(500)
        end
    end
end

function BeginToPoint(x, y, z, radius, move_code, isSprint)
    repeat
        local posX, posY, posZ = GetCoordinates()
        SetAngle(x, y, z)
        MovePlayer(move_code, isSprint)
        local dist = getDistanceBetweenCoords3d(x, y, z, posX, posY, z)
        wait(0)
    until not enabled or dist < radius
end
function MovePlayer(move_code, isSprint)
    setGameKeyState(1, move_code)
    --[[255 - обычный бег назад
       -255 - обычный бег вперед
      65535 - идти шагом вперед
     -65535 - идти шагом назад]]
    if isSprint then setGameKeyState(16, 255) end
end

function SetAngle(x, y, z)
    local posX, posY, posZ = GetCoordinates()
    local pX = x - posX
    local pY = y - posY
    local zAngle = getHeadingFromVector2d(pX, pY)

    if isCharInAnyCar(playerPed) then
        local car = storeCarCharIsInNoSave(playerPed)
        setCarHeading(car, zAngle)
    else
        setCharHeading(playerPed, zAngle)
    end

    restoreCameraJumpcut()
end

function GetCoordinates()
    if isCharInAnyCar(playerPed) then
        local car = storeCarCharIsInNoSave(playerPed)
        return getCarCoordinates(car)
    else
        return getCharCoordinates(playerPed)
    end
end

function cmd_bot(param)
    enabled = not enabled
    if enabled then
        sampAddChatMessage(string.format("[%s]: Активирован", thisScript().name), 0x40FF40)
    else
        sampAddChatMessage(string.format("[%s]: Деактивирован", thisScript().name), 0xFF4040)
    end
end

Код для получения координатов для самого бота. Или можно использовать и в других целях.
При нажатии ALT+P копирует координаты на котором стоит персонаж в следующем виде: "100, 200, 300". Можете сразу вставить в скрипте.

Код 2:
require "lib.moonloader"
local keys = require "vkeys"
local sampev = require "lib.samp.events"

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
       
        if isKeyDown(VK_MENU) and isKeyJustPressed(VK_P) then
            local x, y, z = getCharCoordinates(PLAYER_PED)
            sampAddChatMessage("Coords saved to Clipboard", -1) -- выводит в чат сообщение, что скопировались координаты
            --sampAddChatMessage(string.format('%d %d %d', x, y, z), -1) -- уберите "--" спереди линии если хотите чтобы в чат писал координаты
            setClipboardText(x .. ", " .. y .. ", " .. z)
        end
       
    end
end

Сайт, где можете получить коды виртуальных клавиш или для правильной их названия: https://cherrytree.at/misc/vk.htm, или погуглите сами.
 

chapo

🫡 В армии с 17.10.2023. В ЛС НЕ ОТВЕЧАЮ
Друг
8,763
11,198
чем BeginToPoint лучше taskCharSlideToCoord(Ped ped,float toX,float toY,float toZ,float angle,float withinRadius)?
 

copypaste_scripter

Известный
Автор темы
1,218
223
чем BeginToPoint лучше taskCharSlideToCoord(Ped ped,float toX,float toY,float toZ,float angle,float withinRadius)?
не знаю, я всего лишь достал код из скрипта, использовал сам, сработал. решил рассказать в таком виде чтобы легче было (хз для меня так было бы удобней) 🤔
 
D

deleted-user-422095

Гость
Ну тогда уже это вклей
 
  • Нравится
Реакции: Крипер

copypaste_scripter

Известный
Автор темы
1,218
223
Ну тогда уже это вклей
клей закончился, увы