Вопросы по Lua скриптингу

Общая тема для вопросов по разработке скриптов на языке программирования Lua, в частности под MoonLoader.
  • Задавая вопрос, убедитесь, что его нет в списке частых вопросов и что на него ещё не отвечали (воспользуйтесь поиском).
  • Поищите ответ в теме посвященной разработке Lua скриптов в MoonLoader
  • Отвечая, убедитесь, что ваш ответ корректен.
  • Старайтесь как можно точнее выразить мысль, а если проблема связана с кодом, то обязательно прикрепите его к сообщению, используя блок [code=lua]здесь мог бы быть ваш код[/code].
  • Если вопрос связан с MoonLoader-ом первым делом желательно поискать решение на wiki.

Частые вопросы

Как научиться писать скрипты? С чего начать?
Информация - Гайд - Всё о Lua скриптинге для MoonLoader(https://blast.hk/threads/22707/)
Как вывести текст на русском? Вместо русского текста у меня какие-то каракули.
Изменить кодировку файла скрипта на Windows-1251. В Atom: комбинация клавиш Ctrl+Shift+U, в Notepad++: меню Кодировки -> Кодировки -> Кириллица -> Windows-1251.
Как получить транспорт, в котором сидит игрок?
Lua:
local veh = storeCarCharIsInNoSave(PLAYER_PED)
Как получить свой id или id другого игрока?
Lua:
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED) -- получить свой ид
local _, id = sampGetPlayerIdByCharHandle(ped) -- получить ид другого игрока. ped - это хендл персонажа
Как проверить, что строка содержит какой-то текст?
Lua:
if string.find(str, 'текст', 1, true) then
-- строка str содержит "текст"
end
Как эмулировать нажатие игровой клавиши?
Lua:
local game_keys = require 'game.keys' -- где-нибудь в начале скрипта вне функции main

setGameKeyState(game_keys.player.FIREWEAPON, -1) -- будет сэмулировано нажатие клавиши атаки
Все иды клавиш находятся в файле moonloader/lib/game/keys.lua.
Подробнее о функции setGameKeyState здесь: lua - setgamekeystate | BlastHack — DEV_WIKI(https://www.blast.hk/wiki/lua:setgamekeystate)
Как получить id другого игрока, в которого целюсь я?
Lua:
local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE) -- получить хендл персонажа, в которого целится игрок
if valid and doesCharExist(ped) then -- если цель есть и персонаж существует
  local result, id = sampGetPlayerIdByCharHandle(ped) -- получить samp-ид игрока по хендлу персонажа
  if result then -- проверить, прошло ли получение ида успешно
    -- здесь любые действия с полученным идом игрока
  end
end
Как зарегистрировать команду чата SAMP?
Lua:
-- До бесконечного цикла/задержки
sampRegisterChatCommand("mycommand", function (param)
     -- param будет содержать весь текст введенный после команды, чтобы разделить его на аргументы используйте string.match()
    sampAddChatMessage("MyCMD", -1)
end)
Крашит игру при вызове sampSendChat. Как это исправить?
Это происходит из-за бага в SAMPFUNCS, когда производится попытка отправки пакета определенными функциями изнутри события исходящих RPC и пакетов. Исправления для этого бага нет, но есть способ не провоцировать его. Вызов sampSendChat изнутри обработчика исходящих RPC/пакетов нужно обернуть в скриптовый поток с нулевой задержкой:
Lua:
function onSendRpc(id)
  -- крашит:
  -- sampSendChat('Send RPC: ' .. id)

  -- норм:
  lua_thread.create(function()
    wait(0)
    sampSendChat('Send RPC: ' .. id)
  end)
end
 
Последнее редактирование:

Smeruxa

smeruxa.ru
Проверенный
1,431
800
Как сделать так, чтобы при нажатии лкм - ЛКМ не нажималось, ну т.е. кулаком не било? ( По переменной, т.е. если переменная то запретить если нет то разрешить )
 

PanSeek

t.me/dailypanseek
Всефорумный модератор
912
1,801
А какую именно нужно?
Которую нужно вызывать, логично, нет?
а куда его вписывать?
Там где нужно тебе использовать.

Я не пойму как ты это написал, если не знаешь такие базовые вещи. Я не наезжаю, тут можно задать любой вопрос, но ты их не правильно строишь и в некоторых моментах нужно самому посмотреть как и что работает, чтоб сам понимал.
Lua:
script_name('VRManager')
script_author('Sanchez.')
script_description('Piar for VR Chat')

require 'lib.moonloader'
local encoding = require 'encoding'
local inicfg = require 'inicfg'
local imgui = require 'imgui'
local ia = require 'imgui_addons'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local mainIni = inicfg.load({
    config = {
        piar = false,
        textpiar = "",
        delay = 0,
    }
}, "VRManager")

-- imgui vars
local main_window_state = imgui.ImBool(false)
local piar = imgui.ImBool(mainIni.config.piar)
local textpiar = imgui.ImBuffer(tostring(mainIni.config.textpiar), 300)
local delay = imgui.ImInt(mainIni.config.delay)
-- other vars
local sw, sh = getScreenResolution()
local tag = "{FF0000}VR{FFFFFF}Manager: "

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    if not doesFileExist('moonloader/config/VRManager.ini') then inicfg.save(mainIni, 'VRManager.ini') end

    sampAddChatMessage(tag .. "Автор: Sanchez. Открытие меню: /vm", -1)
    sampRegisterChatCommand("vm", function() main_window_state.v = not main_window_state.v end)

    while true do
        wait(0)
        imgui.Process = main_window_state.v
        if piar.v then
            wait(mainIni.config.delay)
            sampSendChat(u8:decode(mainIni.config.textpiar))
        end
    end
end

function imgui.OnDrawFrame()
    imgui.SetNextWindowSize(imgui.ImVec2(335, 205), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

    imgui.Begin(u8"Авто-реклама /vr", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoMove)
    ia.ToggleButton("##active", piar) imgui.SameLine() imgui.Text(u8"Включить авто-пиар")
    imgui.Separator()
    imgui.PushItemWidth(200)
    imgui.InputText(u8"<< Ваша реклама", textpiar)
    imgui.PopItemWidth()
    imgui.PushItemWidth(100)
    imgui.InputInt('', delay)
    imgui.PopItemWidth()
    imgui.SameLine() imgui.Text(u8"(Задержка в миллисекундах)")
    if imgui.Button(u8"Сохранить настройки") then
        save()
        sampAddChatMessage(tag .. "Настройки сохранены!",-1)
    end
    imgui.End()
end

function theme()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    local ImVec2 = imgui.ImVec2

    style.WindowPadding = imgui.ImVec2(8, 8)
    style.WindowRounding = 6
    style.ChildWindowRounding = 5
    style.FramePadding = imgui.ImVec2(5, 3)
    style.FrameRounding = 3.0
    style.ItemSpacing = imgui.ImVec2(5, 4)
    style.ItemInnerSpacing = imgui.ImVec2(4, 4)
    style.IndentSpacing = 21
    style.ScrollbarSize = 10.0
    style.ScrollbarRounding = 13
    style.GrabMinSize = 8
    style.GrabRounding = 1
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)

    colors[clr.Text]                   = ImVec4(0.95, 0.96, 0.98, 1.00);
    colors[clr.TextDisabled]           = ImVec4(0.29, 0.29, 0.29, 1.00);
    colors[clr.WindowBg]               = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.ChildWindowBg]          = ImVec4(0.12, 0.12, 0.12, 1.00);
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94);
    colors[clr.Border]                 = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.BorderShadow]           = ImVec4(1.00, 1.00, 1.00, 0.10);
    colors[clr.FrameBg]                = ImVec4(0.22, 0.22, 0.22, 1.00);
    colors[clr.FrameBgHovered]         = ImVec4(0.18, 0.18, 0.18, 1.00);
    colors[clr.FrameBgActive]          = ImVec4(0.09, 0.12, 0.14, 1.00);
    colors[clr.TitleBg]                = ImVec4(0.14, 0.14, 0.14, 0.81);
    colors[clr.TitleBgActive]          = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51);
    colors[clr.MenuBarBg]              = ImVec4(0.20, 0.20, 0.20, 1.00);
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.39);
    colors[clr.ScrollbarGrab]          = ImVec4(0.36, 0.36, 0.36, 1.00);
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.18, 0.22, 0.25, 1.00);
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.24, 0.24, 0.24, 1.00);
    colors[clr.ComboBg]                = ImVec4(0.24, 0.24, 0.24, 1.00);
    colors[clr.CheckMark]              = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.SliderGrab]             = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.SliderGrabActive]       = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.Button]                 = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.ButtonHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.ButtonActive]           = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.Header]                 = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.HeaderHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.HeaderActive]           = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.ResizeGrip]             = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.ResizeGripHovered]      = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.ResizeGripActive]       = ImVec4(1.00, 0.19, 0.19, 1.00);
    colors[clr.CloseButton]            = ImVec4(0.40, 0.39, 0.38, 0.16);
    colors[clr.CloseButtonHovered]     = ImVec4(0.40, 0.39, 0.38, 0.39);
    colors[clr.CloseButtonActive]      = ImVec4(0.40, 0.39, 0.38, 1.00);
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00);
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00);
    colors[clr.PlotHistogram]          = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.18, 0.18, 1.00);
    colors[clr.TextSelectedBg]         = ImVec4(1.00, 0.32, 0.32, 1.00);
    colors[clr.ModalWindowDarkening]   = ImVec4(0.26, 0.26, 0.26, 0.60);
end
theme()

function save()
    mainIni.config.piar = piar.v
    mainIni.config.textpiar = textpiar.v
    mainIni.config.delay = delay.v
    inicfg.save(mainIni, "VRManager.ini")
end
Реализация кстати говоря, не из лучших, как по мне. Чутка подправил скрипт в некоторых местах. Реализация осталась такая же
 

Sanchez.

Известный
704
190
Которую нужно вызывать, логично, нет?

Там где нужно тебе использовать.

Я не пойму как ты это написал, если не знаешь такие базовые вещи. Я не наезжаю, тут можно задать любой вопрос, но ты их не правильно строишь и в некоторых моментах нужно самому посмотреть как и что работает, чтоб сам понимал.
Lua:
script_name('VRManager')
script_author('Sanchez.')
script_description('Piar for VR Chat')

require 'lib.moonloader'
local encoding = require 'encoding'
local inicfg = require 'inicfg'
local imgui = require 'imgui'
local ia = require 'imgui_addons'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local mainIni = inicfg.load({
    config = {
        piar = false,
        textpiar = "",
        delay = 0,
    }
}, "VRManager")

-- imgui vars
local main_window_state = imgui.ImBool(false)
local piar = imgui.ImBool(mainIni.config.piar)
local textpiar = imgui.ImBuffer(tostring(mainIni.config.textpiar), 300)
local delay = imgui.ImInt(mainIni.config.delay)
-- other vars
local sw, sh = getScreenResolution()
local tag = "{FF0000}VR{FFFFFF}Manager: "

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    if not doesFileExist('moonloader/config/VRManager.ini') then inicfg.save(mainIni, 'VRManager.ini') end

    sampAddChatMessage(tag .. "Автор: Sanchez. Открытие меню: /vm", -1)
    sampRegisterChatCommand("vm", function() main_window_state.v = not main_window_state.v end)

    while true do
        wait(0)
        imgui.Process = main_window_state.v
        if piar.v then
            wait(mainIni.config.delay)
            sampSendChat(u8:decode(mainIni.config.textpiar))
        end
    end
end

function imgui.OnDrawFrame()
    imgui.SetNextWindowSize(imgui.ImVec2(335, 205), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

    imgui.Begin(u8"Авто-реклама /vr", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoMove)
    ia.ToggleButton("##active", piar) imgui.SameLine() imgui.Text(u8"Включить авто-пиар")
    imgui.Separator()
    imgui.PushItemWidth(200)
    imgui.InputText(u8"<< Ваша реклама", textpiar)
    imgui.PopItemWidth()
    imgui.PushItemWidth(100)
    imgui.InputInt('', delay)
    imgui.PopItemWidth()
    imgui.SameLine() imgui.Text(u8"(Задержка в миллисекундах)")
    if imgui.Button(u8"Сохранить настройки") then
        save()
        sampAddChatMessage(tag .. "Настройки сохранены!",-1)
    end
    imgui.End()
end

function theme()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    local ImVec2 = imgui.ImVec2

    style.WindowPadding = imgui.ImVec2(8, 8)
    style.WindowRounding = 6
    style.ChildWindowRounding = 5
    style.FramePadding = imgui.ImVec2(5, 3)
    style.FrameRounding = 3.0
    style.ItemSpacing = imgui.ImVec2(5, 4)
    style.ItemInnerSpacing = imgui.ImVec2(4, 4)
    style.IndentSpacing = 21
    style.ScrollbarSize = 10.0
    style.ScrollbarRounding = 13
    style.GrabMinSize = 8
    style.GrabRounding = 1
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
    style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)

    colors[clr.Text]                   = ImVec4(0.95, 0.96, 0.98, 1.00);
    colors[clr.TextDisabled]           = ImVec4(0.29, 0.29, 0.29, 1.00);
    colors[clr.WindowBg]               = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.ChildWindowBg]          = ImVec4(0.12, 0.12, 0.12, 1.00);
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94);
    colors[clr.Border]                 = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.BorderShadow]           = ImVec4(1.00, 1.00, 1.00, 0.10);
    colors[clr.FrameBg]                = ImVec4(0.22, 0.22, 0.22, 1.00);
    colors[clr.FrameBgHovered]         = ImVec4(0.18, 0.18, 0.18, 1.00);
    colors[clr.FrameBgActive]          = ImVec4(0.09, 0.12, 0.14, 1.00);
    colors[clr.TitleBg]                = ImVec4(0.14, 0.14, 0.14, 0.81);
    colors[clr.TitleBgActive]          = ImVec4(0.14, 0.14, 0.14, 1.00);
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51);
    colors[clr.MenuBarBg]              = ImVec4(0.20, 0.20, 0.20, 1.00);
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.39);
    colors[clr.ScrollbarGrab]          = ImVec4(0.36, 0.36, 0.36, 1.00);
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.18, 0.22, 0.25, 1.00);
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.24, 0.24, 0.24, 1.00);
    colors[clr.ComboBg]                = ImVec4(0.24, 0.24, 0.24, 1.00);
    colors[clr.CheckMark]              = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.SliderGrab]             = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.SliderGrabActive]       = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.Button]                 = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.ButtonHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.ButtonActive]           = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.Header]                 = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.HeaderHovered]          = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.HeaderActive]           = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.ResizeGrip]             = ImVec4(1.00, 0.28, 0.28, 1.00);
    colors[clr.ResizeGripHovered]      = ImVec4(1.00, 0.39, 0.39, 1.00);
    colors[clr.ResizeGripActive]       = ImVec4(1.00, 0.19, 0.19, 1.00);
    colors[clr.CloseButton]            = ImVec4(0.40, 0.39, 0.38, 0.16);
    colors[clr.CloseButtonHovered]     = ImVec4(0.40, 0.39, 0.38, 0.39);
    colors[clr.CloseButtonActive]      = ImVec4(0.40, 0.39, 0.38, 1.00);
    colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00);
    colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00);
    colors[clr.PlotHistogram]          = ImVec4(1.00, 0.21, 0.21, 1.00);
    colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.18, 0.18, 1.00);
    colors[clr.TextSelectedBg]         = ImVec4(1.00, 0.32, 0.32, 1.00);
    colors[clr.ModalWindowDarkening]   = ImVec4(0.26, 0.26, 0.26, 0.60);
end
theme()

function save()
    mainIni.config.piar = piar.v
    mainIni.config.textpiar = textpiar.v
    mainIni.config.delay = delay.v
    inicfg.save(mainIni, "VRManager.ini")
end
Реализация кстати говоря, не из лучших, как по мне. Чутка подправил скрипт в некоторых местах. Реализация осталась такая же
Я знаю базовые вещи, просто я думал что нужно для нее отдельную функцию писать. И я тупой думал что только можно 1 раз wait() написать в цикле, и потом понял, что я даун и в main() можно использовать wait(). Спасибо за помощь, буду внимательней
 

chapo

tg/inst: @moujeek
Всефорумный модератор
9,240
12,658
Блять я никого не копировал. Просто объясни, что мне щас сделать чтобы заработал авто-пиар. Пожалуйста
один сука вопрос: как и нахуя ты написал отдельную функцию для флуда, если ты не знаешь как ее вызывать?
 

PanSeek

t.me/dailypanseek
Всефорумный модератор
912
1,801
Я знаю базовые вещи, просто я думал что нужно для нее отдельную функцию писать. И я тупой думал что только можно 1 раз wait() написать в цикле, и потом понял, что я даун и в main() можно использовать wait(). Спасибо за помощь, буду внимательней
Можно писать отдельную функцию, можно не писать. Это как захочешь только ты. Как будет тебе удобнее. Но если она используется один раз и это не хук, то для таких надобностей, которые используешь ты - не вижу смысла использовать функции.
Насчет while true do, я написал ранее, что реализация не из лучших и можно сделать по-другому. Но прорабатывать логику и остальные вещи не буду. Я лишь помог, чтоб работало и чтоб ты +- понимал. Может быть потом исправлю по надобности.
 

SurnikSur

Активный
283
40
у меня есть диалог с информацией как выводить в чат определённую информацию с этого диалога?
 

W1ll04eison

Известный
330
19
Lua:
require "lib.moonloader"
local encoding = require "encoding"
local inicfg = require "inicfg"
local directIni = "moonloader\\Note.ini"
local sampev = require "lib.samp.events"
local imgui = require "imgui"
local fa = require 'fAwesome5'
imgui.ToggleButton = require('imgui_addons').ToggleButton
encoding.default = 'CP1251'
u8 = encoding.UTF8

