биндер на клавиши (rkeys, imgui.HotKey)

Corrygan228

Участник
Автор темы
132
9
Версия MoonLoader
.027.0-preview
как реализовать биндер по клавише? такой, чтоб можно было назначать клавишу на определенный бинд, смотрел видос у TheChumpGuess, он создает хоткей и функцию, которая будет выполняться этим хоткеем, а мне нужно сделать аналог этого, только с клавишами:
до этого, я просто инпут оставлял вместо хоткея, а щас в тупике
Lua:
--main()
    for k, v in ipairs(buffer) do
        if v.activation == 1 then
            sampRegisterChatCommand(u8:decode(v.command), function()
                lua_thread.create(function()
                    for text in v.multiline.v:gmatch("[^\r\n]+") do
                        sampSendChat(text)
                        wait(2000)
                    end
                end)
            end)
        end
    end
Lua:
                                if imgui.BeginPopupModal('##add_bind', _, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove) then
                                    imgui.SetNextWindowSize(imgui.ImVec2(350, 250))
                                    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
                                    imgui.CenterText(u8'Настройка нового бинда')
                                    imgui.Separator()
                                    imgui.NewLine()
                                    imgui.PushItemWidth(130)
                                    imgui.InputText(u8'Название', whatSave.name)
                                    imgui.PopItemWidth()
                                    imgui.PushItemWidth(130)
                                    imgui.Combo(u8'##Активация', whatSave.activation, {u8"На кнопку", u8"На команду"})
                                    imgui.PopItemWidth()
                                    imgui.SameLine()
                                    if whatSave.activation.v == 1 then
                                        imgui.PushItemWidth(130)     
                                        imgui.InputText(u8'##Команда без /', whatSave.command)
                                        imgui.PopItemWidth()
                                    elseif whatSave.activation.v == 0 then
                                        imgui.PushItemWidth(130)
                                        if imgui.HotKey() then
                                            --че тут писать, хуй пойму
                                        end
                                        imgui.PopItemWidth()
                                    end
                                    imgui.NewLine()
                                    imgui.Separator()
                                    imgui.SetCursorPosX(18)
                                    if imgui.Button(u8'Принять', imgui.ImVec2(120, 30)) then
                                        if whatSave.name.v ~= '' then
                                            if whatSave.activation.v == 1 then
                                                if whatSave.command.v ~= '' then
                                                    table.insert(testJSON, {
                                                        name = u8:decode(whatSave.name.v),
                                                        multiline = u8:decode(whatSave.multiline.v),
                                                        command = u8:decode(whatSave.command.v),
                                                        hotkey = u8:decode(whatSave.hotkey.v),
                                                        activation = whatSave.activation.v,
                                                    }) save()
                                                    table.insert(buffer, {
                                                        name = u8:decode(tostring(whatSave.name.v)),
                                                        multiline = imgui.ImBuffer(tostring(whatSave.multiline.v), 1024),
                                                        command = u8:decode(whatSave.command.v),
                                                        hotkey = u8:decode(whatSave.hotkey.v),
                                                        activation = whatSave.activation.v,
                                                    })
                                                    whatSave = {
                                                        name = imgui.ImBuffer(256),
                                                        multiline = imgui.ImBuffer(256),
                                                        command = imgui.ImBuffer(256),
                                                        hotkey = imgui.ImBuffer(256),
                                                        activation =  imgui.ImInt(0),
                                                    }
                                                    imgui.CloseCurrentPopup()
                                                else
                                                    sampAddChatMessage('{0099FF}[Prison Helper]:' .. white_color .. ' Введите команду для активации бинда!', -1)
                                                    imgui.CloseCurrentPopup()
                                                end
                                            else
                                                if whatSave.hotkey.v ~= '' then
                                                    table.insert(testJSON, {
                                                        name = u8:decode(whatSave.name.v),
                                                        multiline = u8:decode(whatSave.multiline.v),
                                                        command = u8:decode(whatSave.command.v),
                                                        hotkey = u8:decode(whatSave.hotkey.v),
                                                        activation = whatSave.activation.v,
                                                    }) save()
                                                    table.insert(buffer, {
                                                        name = u8:decode(tostring(whatSave.name.v)),
                                                        multiline = imgui.ImBuffer(tostring(whatSave.multiline.v), 1024),
                                                        command = u8:decode(whatSave.command.v),
                                                        hotkey = u8:decode(whatSave.hotkey.v),
                                                        activation = whatSave.activation.v,
                                                    })
                                                    whatSave = {
                                                        name = imgui.ImBuffer(256),
                                                        multiline = imgui.ImBuffer(256),
                                                        command = imgui.ImBuffer(256),
                                                        hotkey = imgui.ImBuffer(256),
                                                        activation =  imgui.ImInt(0),
                                                    }
                                                    imgui.CloseCurrentPopup()
                                                else
                                                    sampAddChatMessage('{0099FF}[Prison Helper]:' .. white_color .. ' Укажите клавишу для активации бинда!', -1)
                                                    imgui.CloseCurrentPopup()
                                                end
                                            end
                                        else
                                            sampAddChatMessage('{0099FF}[Prison Helper]:' .. white_color .. ' Укажите название бинда!', -1)
                                            imgui.CloseCurrentPopup()
                                        end
                                    end
                                    imgui.SameLine()
                                    imgui.SetCursorPosX(178)
                                    if imgui.Button(u8'Отмена', imgui.ImVec2(120, 30)) then
                                        imgui.CloseCurrentPopup()
                                    end
                                    imgui.EndPopup()
                                end
 

Wycmpblu

Известный
143
31
Мб это поможет
 

shawtyglock.

Активный
166
31

1702747597806.png

Эта часть в мэйне до беск цикла
 
Последнее редактирование: