помогите сделать

Long Penis

Участник
Автор темы
64
5
Версия MoonLoader
.026-beta
помогите сделать так чтобы он водил команду /loto с задержкой, если увидит в чате надпись. ато сразу водит
Lua:
local sampev = require "lib.samp.events"
require  "lib.moonloader"
local active = false

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end


    sampRegisterChatCommand("startfind",function() sampAddChatMessage("Вы начали поиск.",-1)
    active = not active
    end)
    sampRegisterChatCommand("stopfind",function() sampAddChatMessage("{ADFF2F}{Lovlya loto}{ffffff}Поиск остановлен",-1)
    active = active
    end) ]]--
    while true do
    wait(0)
    end
end


function sampev.onServerMessage(color, text)
    if text:find('Бал', 1, true) then
        sampSendChat('/loto')
    active = true
   
    end
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)

    if active and dialogId == 5345 then
        sampSendDialogResponse(5347, 1, 2, nil)
        active = false  
    end
end
 
Решение
Lua:
function sampev.onServerMessage(color, text)
    if text:find('Бал', 1, true) then
    lua_thread.create(function () -- создание потока
    wait(1000) -- задержка в 1 секунду
    sampSendChat('/loto')
    active = true
    end) -- закрытие потока
    end
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if active and dialogId == 5345 then
        sampSendDialogResponse(5347, 1, 2, nil)
        active = false
    end

Kolbasa241

Известный
213
57
Lua:
function sampev.onServerMessage(color, text)
    if text:find('Бал', 1, true) then
    lua_thread.create(function () -- создание потока
    wait(1000) -- задержка в 1 секунду
    sampSendChat('/loto')
    active = true
    end) -- закрытие потока
    end
end

function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if active and dialogId == 5345 then
        sampSendDialogResponse(5347, 1, 2, nil)
        active = false
    end
 
Последнее редактирование модератором: