Помощь со скриптом

cloused2

Активный
Автор темы
309
91
Версия MoonLoader
Другое
Можете подсказать? делаю хоткей на клавишу кроме rshift например на ctrl, он не реагирует на него, я после перезапуска вообще сбрасывает до деф rshift

Up, хелпу пожалуйста

Решено:

Решение проблемы:
local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local hotkey = require('mimhotkey') -- подключаем библиотеку

local inicfg = require 'inicfg'
local directIni = 'mimhotkey_example_2.ini'
local ini = inicfg.load(inicfg.load({
    main = {
        lock_keys = '[80]',
        phone_keys = '[76]'
    },
}, directIni))
inicfg.save(ini, directIni)

local renderWindow = imgui.new.bool(true)
local noBindFlood = imgui.new.bool(true)
local Binds = {
    Lock = {
        desc = u8'Бинд на /lock',
        keys = decodeJson(ini.main.lock_keys),
        callback = function()
            if not sampIsCursorActive() then
                sampSendChat('/lock')
                sampAddChatMessage('машина открыта/закрыта', -1)
            end
        end
    },
    Phone = {
        desc = u8'Бинд на /phone',
        keys = decodeJson(ini.main.phone_keys),
        callback = function()
            if not sampIsCursorActive() then
                sampSendChat('/phone')
                sampAddChatMessage('достаю телефон...', -1)
            end
        end
    }
}

local newFrame = imgui.OnFrame(
    function() return renderWindow[0] end,
    function(self)
        if imgui.Begin('mimhotkey example #2', renderWindow) then
            local NewKeys_Lock = hotkey.KeyEditor('Lock', u8'Открать/закрыть машину')
            if NewKeys_Lock then
                sampAddChatMessage('Бинд изменен на: '..hotkey.GetBindKeys(NewKeys_Lock), -1)
                ini.main.lock_keys = encodeJson(NewKeys_Lock)
                inicfg.save(ini, directIni)
            end

            local NewKeys_Phone = hotkey.KeyEditor('Phone', u8'Достать телефон')
            if NewKeys_Phone then
                sampAddChatMessage('Бинд изменен на: '..hotkey.GetBindKeys(NewKeys_Phone), -1)
                ini.main.phone_keys = encodeJson(NewKeys_Phone)
                inicfg.save(ini, directIni)
            end
            if imgui.Checkbox('No key flood', noBindFlood) then
                hotkey.no_flood = noBindFlood[0]
            end
            imgui.End()
        end
    end
)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('mimhk', function()
        renderWindow[0] = not renderWindow[0]
    end)
    hotkey.RegisterCallback('Lock', Binds.Lock.keys, Binds.Lock.callback)
    hotkey.RegisterCallback('Phone', Binds.Phone.keys, Binds.Phone.callback)
    hotkey.Text.wait_for_key = u8'Нажмите клавишу'
    hotkey.Text.no_key = u8'Нет'
    wait(-1)
end
 

Вложения

  • AirBrake.lua
    21.4 KB · Просмотры: 3
Последнее редактирование:
  • Bug
Реакции: minxty