if not doesFileExist("moonloader\\Note.ini")
 then
  file = io.open("moonloader\\Note.ini", "a")
  for i = 1, 2 do
   file:write("[" .. i .. "]\n" .. "name=Заметка №" .. i .. "\ntable=0\ntext1=\ntext2=\ntext3=\ntext4=\ntext5=\n")
  end
  file:close()
end
local mainIni = inicfg.load(nil, directIni)

function apply_custom_style()
 imgui.SwitchContext()
 local style = imgui.GetStyle()
 local colors = style.Colors
 local clr = imgui.Col
 local ImVec4 = imgui.ImVec4
 style.WindowRounding = 2.0
 style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
 style.ChildWindowRounding = 2.0
 style.FrameRounding = 2.0
 style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
 style.ScrollbarSize = 13.0
 style.ScrollbarRounding = 0
 style.GrabMinSize = 8.0
 style.GrabRounding = 1.0
 colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
 colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
 colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
 colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
 colors[clr.TitleBgActive]          = ImVec4(0.16, 0.29, 0.48, 1.00)
 colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
 colors[clr.CheckMark]              = ImVec4(0.26, 0.59, 0.98, 1.00)
 colors[clr.SliderGrab]             = ImVec4(0.24, 0.52, 0.88, 1.00)
 colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.59, 0.98, 1.00)
 colors[clr.Button]                 = ImVec4(0.26, 0.59, 0.98, 0.40)
 colors[clr.ButtonHovered]          = ImVec4(0.26, 0.59, 0.98, 1.00)
 colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
 colors[clr.Header]                 = ImVec4(0.26, 0.59, 0.98, 0.31)
 colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
 colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
 colors[clr.Separator]              = colors[clr.Border]
 colors[clr.SeparatorHovered]       = ImVec4(0.26, 0.59, 0.98, 0.78)
 colors[clr.SeparatorActive]        = ImVec4(0.26, 0.59, 0.98, 1.00)
 colors[clr.ResizeGrip]             = ImVec4(0.26, 0.59, 0.98, 0.25)
 colors[clr.ResizeGripHovered]      = ImVec4(0.26, 0.59, 0.98, 0.67)
 colors[clr.ResizeGripActive]       = ImVec4(0.26, 0.59, 0.98, 0.95)
 colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.59, 0.98, 0.35)
 colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
 colors[clr.TextDisabled]           = ImVec4(0.50, 0.50, 0.50, 1.00)
 colors[clr.WindowBg]               = ImVec4(0.06, 0.06, 0.06, 0.94)
 colors[clr.ChildWindowBg]          = ImVec4(1.00, 1.00, 1.00, 0.00)
 colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
 colors[clr.ComboBg]                = colors[clr.PopupBg]
 colors[clr.Border]                 = ImVec4(0.43, 0.43, 0.50, 0.50)
 colors[clr.BorderShadow]           = ImVec4(0.00, 0.00, 0.00, 0.00)
 colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 1.00)
 colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.53)
 colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 1.00)
 colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 1.00)
 colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 1.00)
 colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 0.50)
 colors[clr.CloseButtonHovered]     = ImVec4(0.98, 0.39, 0.36, 1.00)
 colors[clr.CloseButtonActive]      = ImVec4(0.98, 0.39, 0.36, 1.00)
 colors[clr.PlotLines]              = ImVec4(0.61, 0.61, 0.61, 1.00)
 colors[clr.PlotLinesHovered]       = ImVec4(1.00, 0.43, 0.35, 1.00)
 colors[clr.PlotHistogram]          = ImVec4(0.90, 0.70, 0.00, 1.00)
 colors[clr.PlotHistogramHovered]   = ImVec4(1.00, 0.60, 0.00, 1.00)
 colors[clr.ModalWindowDarkening]   = ImVec4(0.80, 0.80, 0.80, 0.35)
end
apply_custom_style()

imgui.Process = true
imgui_active = imgui.ImBool(false)
local w, h = getScreenResolution()

local slot = 0

local name = imgui.ImBuffer(20)
local combo  = imgui.ImInt(0)
local text1 = imgui.ImBuffer(65536)
local text2 = imgui.ImBuffer(65536)
local text3 = imgui.ImBuffer(65536)
local text4 = imgui.ImBuffer(65536)
local text5 = imgui.ImBuffer(65536)

sampRegisterChatCommand("note", function()
 imgui_active.v = not imgui_active.v
 imgui.Process = imgui_active.v
end)

local fa_font = nil
local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
function imgui.BeforeDrawFrame()
 if fa_font == nil
  then
   local font_config = imgui.ImFontConfig()
   font_config.MergeMode = true
   fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/lib/fa-solid-900.ttf', 13.0, font_config, fa_glyph_ranges)
 end
end

function main()
 if not isSampLoaded() or not isSampfuncsLoaded()
  then
   return
 end
  while not isSampAvailable() do wait(100) end
   sampAddChatMessage("[Note] {FFFFFF}Загружен Автор: {FF9933}Artem_Williams", 0x3399FF)
  while true do
   wait(0)
  end
end

function imgui.OnDrawFrame()
 if imgui_active.v
  then
   imgui.SetNextWindowSize(imgui.ImVec2(750, 500), imgui.Cond.FirstUseEver)
   imgui.SetNextWindowPos(imgui.ImVec2(w / 2, h / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
   imgui.Begin(fa.ICON_FA_ENVELOPE_OPEN_TEXT .. u8" Заметки", imgui_active, imgui.WindowFlags.NoResize)
   imgui.BeginChild("", imgui.ImVec2(150, 464), true)
   for i = 1, 2 do
    if imgui.Selectable(u8(mainIni[i].name))
     then
      name.v = u8(mainIni[i].name)
      combo.v = mainIni[i].table
      text1.v = string.gsub(u8(mainIni[i].text1), "&", "\n")
      text2.v = string.gsub(u8(mainIni[i].text2), "&", "\n")
      text3.v = string.gsub(u8(mainIni[i].text3), "&", "\n")
      text4.v = string.gsub(u8(mainIni[i].text4), "&", "\n")
      text5.v = string.gsub(u8(mainIni[i].text5), "&", "\n")
      slot = i
    end   
   end
   imgui.EndChild()
   imgui.SameLine()
   imgui.BeginChild(" ", imgui.ImVec2(579, 464), true)
   if slot ~= 0
    then
     imgui.Text(u8"Название:")
     imgui.SameLine()
     imgui.PushItemWidth(150)
     imgui.InputText(u8"Столбцы:", name)
     imgui.SameLine()
     imgui.PushItemWidth(40)
     imgui.Combo("  ", combo, {"1", "2", "3", "4", "5"})
     imgui.PopItemWidth(2)
     imgui.SameLine(331)
     if imgui.Button(fa.ICON_FA_SAVE .. u8" Сохранить", imgui.ImVec2(125, 20))
      then
       mainIni[slot].name = u8:decode(name.v)
       mainIni[slot].table = combo.v
       mainIni[slot].text1 = string.gsub(u8:decode(text1.v), "\n", "&")
       mainIni[slot].text2 = string.gsub(u8:decode(text2.v), "\n", "&")
       mainIni[slot].text3 = string.gsub(u8:decode(text3.v), "\n", "&")
       mainIni[slot].text4 = string.gsub(u8:decode(text4.v), "\n", "&")
       mainIni[slot].text5 = string.gsub(u8:decode(text5.v), "\n", "&")
       inicfg.save(mainIni, directIni)
       sampAddChatMessage('[Note] {FFFFFF}Заметка "' .. u8:decode(name.v) .. '" сохранена.', 0x3399FF)
     end
     if combo.v == 0 then
      imgui.InputTextMultiline("    ", text1, imgui.ImVec2(562, 423))
     elseif combo.v == 1 then
      imgui.InputTextMultiline("    ", text1, imgui.ImVec2(279, 423))
      imgui.SameLine()
      imgui.InputTextMultiline("     ", text2, imgui.ImVec2(279, 423))
     elseif combo.v == 2 then
      imgui.InputTextMultiline("    ", text1, imgui.ImVec2(184, 423))
      imgui.SameLine()
      imgui.InputTextMultiline("     ", text2, imgui.ImVec2(184, 423))
      imgui.SameLine()
      imgui.InputTextMultiline("      ", text3, imgui.ImVec2(184, 423))
     elseif combo.v == 3 then
      imgui.InputTextMultiline("    ", text1, imgui.ImVec2(137, 423))
      imgui.SameLine()
      imgui.InputTextMultiline("     ", text2, imgui.ImVec2(137, 423))
      imgui.SameLine()
      imgui.InputTextMultiline("      ", text3, imgui.ImVec2(137, 423))
      imgui.SameLine()
      imgui.InputTextMultiline("       ", text4, imgui.ImVec2(137, 423))
     elseif combo.v == 4 then
      imgui.InputTextMultiline("    ", text1, imgui.ImVec2(108, 423))
      imgui.SameLine()
      imgui.InputTextMultiline("     ", text2, imgui.ImVec2(108, 423))
      imgui.SameLine()
      imgui.InputTextMultiline("      ", text3, imgui.ImVec2(108, 423))
      imgui.SameLine()
      imgui.InputTextMultiline("       ", text4, imgui.ImVec2(108, 423))
      imgui.SameLine()
      imgui.InputTextMultiline("        ", text5, imgui.ImVec2(108, 423))
     end
   end
   imgui.EndChild()
   imgui.End()
  else
   imgui.Process = false
 end
end

У меня есть код блокнота (кинул выше), подскажите как сделать добавление заметки по нажатию на кнопку и так же удаление определенной заметки на кнопку.
Я пробывал сделать добавление на кнопук, но что то пошло не так (кину ниже кнопку)

Lua:
if imgui.Button('Создть заметку') then
slot = slot + 1

inicfg.save(mainIni, directIni)
end
 

copypaste_scripter

Известный
1,437
293
IMG_20210605_114619_192.jpg
IMG_20210605_114553_110.jpg

Что не так?
 

copypaste_scripter

Известный
1,437
293
синтаксис учи, и вообще какого хера скрины а не текст
просто скажи что не так плиз, синтакс вроде не при чем. пишет что булин не хочет. а скрины потому что комп слабый и браузер с игрой не откроешь, пишу с телефона
 

W1ll04eison

Известный
330
19
Подскажите, как сделать добавление и удаление слота в биндере ( код скину ниже)


Lua:
script_name("MultiBinder by FORMYS")
script_authors("FORMYS, TheChampGuess")

local key = require 'vkeys'
local imgui = require 'imgui'
local inicfg = require 'inicfg'
local encoding = require 'encoding'
local sampev = require 'lib.samp.events'
local bindPath = "moonloader\\MultiBinder\\binder.ini";
local bindPathShort = "moonloader\\MultiBinder";

require "lib.moonloader"
encoding.default = 'CP1251'
u8 = encoding.UTF8

local bind_slot = 50 -- кол-во слотов биндера

if not doesDirectoryExist(bindPathShort) then
    createDirectory(bindPathShort)
end

if not doesFileExist(bindPath) then
    f = io.open(bindPath, 'a')
    for i=1, bind_slot do
        f:write("[".. i .."]\n")
    end
    f:write("1=")
    f:close()
end

local mainBind = inicfg.load(nil, bindPath)
local binder_window = imgui.ImBool(false)
local sw, sh = getScreenResolution()
local wmine = 700

about_bind = {}
binder_text = {}
binder_text[1] = imgui.ImBuffer(1024) -- multiline
binder_text[2] = imgui.ImBuffer(192) -- активация команда
binder_text[3] = imgui.ImBuffer(16) -- задержка
selected_item_binder = imgui.ImInt(0)

cb_render_in_menu = imgui.ImBool(imgui.RenderInMenu)
cb_lock_player = imgui.ImBool(imgui.LockPlayer)
cb_show_cursor = imgui.ImBool(imgui.ShowCursor)

function SetStyle()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.ChildWindowRounding = 4.0
    colors[clr.PopupBg]                = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.ComboBg]                = colors[clr.PopupBg]
    colors[clr.Button]                 = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.ButtonHovered]          = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.ButtonActive]           = ImVec4(0.06, 0.53, 0.98, 1.00)
    colors[clr.TitleBg]                = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]          = ImVec4(0.16, 0.29, 0.48, 1.00)
    colors[clr.TitleBgCollapsed]       = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.CloseButton]            = ImVec4(0.41, 0.41, 0.41, 0.50)
    colors[clr.CloseButtonHovered]     = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.CloseButtonActive]      = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.TextSelectedBg]         = ImVec4(0.26, 0.59, 0.98, 0.35)
    colors[clr.Text]                   = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.FrameBg]                = ImVec4(0.16, 0.29, 0.48, 0.54)
    colors[clr.FrameBgHovered]         = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.FrameBgActive]          = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.MenuBarBg]              = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.ScrollbarBg]            = ImVec4(0.02, 0.02, 0.02, 0.53)
    colors[clr.ScrollbarGrab]          = ImVec4(0.31, 0.31, 0.31, 1.00)
    colors[clr.ScrollbarGrabHovered]   = ImVec4(0.41, 0.41, 0.41, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 1.00)
    colors[clr.CheckMark]              = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.Header]                 = ImVec4(0.26, 0.59, 0.98, 0.31)
    colors[clr.HeaderHovered]          = ImVec4(0.26, 0.59, 0.98, 0.80)
    colors[clr.HeaderActive]           = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.SliderGrab]             = ImVec4(0.24, 0.52, 0.88, 1.00)
    colors[clr.SliderGrabActive]       = ImVec4(0.26, 0.59, 0.98, 1.00)
end
SetStyle()

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    thread = lua_thread.create_suspended(thread_function)
    AddChatMessage("Успешно запущен")

    while true do
        wait(0)

        for i = 1, bind_slot do
            if mainBind[i] ~= nil then
                if mainBind[i].act ~= nil and not string.find(mainBind[i].act, "/", 1, true) then
                    if isKeysDown(strToIdKeys(mainBind[i].act)) then
                        thread:run("binder" .. i)
                    end
                end
            end
        end
    end

end

function sampev.onSendCommand(command)
    if command == "/binder" then
        binder_window.v = not binder_window.v
        imgui.Process = binder_window.v
    end
    for i = 1, bind_slot do
        if mainBind[i] ~= nil and mainBind[i].act ~= nil then
            if command == mainBind[i].act then
                thread:run("binder" .. i)
                return false
            end
        end
    end
end

function thread_function(option)
    if string.sub(option, 0, 6) == "binder" then
        ind = tonumber(string.sub(option, 7))
        for i = 1, 30 do
            if mainBind[ind][i] ~= nil then
                if mainBind[ind][i] == "" then
                    sampAddChatMessage("[Binder | Warning]: Обнаружена пустая строка", -1)
                else
                    sampSendChat(u8:decode(mainBind[ind][i]))
                    wait(tonumber(mainBind[ind].wait .. "000"))
                end
            else
                return
            end
        end
        return
    end
end

function AddChatMessage(text)
    sampAddChatMessage("[MultiBinder]: {FFFFFF}" .. text, 0x5A90CE)
end

function ShowHelpMarker(text)
    imgui.SameLine()
    imgui.TextDisabled("(?)")
    if (imgui.IsItemHovered()) then
        imgui.SetTooltip(u8(text))
    end
end

function ShowCenterTextColor(text, wsize, color)
    imgui.SetCursorPosX((wsize / 2) - (imgui.CalcTextSize(text).x / 2))
    imgui.TextColored(color, text)
end

function ShowCenterText(text, wsize)
    imgui.SetCursorPosX((wsize / 2) - (imgui.CalcTextSize(text).x / 2))
    imgui.TextColored(imgui.ImVec4(0.4, 0.8, 0.3, 1.0), text)
end

function isReservedCommand(command)
    ArrRCommand = {"binder"}
    for i = 1, #ArrRCommand do
        if command == ArrRCommand[i] then
            return true
        end
    end
    return false
end

function getDownKeys()
    local curkeys = ""
    local bool = false
    for k, v in pairs(key) do
        if isKeyDown(v) and (v == VK_MENU or v == VK_CONTROL or v == VK_SHIFT or v == VK_LMENU or v == VK_RMENU or v == VK_RCONTROL or v == VK_LCONTROL or v == VK_LSHIFT or v == VK_RSHIFT) then
            if v ~= VK_MENU and v ~= VK_CONTROL and v ~= VK_SHIFT then
                curkeys = v
            end
        end
    end
    for k, v in pairs(key) do
        if isKeyDown(v) and (v ~= VK_MENU and v ~= VK_CONTROL and v ~= VK_SHIFT and v ~= VK_LMENU and v ~= VK_RMENU and v ~= VK_RCONTROL and v ~= VK_LCONTROL and v ~= VK_LSHIFT and v ~= VK_RSHIFT) then
            if tostring(curkeys):len() == 0 then
                curkeys = v
            else
                curkeys = curkeys .. " " .. v
            end
            bool = true
        end
    end
    return curkeys, bool
end

function getDownKeysText()
    tKeys = string.split(getDownKeys(), " ")
    if #tKeys ~= 0 then
        for i = 1, #tKeys do
            if i == 1 then
                str = key.id_to_name(tonumber(tKeys[i]))
            else
                str = str .. "+" .. key.id_to_name(tonumber(tKeys[i]))
            end
        end
        return str
    else
        return "None"
    end
end


function string.split(inputstr, sep)
    if sep == nil then
            sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
            t[i] = str
            i = i + 1
    end
    return t
end

function strToIdKeys(str)
    tKeys = string.split(str, "+")
    if #tKeys ~= 0 then
        for i = 1, #tKeys do
            if i == 1 then
                str = key.name_to_id(tKeys[i], false)
            else
                str = str .. " " .. key.name_to_id(tKeys[i], false)
            end
        end
        return tostring(str)
    else
        return "(("
    end
end

function isKeysDown(keylist, pressed)
    local tKeys = string.split(keylist, " ")
    if pressed == nil then
        pressed = false
    end
    if tKeys[1] == nil then
        return false
    end
    local bool = false
    local key = #tKeys < 2 and tonumber(tKeys[1]) or tonumber(tKeys[2])
    local modified = tonumber(tKeys[1])
    if #tKeys < 2 then
        if not isKeyDown(VK_RMENU) and not isKeyDown(VK_LMENU) and not isKeyDown(VK_LSHIFT) and not isKeyDown(VK_RSHIFT) and not isKeyDown(VK_LCONTROL) and not isKeyDown(VK_RCONTROL) then
            if wasKeyPressed(key) and not pressed then
                bool = true
            elseif isKeyDown(key) and pressed then
                bool = true
            end
        end
    else
        if isKeyDown(modified) and not wasKeyReleased(modified) then
            if wasKeyPressed(key) and not pressed then
                bool = true
            elseif isKeyDown(key) and pressed then
                bool = true
            end
        end
    end
    if nextLockKey == keylist then
        if pressed and not wasKeyReleased(key) then
            bool = false
        else
            bool = false
            nextLockKey = ""
        end
    end
    return bool
end

function imgui.OnDrawFrame()
    if not binder_window.v then
        imgui.Process = false
    end
    if binder_window.v then
        imgui.SetNextWindowSize(imgui.ImVec2(wmine+50, 340), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.Begin(u8'Настройка MultiBinder', binder_window, imgui.WindowFlags.NoResize)

        imgui.BeginChild("test", imgui.ImVec2(wmine-490, 305), true)
                        imgui.Columns(2, "mycolumns")
                        imgui.Separator()
                        imgui.Text(u8"Активация") ShowHelpMarker("Двойной щелчок по пункту открывает\nнастройку редактора биндера") imgui.NextColumn()
                        imgui.Text(u8"Статус") imgui.NextColumn()
            imgui.Separator()
            for i = 1, bind_slot do
                if imgui.Selectable(u8"Слот №" .. i, false, imgui.SelectableFlags.AllowDoubleClick) then
                    if (imgui.IsMouseDoubleClicked(0)) then
                        z = i
                        if mainBind[i] == nil then
                            imgui.OpenPopup("SetActivation")
                        else
                            imgui.OpenPopup("ReActivation")
                        end
                    end
                end
                imgui.NextColumn()
                if mainBind[i] ~= nil and mainBind[i].wait ~= nil and mainBind[i].act ~= nil then
                    if change_binder == i and change_binder ~= nil and change_binder ~= "" then
                        imgui.TextColored(imgui.ImVec4(0.4, 0.8, 0.8, 1.0), u8"Ред. | Занято")
                    else
                        imgui.TextColored(imgui.ImVec4(0.8, 0.7, 0.1, 1.0), mainBind[i].act) --u8"Занято"
                        about_bind[i] = true
                    end
                else
                    if change_binder == i and change_binder ~= nil and change_binder ~= "" then
                        imgui.TextColored(imgui.ImVec4(0.4, 0.8, 0.8, 1.0), u8"Редактируется")
                    else
                        imgui.TextColored(imgui.ImVec4(0.4, 0.8, 0.3, 1.0), u8"Cвободно")
                        about_bind[i] = false
                    end
                end
                imgui.NextColumn()
            end
        if imgui.BeginPopup("ReActivation") then
            imgui.Text(u8"Выберите нужное действие для (Слот №" .. z .. ")")
            imgui.SetCursorPosX(20)
            if imgui.Button(u8"Удалить") then
                for i = 1, 30 do
                    mainBind[z][i] = nil
                end
                mainBind[z].act = nil
                mainBind[z].wait = nil
                mainBind[z] = nil
                inicfg.save(mainBind, "moonloader\\mz\\binder.ini")
                imgui.CloseCurrentPopup()
            end
            imgui.SameLine()
            if imgui.Button(u8"Редактировать") then
                change_binder = z
                is_changeact = true
                binder_text[2].v = mainBind[z].act
                binder_text[3].v = mainBind[z].wait
                for g = 1, 30 do
                    if mainBind[z][g] == nil then
                        break
                    else
                        if g == 1 then
                            binder_text[1].v = mainBind[z][g]
                        else
                            binder_text[1].v = binder_text[1].v .. "\n" .. mainBind[z][g]
                        end
                    end
                end
                imgui.CloseCurrentPopup()
            end
            imgui.SameLine()
            if imgui.Button(u8"Закрыть") then
                imgui.CloseCurrentPopup()
            end
            imgui.EndPopup()
        end
        if imgui.BeginPopup("SetActivation") then
            imgui.Text(u8"Выберите нужную вам активацию для (Слот №" .. z .. ")")
            imgui.PushItemWidth(240)
            imgui.SetCursorPosX(30)
            imgui.Combo("", selected_item_binder, u8"На клавишу (комбинацию клавиш)\0На команду (прим. /command)\0\0")
            imgui.SetCursorPosX(85)
            if imgui.Button(u8"Выбрать") then
                change_binder = z
                binder_text[1].v = ""
                is_changeact = false
                if about_bind[z] then
                    binder_text[2].v = mainBind[z].act
                    binder_text[3].v = mainBind[z].wait
                    for g = 1, 30 do
                        if mainBind[z][g] == nil then
                            break
                        else
                            if g == 1 then
                                binder_text[1].v = mainBind[z][g]
                            else
                                binder_text[1].v = binder_text[1].v .. "\n" .. mainBind[z][g]
                            end
                        end
                    end
                else
                    binder_text[2].v = ""
                    binder_text[3].v = ""
                end

                imgui.CloseCurrentPopup()
            end
            imgui.SameLine()
            imgui.SetCursorPosX(155)
            if imgui.Button(u8"Закрыть") then
                imgui.CloseCurrentPopup()
            end
            imgui.EndPopup()
        end
        if bind_slot < 15 then
            imgui.Columns(1)
            imgui.Separator()
        end
        imgui.EndChild()
        imgui.SameLine()
        imgui.BeginChild("notest", imgui.ImVec2(wmine-(wmine-490)+25, 305), true)

        if change_binder ~= nil and change_binder ~= "" then
            imgui.SetCursorPosY(5)
            ShowCenterTextColor(u8("Редакторивание профиля биндера (Слот №" .. change_binder .. ")"), wmine-200, imgui.ImVec4(0.8, 0.7, 0.1, 1.0))
            imgui.Separator()

            if not is_changeact then

                if selected_item_binder.v == 0 then
                    imgui.BeginChild("change", imgui.ImVec2(118, 20), true)
                    imgui.SetCursorPosY(2)
                    imgui.TextColored(imgui.ImVec4(1.0, 1.0, 0.7, 1.0), getDownKeysText())
                    imgui.EndChild()
                    imgui.SameLine()
                    imgui.SetCursorPosY(28)
                    imgui.Text(u8"Зажмите клавишу/комбинацию клавиш и нажмите")
                    imgui.SameLine()
                    if imgui.Button(u8("Сохранить")) then
                        if getDownKeysText() ~= "None" then
                            binder_text[2].v = getDownKeysText()
                            is_changeact = true
                        else
                            AddChatMessage("Зажмите клавишу/клавиши, после чего повторите попытку")
                        end
                    end
                else
                    imgui.Text(u8"Активация: /")
                    imgui.SameLine()
                    imgui.PushItemWidth(100)
                    imgui.SetCursorPos(imgui.ImVec2(90, 26))
                    imgui.InputText(u8"##1", binder_text[2])
                    imgui.SameLine()
                    if imgui.Button(u8"Сохранить") then
                        if isReservedCommand(binder_text[2].v) then
                            AddChatMessage("Введенная вами команда является зарезервированной скриптом. Придумайте другую")
                        else
                            if string.find(binder_text[2].v, '/', 1, true) then
                                AddChatMessage('Знак "/" будет прикреплен к команде позже. В данный момент он не нужен')
                            else
                                is_changeact = true
                                binder_text[2].v = "/" .. binder_text[2].v
                            end
                        end
                    end
                end

            else
                imgui.SetCursorPosY(30)
                imgui.Text(u8"Активация:")
                imgui.SameLine()
                imgui.SetCursorPosY(30)
                imgui.TextColored(imgui.ImVec4(0.4, 0.8, 0.3, 1.0), binder_text[2].v)
                imgui.SameLine()
                imgui.SetCursorPosY(28)
                if imgui.Button(u8("Изменить активацию")) then
                    imgui.OpenPopup("ChangeActivation")
                end
            end

            if (imgui.BeginPopup("ChangeActivation")) then
                imgui.Text(u8"Выберите нужную вам активацию для (Слот №" .. z .. ")")
                imgui.PushItemWidth(240)
                imgui.SetCursorPosX(30)
                imgui.Combo("", selected_item_binder, u8"На клавишу (комбинацию клавиш)\0На команду (прим. /command)\0\0")
                imgui.SetCursorPosX(85)
                if imgui.Button(u8"Выбрать") then
                    if selected_item_binder.v == 1 then
                        if binder_text[2].v ~= "" then
                            if string.find(binder_text[2].v, '/', 1, true) then
                                binder_text[2].v = string.sub(binder_text[2].v, 2)
                            else
                                binder_text[2].v = ""
                            end
                        end
                    end
                    is_changeact = false
                    imgui.CloseCurrentPopup()
                end
                imgui.SameLine()
                imgui.SetCursorPosX(155)
                if imgui.Button(u8"Закрыть") then
                    imgui.CloseCurrentPopup()
                end
                imgui.EndPopup()
            end

            imgui.Text(u8"Задержка:")
            imgui.SameLine()
            imgui.PushItemWidth(50)
            imgui.InputText(u8'сек.', binder_text[3], imgui.InputTextFlags.CharsDecimal)
            imgui.SameLine()
            if imgui.Checkbox(u8"Блокировка движений персонажа", cb_lock_player) then
                imgui.LockPlayer = cb_lock_player.v
            end
            imgui.Separator()
            ShowCenterTextColor(u8("Вводимый текст биндера (для переноса строки нажать Enter)"), wmine-200, imgui.ImVec4(0.8, 0.7, 0.1, 1.0))
            imgui.InputTextMultiline(u8'##3', binder_text[1], imgui.ImVec2(500, 178))
            imgui.SetCursorPosX(120)
            if imgui.Button(u8("Сохранить"), imgui.ImVec2(120, 20)) then
                if binder_text[3].v == "" then
                    binder_text[3].v = 0
                end
                if binder_text[1].v == "" or binder_text[2].v == "" then
                    AddChatMessage("Заполните все поля!")
                else
                    for i = 1, 30 do
                        if mainBind[change_binder] ~= nil then
                            if mainBind[change_binder][i] ~= nil then
                                mainBind[change_binder][i] = nil
                            else
                                break
                            end
                        else
                            break
                        end
                    end
                    i = 0
                    for s in string.gmatch(binder_text[1].v, "[^\r\n]+") do
                        i = i + 1
                        if mainBind[change_binder] == nil then
                            mainBind[change_binder] = {}
                        end
                        mainBind[change_binder][i] = s
                    end
                    mainBind[change_binder].act = binder_text[2].v
                    mainBind[change_binder].wait = binder_text[3].v
                    inicfg.save(mainBind, bindPath)
                    AddChatMessage("Данные биндера успешно сохранены!")
                end
            end
            imgui.SameLine()
            imgui.SetCursorPosX(260)
            if imgui.Button(u8("Отмена"), imgui.ImVec2(120, 20)) then
                change_binder = ""
            end

        end

        imgui.EndChild()
        imgui.End()
    end
end