Помогите разобраться с ботом

Diego_Sativa

Известный
Автор темы
578
59
Включаю бота рыбалки, в оконном режиме. И с помощью открытия чата (F6) переходу в браузер что бы гта в афк не ушла.
Но бот начинает нажимать клавши в браузере. как этого избежать?
Lua:
script_author('checkdasound')

local events = require ('samp.events')
require ('moonloader')
require('memory').fill(0x00531155, 0x90, 5, true)

local act = false
local cooke = false
local state = false -- по умолчанию отключаем статус переменной для команды при запуске гта

function main() --открываем главную функцию
    while not isSampAvailable() do wait(100) end -- проверка на то, загружен ли самп
    sampRegisterChatCommand('rblk', rblk)
    sampRegisterChatCommand('worm', worm)    --регистрация команды
    while true do wait(2000)-- задержка 2000 мс
        if state then
            sampSendChat("/fish findworm") -- сообщение для отправки
        end -- закрываем проверку
    end --закрываем цикл
end --закрываем главную функцию

function worm()--создаем функцию, к которой обращается команда
    state = not state
    if state then -- проверяем статус переменной
        sampAddChatMessage('Поиск червей включён.', -1) --информируем в чат пользователя
    else
        sampAddChatMessage('Поиск червей отключен.', -1)
    end --закрываем проверку
end --закрываем функцию

function rblk()
    act = not act
    if act then
        sampAddChatMessage('Бот рыбалки включен.', -1)
    else
        sampAddChatMessage('Бот рыбалки выключен.', -1)
    end
end

function events.onDisplayGameText(style, time, text)
    -- print('Style: '..style..' Time: '..time..' Text: '..text)
    if act then
        if style == 6 and text == '~n~~n~~y~!' or style == 6 and text == '~n~~n~~n~~r~!' then
            lua_thread.create(function()
                lockPlayerControl(true)
                setVirtualKeyDown(VK_LMENU, true)
                wait(50)
                setVirtualKeyDown(VK_LMENU, false)
                lockPlayerControl(false)
            end)
        end
    end
end

function events.onServerMessage(color, text)
    -- print('Color: '..color..' Text: '..text)
    if act then
        if color == -1342193921 then
            if text:find('Вы оснастили') or text:find('Вы наживили') or text:find('Вы поймали') then
                lua_thread.create(function()
                    wait(3500)
                    lockPlayerControl(true)
                    setVirtualKeyDown(VK_LMENU, true)
                    wait(50)
                    setVirtualKeyDown(VK_LMENU, false)
                    lockPlayerControl(false)
                end)
            elseif text:find('Рыба сорвалась') then
           
                test = math.random(1, 20)
                print(test)
                lua_thread.create(function()
                    if test == 12 or test == 20 then
                        wait(1000)
                        setVirtualKeyDown(VK_D, true)
                        wait(50)
                        setVirtualKeyDown(VK_D, false)
                        wait(2450)
                        lockPlayerControl(true)
                        setVirtualKeyDown(VK_LMENU, true)
                        wait(50)
                        setVirtualKeyDown(VK_LMENU, false)
                        lockPlayerControl(false)
                    else
                        wait(3500)
                        lockPlayerControl(true)
                        setVirtualKeyDown(VK_LMENU, true)
                        wait(50)
                        setVirtualKeyDown(VK_LMENU, false)
                        lockPlayerControl(false)
                    end
                end)
            end
        end
    end
end