диалоги

лион из бровл сторс

Участник
Автор темы
140
13
Версия MoonLoader
.026-beta
Как сделать, чтоб при выборе в 1-ом диалоге пункта "Неподчинение", открывалось другое диалоговое окно и там уже можно было выбирать нужный пункт, и он выполнялся? Нашел какой то код, попытался переделать, но при нажатии в 1-ом диалоге на пункт "что" открывается другое диалоговое окно и сразу кидается сообщение " ааааааааааааааааа ", хотя оно должно кидаться в зависимости от выбора во 2-ом диалоге

Lua:
require "lib.moonloader"

function main()

        while not isSampAvailable() do wait(0) end
    
            sampRegisterChatCommand("sum", sushka)
            sampAddChatMessage("Loaded", -1)
            
        while true do
        wait(0)
        
        local result, button, list, input = sampHasDialogRespond(1999)
                if result then
                    if button == 1 and list == 0 then
                            lua_thread.create(function()
                                sampShowDialog(1999, "{0000ff}Helper", string.format("{FFFFFF}1. да\nнет"), "Выбрать", "Отмена", 2)
                                   if button == 1 and list == 0 then
                                    sampSendChat('ааааааааааааааааа')
                                end
                            end)
                        end
                        if button == 1 and list == 1 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 2 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 3 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 4 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 5 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 6 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 7 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 8 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 9 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 10 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 0 then
                        sampCloseCurrentDialogWithButton(0)
                        end
                    end
                end
end



function sushka()
    sampShowDialog(1999, "{0000ff}Helper", string.format("{FFFFFF}1. что\nИ так далее"), "Выбрать", "Отмена", 2)
    end
 

лион из бровл сторс

