Как сделать активную вкладку

#SameLine

Активный
Автор темы
421
38
Версия MoonLoader
.026-beta
Как сделать например строка "Текст 1 [ Отключено ], при нажатии на него что-то пишется в чат и выволится уже на строке "Текст 1 [ Включено ]??
 
Решение
Lua:
local act1, act2 = false, false

function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('test', main_menu)
    while true do
        wait(0)
        local result_d, button, list, input = sampHasDialogRespond(6405)
        if result_d then
            if button == 1 then
                if list == 0 then
                    act1 = not act1
                    --main_menu()
                elseif list == 1 then
                    act2 = not act2
                    --main_menu()
                end
            end
        end
    end
end

function main_menu()
    str_main_dialog = string.format([[
Текст 1 %s
Текст 2 %s
]], (act1 and '{33AA33}[Включено]' or '{AA3333}[Выключено]'), (act2 and...

qdIbp

Автор темы
Проверенный
1,450
1,191
Типа так?
Lua:
require "lib.moonloader"
local on = require "lib.samp.events"

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand("xz",aa)
while not isSampAvailable() do wait(100) end
    while true do
        wait(0)
       
    end
end

local da = "выкл"

function aa()
    lua_thread.create(function()
    if da == "вкл" then
        sampShowDialog(6405, "xz", "текст 1 ["..da.."]\nlol", "ok", "neok", DIALOG_STYLE_LIST)
        while sampIsDialogActive(6405) do wait(100) end
        local _, button, list, _ = sampHasDialogRespond(6405)
        da = "выкл"
       
        if button == 1 and list == 0 then
            sampAddChatMessage("da",-1)
            sampShowDialog(6405, "xz", "текст 1 ["..da.."]\nlol", "ok", "neok", DIALOG_STYLE_LIST)  
            return false
        else --выкл
        sampAddChatMessage("dial close",-1)
        end
    end  
   
    if da == "выкл" then
        sampShowDialog(6405, "xz", "текст 1 ["..da.."]\nlol", "ok", "neok", DIALOG_STYLE_LIST)
        while sampIsDialogActive(6405) do wait(100) end
        local _, button, list, _ = sampHasDialogRespond(6405)
        da = "вкл"
       
        if button == 1 and list == 0 then      
            sampAddChatMessage("da",-1)
            sampShowDialog(6405, "xz", "текст 1 ["..da.."]\nlol", "ok", "neok", DIALOG_STYLE_LIST)
            return false
        else --close диалога
        sampAddChatMessage("dial close",-1)
        end              
    end
   
    end)
end
 
Последнее редактирование:
  • Bug
Реакции: PanSeek

PanSeek

t.me/dailypanseek
Всефорумный модератор
910
1,782
Lua:
local act1, act2 = false, false

function main()
    repeat wait(0) until isSampAvailable()
    sampRegisterChatCommand('test', main_menu)
    while true do
        wait(0)
        local result_d, button, list, input = sampHasDialogRespond(6405)
        if result_d then
            if button == 1 then
                if list == 0 then
                    act1 = not act1
                    --main_menu()
                elseif list == 1 then
                    act2 = not act2
                    --main_menu()
                end
            end
        end
    end
end

function main_menu()
    str_main_dialog = string.format([[
Текст 1 %s
Текст 2 %s
]], (act1 and '{33AA33}[Включено]' or '{AA3333}[Выключено]'), (act2 and '{33AA33}[Включено]' or '{AA3333}[Выключено]')
    sampShowDialog(6405, 'Test dialog', str_main_dialog, 'Выбрать', 'Закрыть', 2)
end
Диалог при нажатии на кнопку пропадает, откомментируй закомментируемое, чтобы не пропадал диалог, пока не нажмёшь на "Закрыть".
P.S. Писал с телефона, в больничке, проверить не могу, должно всё работать. Это лучше чем вариант выше.
 
  • Нравится
Реакции: James Saula