проверка на сообщение в чате

xolod0k

Новичок
Автор темы
3
1
Версия MoonLoader
.027.0-preview
пытаюсь сделать скрипт, который флудит /ot и перестает флудить когда я принимаю репорт. идей как сделать так, чтобы переставал флудить - только одна: сделать проверку на мой ник в чате.
kod:
require "lib.moonloader"
local sampev = require "lib.moonloader"
local key = 115

local active = false

function main()
    while not isSampAvailable() do wait(0) end
    while true do
        wait(150)
        if active then
            sampSendChat('/ot')
        end
        if isSampfuncsConsoleActive() and active == true or sampIsChatInputActive() and active == true or sampIsDialogActive() and active == true or isPauseMenuActive() and active == true then
            active = false
            sampAddChatMessage('Флудер выключен', -1)
        end
        if wasKeyPressed(key) then
            if active then
                active = false
                sampAddChatMessage('Флудер /ot выключен', -1)
            else
                active = true
                sampAddChatMessage('Флудер /ot включен', -1)
            end
        end
    end
end

function sampev.onServerMessage(color, text)
     if text:find('Nick_Name') and active then
          active = false
          sampAddChatMessage('Вы словили репорт!')
     end
end
Прикрепил свой код, но он не работает. не понимаю, как это сделать, хелп плиз. я чайник, не бейте!!!
 

fokichevskiy

Известный
496
283
переписал систему флуда, и теперь он останавливается при появлении диалога от команды /ot
обрати внимание на 3, 41, 51, 52 строчки и не забудь сохранить файл в кодировке windows-1251

Lua:
require "lib.moonloader"
local sampev = require('lib.samp.events')
local key = VK_F4 -- тут твоя клавиша, вводишь через VK_{КЛАВИША}

local active = false

function main()
    while not isSampAvailable() do wait(0) end
    flooder = FloodThread()
    while true do
        if wasKeyPressed(key) then
            if flooder:status() == 'suspended' or flooder:status() == 'dead' then
                active = true
                flooder:run()
            else
                active = false
                flooder:terminate()
            end
            sampAddChatMessage('Флудер /ot ' .. (active and 'включен' or 'выключен'), -1)
        end
        wait(0)
    end
end

function FloodThread()
    local flooder = lua_thread.create_suspended(function ()
        while true do
            if isSampfuncsConsoleActive() or sampIsChatInputActive() or isPauseMenuActive() then
                active = false
                sampAddChatMessage('Флудер выключен', -1)
                break
            end
            sampSendChat('/ot')
            wait(150)
        end
    end)
    return flooder
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if dialogId == 123 then -- тут впиши айди диалога с /ot
        flooder:terminate()
        active = false
        sampAddChatMessage('Вы словили репорт, флудер выключен.', -1)
    else -- если вылезает какой-либо другой диалог, то флудер останавливается
        flooder:terminate()
        active = false
    end
end

function sampev.onSendDialogResponse(dialogId, button, listboxId, input) -- если надо, то после ответа на репорт флудер будет включаться, в противном случае удали эту функцию
    if dialogId == 123 then -- тут впиши айди диалога с /ot
        flooder:run()
        active = true
        sampAddChatMessage('Флудер включен.', -1)
    end
end
 
Последнее редактирование: