Булевые лист айтемы в диалоге

P0M61K

Активный
Автор темы
264
54
Версия MoonLoader
.026-beta
Вроде я не дурак и спокойно могу такое реализовать, но тут появилась одна проблема. Дело в том что мой кодик короче как-то криво работает.
Вот сам код
Lua:
require("lib.moonloader")
require("lib.sampfuncs")
local vkeys = require("vkeys")
function main()
    while not isSampAvailable() do wait(0) end
    while true do
        wait(0)
        activet = active and "{008000}ON" or "{FF0000}OFF"
        listt = listd and "{808080}BlackList" or "{FFFFFF}WhiteList"
        if isKeyJustPressed(vkeys.VK_7) then
            if not sampIsChatInputActive() then
                  sampShowDialog(156, "Название окна", "Статус активности: " .. activet .. "\nРежим уничтожения: " .. listt, "Выбрать", "Закрыть", 2)
            end
        end
          local result, button, list, input = sampHasDialogRespond(156)
        if result then
            sampShowDialog(156, "Название окна", "Статус активности: " .. activet .. "\nРежим уничтожения: " .. listt, "Выбрать", "Закрыть", 2)
            if list == 0 then
                if button == 1 then
                    active = not active
                    wait(10)
                    sampSetCurrentDialogListItem(list)
                end
            elseif list == 1 then
                if button == 1 then
                    listd = not listd
                    wait(10)
                    sampSetCurrentDialogListItem(list)
                end
            end
          end
    end
end

--sampShowDialog(156, "Название окна", "Статус активности: " .. activet .. "\nРежим уничтожения: " .. listt, "Выбрать", "Закрыть", 2)

Например: когда я выбираю в лист айтеме второй пункт то сначала меняется состояние первого а потом второго. И смена первого происходит один раз. После можно сколько угодно менять айтему значение булевое, но все же остается вопрос почему так?
 
Решение
Lua:
require("lib.moonloader")
require("lib.sampfuncs")
local vkeys = require("vkeys")
function main()
    while not isSampAvailable() do wait(0) end
    while true do
        wait(0)
        
        if isKeyJustPressed(vkeys.VK_7) then
            if not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsScoreboardOpen() then
                ShowDialog()
                while sampIsDialogActive() and sampGetCurrentDialogId() == 156 do
                    wait(0)
                    local result, button, list, input = sampHasDialogRespond(156)
                    if result then
                        if button == 1 and list == 0 then
                            active = not active...

meowprd

Тот самый Котовский
Проверенный
1,280
712
Lua:
require("lib.moonloader")
require("lib.sampfuncs")
local vkeys = require("vkeys")
function main()
    while not isSampAvailable() do wait(0) end
    while true do
        wait(0)
        
        if isKeyJustPressed(vkeys.VK_7) then
            if not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsScoreboardOpen() then
                ShowDialog()
                while sampIsDialogActive() and sampGetCurrentDialogId() == 156 do
                    wait(0)
                    local result, button, list, input = sampHasDialogRespond(156)
                    if result then
                        if button == 1 and list == 0 then
                            active = not active
                            sampSetCurrentDialogListItem(0)
                            ShowDialog()
                        end
                        if button == 1 and list == 1 then
                            listd = not listd
                            sampSetCurrentDialogListItem(1)
                            ShowDialog()
                        end
                    end
                end
            end
        end
    end
end
function ShowDialog()
    activet = active and "{008000}ON" or "{FF0000}OFF"
    listt = listd and "{808080}BlackList" or "{FFFFFF}WhiteList"
    sampShowDialog(156, "Window Name", "Статус активности: "..activet.."\nРежим уничтожения: "..listt, 'Choose', 'Close', 2)
end
 
  • Нравится
Реакции: Gorskin и P0M61K