Участник
Автор темы
140
13
Делал то, что тебя интересует в этом скрипте по ссылке, а именно открытие окна по пункту из меню другого окна и без кучи потоков, которые у тебя используются не по назначению.
бля там много всего, еще и на переменных. Ниче не понимаю(
 

Dmitriy Makarov

25.05.2021
Проверенный
2,484
1,114
Как сделать, чтоб при выборе в 1-ом диалоге пункта "Неподчинение", открывалось другое диалоговое окно и там уже можно было выбирать нужный пункт, и он выполнялся? Нашел какой то код, попытался переделать, но при нажатии в 1-ом диалоге на пункт "что" открывается другое диалоговое окно и сразу кидается сообщение " ааааааааааааааааа ", хотя оно должно кидаться в зависимости от выбора во 2-ом диалоге

Lua:
require "lib.moonloader"

function main()

        while not isSampAvailable() do wait(0) end
   
            sampRegisterChatCommand("sum", sushka)
            sampAddChatMessage("Loaded", -1)
           
        while true do
        wait(0)
       
        local result, button, list, input = sampHasDialogRespond(1999)
                if result then
                    if button == 1 and list == 0 then
                            lua_thread.create(function()
                                sampShowDialog(1999, "{0000ff}Helper", string.format("{FFFFFF}1. да\nнет"), "Выбрать", "Отмена", 2)
                                   if button == 1 and list == 0 then
                                    sampSendChat('ааааааааааааааааа')
                                end
                            end)
                        end
                        if button == 1 and list == 1 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 2 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 3 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 4 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 5 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 6 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 7 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 8 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 9 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 1 and list == 10 then
                            lua_thread.create(function()
                            end)
                        end
                        if button == 0 then
                        sampCloseCurrentDialogWithButton(0)
                        end
                    end
                end
end



function sushka()
    sampShowDialog(1999, "{0000ff}Helper", string.format("{FFFFFF}1. что\nИ так далее"), "Выбрать", "Отмена", 2)
    end
Простой пример.
Lua:
function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("dlg", function()
        sampShowDialog(110, "Title №1", "List 1", "Select", "Close", 2)
    end)
    
    while true do wait(0)
        local result, button, list, input = sampHasDialogRespond(110)
        if result then
            if button == 1 and list == 0 then -- list 0 — 1-я строка.
                sampShowDialog(111, "Title №2", "Click me", "Select", "Close", 2)
            end
        end

        local result, button, list, input = sampHasDialogRespond(111)
        if result then
            if button == 1 and list 0 then
                sampAddChatMessage("Нажата 1-я строчка", -1)
            end
        end
    end
end
 

лион из бровл сторс

Участник
Автор темы
140
13
Простой пример.
Lua:
function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("dlg", function()
        sampShowDialog(110, "Title №1", "List 1", "Select", "Close", 2)
    end)
   
    while true do wait(0)
        local result, button, list, input = sampHasDialogRespond(110)
        if result then
            if button == 1 and list == 0 then -- list 0 — 1-я строка.
                sampShowDialog(111, "Title №2", "Click me", "Select", "Close", 2)
            end
        end

        local result, button, list, input = sampHasDialogRespond(111)
        if result then
            if button == 1 and list 0 then
                sampAddChatMessage("Нажата 1-я строчка", -1)
            end
        end
    end
end
[ML] (error) new.lua: D:\DEFAULT GTA SA WITH FIX MEDIUM PC\moonloader\new.lua:19: 'then' expected near '0'
[ML] (error) new.lua: Script died due to an error. (1CB336BC)
И что делать
 

Dmitriy Makarov

25.05.2021
Проверенный
2,484
1,114
Забыл "==" поставить.
Lua:
function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("dlg", function()
        sampShowDialog(110, "Title №1", "List 1", "Select", "Close", 2)
    end)
    
    while true do wait(0)
        local result, button, list, input = sampHasDialogRespond(110)
        if result then
            if button == 1 and list == 0 then -- list 0 — 1-я строка.
                sampShowDialog(111, "Title №2", "Click me", "Select", "Close", 2)
            end
        end

        local result, button, list, input = sampHasDialogRespond(111)
        if result then
            if button == 1 and list == 0 then
                sampAddChatMessage("Нажата 1-я строчка", -1)
            end
        end
    end
end
 

лион из бровл сторс

Участник
Автор темы
140
13
Забыл "==" поставить.
Lua:
function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("dlg", function()
        sampShowDialog(110, "Title №1", "List 1", "Select", "Close", 2)
    end)
   
    while true do wait(0)
        local result, button, list, input = sampHasDialogRespond(110)
        if result then
            if button == 1 and list == 0 then -- list 0 — 1-я строка.
                sampShowDialog(111, "Title №2", "Click me", "Select", "Close", 2)
            end
        end

        local result, button, list, input = sampHasDialogRespond(111)
        if result then
            if button == 1 and list == 0 then
                sampAddChatMessage("Нажата 1-я строчка", -1)
            end
        end
    end
end
Lua:
function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("dlg", function()
        sampShowDialog(110, "Title №1", "List 1", "Select", "Close", 2)
    end)
    
    while true do wait(0)
        local result, button, list, input = sampHasDialogRespond(110)
        if result then
            if button == 1 and list == 0 then -- list 0 — 1-я строка.
                sampShowDialog(111, "Title №2", "Click me\nClick me 2", "Select", "Close", 2)
            end
        end

        local result, button, list, input = sampHasDialogRespond(111)
        if result then
            if button == 1 and list == 0 then
                sampAddChatMessage("Нажата 1-я строчка", -1)
            end
        end

        local result, button, list, input = sampHasDialogRespond(111)
        if result then
            if button == 1 and list == 1 then
                sampAddChatMessage("Нажата 2-я строчка", -1)
            end
        end
    end
end

"Click me 2" не работает. Тупо диалог закрывается
 

Dmitriy Makarov

25.05.2021
Проверенный
2,484
1,114
Неправильно делаешь, поэтому и не работает..
Lua:
function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("dlg", function()
        sampShowDialog(110, "Title №1", "List 1", "Select", "Close", 2)
    end)
    
    while true do wait(0)
        local result, button, list, input = sampHasDialogRespond(110)
        if result then
            if button == 1 and list == 0 then -- list 0 — 1-я строка.
                sampShowDialog(111, "Title №2", "Click me\nClick me 2", "Select", "Close", 2)
            end
        end

        local result, button, list, input = sampHasDialogRespond(111)
        if result then
            if button == 1 then
                if list == 0 then
                    sampAddChatMessage("Нажата 1-я строчка", -1)
                elseif list == 1 then
                    sampAddChatMessage("Нажата 2-я строчка", -1)
                end
            end
        end
    end
end
 

лион из бровл сторс

Участник
Автор темы
140
13
Неправильно делаешь, поэтому и не работает..
Lua:
function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand("dlg", function()
        sampShowDialog(110, "Title №1", "List 1", "Select", "Close", 2)
    end)
  
    while true do wait(0)
        local result, button, list, input = sampHasDialogRespond(110)
        if result then
            if button == 1 and list == 0 then -- list 0 — 1-я строка.
                sampShowDialog(111, "Title №2", "Click me\nClick me 2", "Select", "Close", 2)
            end
        end

        local result, button, list, input = sampHasDialogRespond(111)
        if result then
            if button == 1 then
                if list == 0 then
                    sampAddChatMessage("Нажата 1-я строчка", -1)
                elseif list == 1 then
                    sampAddChatMessage("Нажата 2-я строчка", -1)
                end
            end
        end
    end
end
А как еще сделать аргументы? Допустим вводишь /dlg 63, выбираешь там пункты и в чат пишет "Аргумент 63"
p.s извините, я не кодер