не работает wait()

Dark.

Известный
Автор темы
1,750
768
Версия MoonLoader
Другое
Крч, решил себе написать простенький биндерботик.
Но вот не задача, когда пишу команду и он отправляет одну строчку скрипт вылетает, в логе пишет что wait() полная фигня, как мне сделать задержку?
код:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("send1", send1)
    sampRegisterChatCommand("send2", send2)
    sampRegisterChatCommand("send3", send3)
    sampRegisterChatCommand("send4", send4)
    sampRegisterChatCommand("send5", send5)
    while true do
        wait(0)
    end
end

function send1()
    sampSendChat("/fb Подсоединяемся к спец.рации Discord!")
    wait(1200)
    sampSendChat("/fb Там вы найдете всю самую актуальную информацию о банде.")
    wait(1200)
    sampSendChat("/fb Ссылку вы можете найти на форуме!")
end

function send2()
    sampSendChat("/fb Все собираемся на респе, в 00 порт!")
    wait(1200)
    sampSendChat("/fb Заточеные аксы запрещены, обязательно маски и броники!")
    wait(1200)
    sampSendChat("/fb Самые активные получат 8 ранг!")
end

function send3()
    sampSendChat("/fb Собираемся на респе, капт!")
    wait(1200)
    sampSendChat("/fb СК респы грувов нельзя, арморы / маски / заточки / +с НЕЛЬЗЯ")
    wait(1200)
    sampSendChat("/fb Кого увижу за нарушением - сразу же увольняю!")
end

function send4()
    sampSendChat("/fb привет")
    wait(1200)
    sampSendChat("/fb привет")
    wait(1200)
    sampSendChat("/fb привет")
    wait(1200)
    sampSendChat("/fb привет")
    wait(1200)
    sampSendChat("/fb привет")
    wait(1200)
end

function send5()
    sampSendChat("/fb привет")
    wait(1200)
    sampSendChat("/fb привет")
    wait(1200)
    sampSendChat("/fb привет")
    wait(1200)
    sampSendChat("/fb привет")
    wait(1200)
    sampSendChat("/fb привет")
    wait(1200)
end
 

Dmitriy Makarov

25.05.2021
Проверенный
2,479
1,113
Задержку использовать надо в потоке. lua_thread.create
Lua:
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampRegisterChatCommand("send1", send1)
    sampRegisterChatCommand("send2", send2)
    sampRegisterChatCommand("send3", send3)
    sampRegisterChatCommand("send4", send4)
    sampRegisterChatCommand("send5", send5)
    while true do
        wait(0)
    end
end

function send1()
    lua_thread.create(function()
        sampSendChat("/fb Подсоединяемся к спец.рации Discord!")
        wait(1200)
        sampSendChat("/fb Там вы найдете всю самую актуальную информацию о банде.")
        wait(1200)
        sampSendChat("/fb Ссылку вы можете найти на форуме!")
    end)
end

function send2()
    lua_thread.create(function()
        sampSendChat("/fb Все собираемся на респе, в 00 порт!")
        wait(1200)
        sampSendChat("/fb Заточеные аксы запрещены, обязательно маски и броники!")
        wait(1200)
        sampSendChat("/fb Самые активные получат 8 ранг!")
    end)
end

function send3()
    lua_thread.create(function()
        sampSendChat("/fb Собираемся на респе, капт!")
        wait(1200)
        sampSendChat("/fb СК респы грувов нельзя, арморы / маски / заточки / +с НЕЛЬЗЯ")
        wait(1200)
        sampSendChat("/fb Кого увижу за нарушением - сразу же увольняю!")
    end)
end

function send4()
    lua_thread.create(function()
        sampSendChat("/fb привет")
        wait(1200)
        sampSendChat("/fb привет")
        wait(1200)
        sampSendChat("/fb привет")
        wait(1200)
        sampSendChat("/fb привет")
        wait(1200)
        sampSendChat("/fb привет")
        wait(1200)
    end)
end

function send5()
    lua_thread.create(function()
        sampSendChat("/fb привет")
        wait(1200)
        sampSendChat("/fb привет")
        wait(1200)
        sampSendChat("/fb привет")
        wait(1200)
        sampSendChat("/fb привет")
        wait(1200)
        sampSendChat("/fb привет")
        wait(1200)
    end)
end
 
  • Влюблен
  • Bug
Реакции: Dark. и Fott