не сохраняется инфа в ini файл

Kegwineye.

Участник
Автор темы
478
20
Lua:
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local sampev = require 'lib.samp.events'
local keys = require 'vkeys'
local list = {}
local inicfg = require 'inicfg'
local fontsize = nil
local menu = 0
local slider = imgui.ImFloat(0)
local fa = require 'fAwesome5' -- ICONS LIST: https://fontawesome.com/v5.15/icons?d=gallery&s=solid&m=free
        
local localwindow = imgui.ImBool(false)
local windowleader = imgui.ImBool(false)
local newfindwindow = imgui.ImBool(false)
local statisticwindowlite = imgui.ImBool(false)
local statisticwindowhight = imgui.ImBool(false)

local cfg = inicfg.load({
    password = "",
    autologin = false,
    Binds_Name = {},
    Binds_Action = {},
    Binds_Deleay = {},
}, "Onfroy Family Helper")

local mainlocalcolor = '{0000CD}'
local localscripttag = '{0000CD}[Onfroy Family Helper]: {FFFFFF}'
local window = imgui.ImBool(false)
local binder_delay = imgui.ImInt(2500)
local text_binder = imgui.ImBuffer(65536)
local binder_name = imgui.ImBuffer(35)
local autologin = imgui.ImBool(cfg.autologin)
local password = imgui.ImBuffer(''.. cfg.password, 256)

local colors = imgui.GetStyle().Colors;
local icol = imgui.Col
local ImVec4 = imgui.ImVec4

if cfg.hotkey == nil then -- если отсутствует секция hotkey в ини файле
    cfg.hotkey = {
        bindLock = "[]",
        bindKey = "[]",
        bindSbiv = "[]",
        bindPhone = "[]"
    }
end

function main()
    while not isSampAvailable() do wait(200) end
    sampRegisterChatCommand('opw', openmainwindow)
    sampRegisterChatCommand('leaders', function() sampSendChat("/leaders") ; windowleader.v = not windowleader.v end)
    sampRegisterChatCommand('stats', function() statisticwindowhight.v = not statisticwindowhight.v end)
    imgui.Process = false
    localwindow.v = false
    windowleader.v = false  --show window on start
    while true do
        wait(0)
        imgui.Process = localwindow.v or windowleader.v or statisticwindowhight.v
    end
end

function openmainwindow()
    localwindow.v = not localwindow.v
end

function imgui.OnDrawFrame()
    if localwindow.v then
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 700, 500 -- WINDOW SIZE
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - sizeX / 2, resY / 2 - sizeY / 2), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('Window Title', localwindow, imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoResize)
            imgui.SetCursorPosX(170)
            imgui.SetCursorPosY(450)
            imgui.PushFont(fontsizefa25)
            imgui.Button(fa.ICON_FA_QUESTION_CIRCLE ..'')
            imgui.PopFont()
            imgui.Hint(u8'Актуальная версия скрипта 0.1')
            imgui.SameLine()
            imgui.SetCursorPosX(130)
            imgui.SetCursorPosY(450)
            imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0, 0, 2.25, 0.65))
            imgui.PushFont(fontsizefa25)
            if imgui.Button(fa.ICON_FA_LINK ..'##VK') then
                setClipboardText(u8'https://vk.com/kinginthedead'); GHsms('Ссылка на {4169E1}"ВКонтакте"{FFFFFF} была скопированна!')
            end
            imgui.PopFont()
            imgui.Hint(u8'Нажмите, чтобы скопировать')
            imgui.PopStyleColor()
            imgui.SetCursorPosX(90)
            imgui.SetCursorPosY(450)
            imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0.48, 0, 2.26, 1))
            imgui.PushFont(fontsizefa25)
            if imgui.Button(fa.ICON_FA_LINK ..'##DS') then
                setClipboardText(u8'ssultan#9919'); GHsms('Тег для {9370DB}"Discord"{FFFFFF} была скопирован!')
            end
            imgui.PopFont()
            imgui.Hint(u8'Нажмите, чтобы скопировать')
            imgui.PopStyleColor()
            imgui.SetCursorPosX(30)
            imgui.SetCursorPosY(400)
            if imgui.Button(u8'Save Settings', imgui.ImVec2(120,30)) then -- Кнопка для сохранения настроек
                cfg.password = password.v
                cfg.autologin = autologin.v
                inicfg.save(cfg, 'Onfroy Family Helper.ini')
                sampAddChatMessage(localscripttag .."Настройки были успешно сохранены.", -1)
            end
            imgui.SetCursorPosX(240)
            imgui.SetCursorPosY(5)
            imgui.PushFont(fontsize)
            imgui.TextColoredRGB(mainlocalcolor ..'ONFROY HELPER')
            imgui.PopFont()
            imgui.SetCursorPosY(10)
            imgui.SetCursorPosX(650)
            if imgui.Button(fa.ICON_FA_TIMES ..'', imgui.ImVec2(40, 40)) then localwindow.v = not localwindow.v end
            imgui.SetCursorPosY(10)
            imgui.PushStyleVar(imgui.StyleVar.FrameRounding, 5)
            imgui.SetCursorPosY(10)
            if imgui.Button(u8"Основные", imgui.ImVec2(180, 40)) then menu = 1 end
            imgui.SetCursorPosY(60)
            if imgui.Button(u8"Другое", imgui.ImVec2(180, 40)) then menu = 2 end
            imgui.SetCursorPosY(110)
            if imgui.Button(u8"Улучшения", imgui.ImVec2(180, 40)) then menu = 3 end
            imgui.SetCursorPosY(160)
            if imgui.Button(u8"Биндер", imgui.ImVec2(180, 40)) then menu = 4 end
            imgui.PopStyleVar(1)
            imgui.SameLine()
        if menu == 0 then
            imgui.SetCursorPosY(60)
            imgui.BeginChild("child2", imgui.ImVec2(480, 430), false)
            imgui.CenterText(u8"Добро пожаловать на открытое бета-тестирование хелпера от семьи Onfroy!")
            imgui.Text(u8" Мы играем на проекте Online RP 02, приглашаем вас к себе на второй сервер\n   При регестрации указывай ник Handerson_Onfroy, а так же /mn - 11 - #onfroy")
            imgui.EndChild()
        end
            imgui.SameLine()
        if menu == 1 then
            imgui.SetCursorPosY(60)
            imgui.BeginChild("child2", imgui.ImVec2(480, 430), false)
            imgui.Text("1")
            imgui.EndChild()
        end
        imgui.SameLine()
        if menu == 2 then
            imgui.SetCursorPosY(60)
            imgui.BeginChild("child2", imgui.ImVec2(480, 430), false)
            imgui.Checkbox(u8 " Автологин", autologin)
                imgui.SameLine()
                imgui.Hint(u8"При входе на сервер будет автоматически вводиться пароль")
                imgui.Separator()
            if pokaz then
                imgui.InputText(u8"", password) else
                imgui.InputText(u8"", password, imgui.InputTextFlags.Password) end
                imgui.SameLine()
                imgui.Hint(u8"Данный пароль будет использован при заходе на сервер")
            if imgui.Button(pokaz and fa.ICON_FA_EYE_SLASH ..u8'' or fa.ICON_FA_EYE ..u8'') then
    pokaz = not pokaz end
            imgui.EndChild()
        end
        imgui.SameLine()
        if menu == 3 then
            imgui.SetCursorPosY(60)
            imgui.BeginChild("child2", imgui.ImVec2(480, 430), false)
            imgui.Text("3")
            imgui.EndChild()
        end
        imgui.SameLine()
        if menu == 4 then
            imgui.SetCursorPosY(60)
            imgui.BeginChild("child2", imgui.ImVec2(480, 430), false)
            imgui.Text('\n')
            imgui.CenterTextColoredRGB('Меню ваших биндов')
            imgui.Separator()
            if #cfg.Binds_Name > 0 then
            for key_bind, name_bind in pairs(cfg.Binds_Name) do
            if imgui.Button(u8(name_bind)..'##'..key_bind, imgui.ImVec2(312, 30)) then
            play_bind(key_bind)
            
            end
            imgui.SameLine()
            if imgui.Button(fa.ICON_FA_PEN..'##'..key_bind, imgui.ImVec2(30, 30)) then
            EditOldBind = true
            name_old_bild = cfg.Binds_Name[key_bind]
            getpos = key_bind
            binder_delay.v = cfg.Binds_Deleay[key_bind]
            local returnwrapped = tostring(cfg.Binds_Action[key_bind]):gsub('~', '\n')
            text_binder.v = u8(returnwrapped)
            binder_name.v = tostring(u8(cfg.Binds_Name[key_bind]))
            imgui.OpenPopup(u8'Биндер')
            end
            imgui.SameLine()
            if imgui.Button(fa.ICON_FA_TRASH..'##'..key_bind, imgui.ImVec2(30, 30)) then
            GHsms('Бинд {0000CD}«'..cfg.Binds_Name[key_bind]..'»{FFFFFF} удалён!')
            table.remove(cfg.Binds_Name, key_bind)
            table.remove(cfg.Binds_Action, key_bind)
            table.remove(cfg.Binds_Deleay, key_bind)
            inicfg.save(cfg, 'Onfroy Family Helper.ini')
            end
            end
            else
            imgui.CenterTextColoredRGB('Здесь пока нету Ваших биндов.')
            imgui.CenterTextColoredRGB('Их можно создать!')
            imgui.SetCursorPosX((imgui.GetWindowWidth() - 25) / 2)
            end
            imgui.Separator()
            if imgui.Button(fa.ICON_FA_PLUS_CIRCLE..u8' Создать бинд', imgui.ImVec2(-1,30)) then
            imgui.OpenPopup(u8'Биндер')
            binder_delay.v = 2500
            end


            if imgui.BeginPopupModal(u8'Биндер', false, imgui.WindowFlags.NoResize + imgui.WindowFlags.AlwaysAutoResize + imgui.WindowFlags.NoTitleBar) then
            imgui.BeginChild("##EditBinder", imgui.ImVec2(630, 367), true)
            imgui.PushItemWidth(150)
            imgui.InputInt(u8("Задержка между строками в миллисекундах"), binder_delay); imgui.SameLine(); imgui.Vopros(); imgui.Hint(u8'Не больше 60.000 ms!\n(1 sec = 1000 ms)')
            imgui.PopItemWidth()
            if binder_delay.v <= 0 then
            binder_delay.v = 1
            elseif binder_delay.v >= 60001 then
            binder_delay.v = 60000
            end
            imgui.SameLine()
            if imgui.Button(u8'Локальные тэги##LocalTag', imgui.ImVec2(140,20)) then
            imgui.OpenPopup(u8'Локальные тэги')
            end
            localtag()
            imgui.InputTextMultiline("##EditMultiline", text_binder, imgui.ImVec2(-1, 250))
            imgui.Text(u8'Название бинда (обязательно):'); imgui.SameLine()
            imgui.PushItemWidth(200)
            imgui.InputText("##binder_name", binder_name)
            imgui.PopItemWidth()

            if #binder_name.v > 0 and #text_binder.v > 0 then
            imgui.SameLine()
            if imgui.Button(u8'Сохранить##bind1', imgui.ImVec2(-1,20)) then
            if not EditOldBind then
            refresh_text = text_binder.v:gsub("\n", "~")
            table.insert(cfg.Binds_Name, u8:decode(binder_name.v))
            table.insert(cfg.Binds_Action, u8:decode(refresh_text))
            table.insert(cfg.Binds_Deleay, binder_delay.v)
            if inicfg.save(cfg, 'Onfroy Family Helper.ini') then
            GHsms('Бинд {0000CD}«'..u8:decode(binder_name.v)..'»{FFFFFF} успешно добавлен!')
            binder_name.v, text_binder.v = '', ''
            end
            imgui.CloseCurrentPopup()
            else
            refresh_text = text_binder.v:gsub("\n", "~")
            table.insert(cfg.Binds_Name, getpos, u8:decode(binder_name.v))
            table.insert(cfg.Binds_Action, getpos, u8:decode(refresh_text))
            table.insert(cfg.Binds_Deleay, getpos, binder_delay.v)
            table.remove(cfg.Binds_Name, getpos + 1)
            table.remove(cfg.Binds_Action, getpos + 1)
            table.remove(cfg.Binds_Deleay, getpos + 1)
            if inicfg.save(cfg, 'Onfroy Family Helper.ini') then
            GHsms('Бинд {0000CD}«'..name_old_bild..'»{FFFFFF} успешно отредактирован!')
            binder_name.v, text_binder.v = '', ''
            end
            EditOldBind = false
            imgui.CloseCurrentPopup()
            end
            end
            else
            imgui.SameLine()
            imgui.DisableButton(u8'Сохранить##bind2', imgui.ImVec2(-1,20))
            imgui.Hint(u8'Заполнены не все пункты!')
            end

            if imgui.Button(u8'Закрыть', imgui.ImVec2(-1,20)) then
            if not EditOldBind then
            imgui.CloseCurrentPopup()
            binder_name.v, text_binder.v = '', ''
            else
            EditOldBind = false
            imgui.CloseCurrentPopup()
            binder_name.v, text_binder.v = '', ''
            end
            end
            imgui.EndChild()
            imgui.EndPopup()
        end
            imgui.End()
        end
        imgui.End()
    end
    if windowleader.v then
        imgui.SetNextWindowPos(imgui.ImVec2(350.0, 250.0), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(280.0, 70.0), imgui.Cond.FirstUseEver)
        imgui.Begin(u8'Лидеры в сети', windowleader, imgui.WindowFlags.AlwaysAutoResize + imgui.WindowFlags.NoTitleBar)
        if list[1] ~= nil then
            imgui.SetCursorPosX(40)
            imgui.Text(u8'Организация')
            imgui.SameLine()
            imgui.SetCursorPosX(185)
            imgui.Text(u8'Звание')
            imgui.SameLine()
            imgui.SetCursorPosX(340)
            imgui.Text(u8'Ник')
            imgui.SameLine()
            imgui.SetCursorPosX(450)
            imgui.Text(u8'Номер')
            imgui.Separator()
            imgui.Separator()
            for i = 1, #list do
                
                local a,b,c,e,f = list[i]:match("[}](.+)[-](.+)[-](.+)[-](.+)")
                imgui.SetCursorPosX(10)
                if imgui.Text(u8(a)) then end
                imgui.Columns()
                imgui.SameLine()
                imgui.SetCursorPosX(145)
                imgui.VerticalSeparator()
                imgui.SetCursorPosX(150)
                imgui.Text(u8(b))
                imgui.SameLine()
                imgui.SetCursorPosX(275)
                imgui.VerticalSeparator()
                imgui.SetCursorPosX(280)
                imgui.Text(u8(c))
                imgui.SameLine()
                imgui.SetCursorPosX(445)
                imgui.VerticalSeparator()
                imgui.SetCursorPosX(450)
                if imgui.Link(u8(e)) then
                    setClipboardText(u8(e))
                end
            end
        end

        imgui.End()
    end
    if statisticwindowhight.v then
        local resX, resY = getScreenResolution()
        local sizeX, sizeY = 500, 700 -- WINDOW SIZE
        imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - sizeX / 2, resY / 2 - sizeY / 2), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
        imgui.Begin('##huyna', statisticwindowhight, imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoResize)
        imgui.End()
    end
end

function imgui.Vopros()
    imgui.TextDisabled(fa.ICON_FA_QUESTION_CIRCLE)
end

function imgui.Hint(text, delay, action)
    if imgui.IsItemHovered() then
        if go_hint == nil then go_hint = os.clock() + (delay and delay or 0.0) end
        local alpha = (os.clock() - go_hint) * 5 -- скорость появления
        if os.clock() >= go_hint then
            imgui.PushStyleVar(imgui.StyleVar.WindowPadding, imgui.ImVec2(10, 10))
            imgui.PushStyleVar(imgui.StyleVar.Alpha, (alpha <= 1.0 and alpha or 1.0))
            imgui.PushStyleColor(imgui.Col.PopupBg, imgui.GetStyle().Colors[imgui.Col.PopupBg])
            imgui.BeginTooltip()
            imgui.PushTextWrapPos(700)
            imgui.TextColored(imgui.GetStyle().Colors[imgui.Col.ButtonActive], fa.ICON_FA_INFO_CIRCLE..u8' Подсказка:')
            imgui.TextUnformatted(text)
            if action ~= nil then
                imgui.TextColored(imgui.GetStyle().Colors[imgui.Col.TextDisabled], '\n'..fa.ICON_FA_SHARE..' '..action)
            end
            if not imgui.IsItemVisible() and imgui.GetStyle().Alpha == 1.0 then go_hint = nil end
            imgui.PopTextWrapPos()
            imgui.EndTooltip()
            imgui.PopStyleColor()
            imgui.PopStyleVar(2)
        end
    end
end

function imgui.TextColoredRGB(text)
    local style = imgui.GetStyle()
    local colors = style.Colors
    local ImVec4 = imgui.ImVec4

    local explode_argb = function(argb)
        local a = bit.band(bit.rshift(argb, 24), 0xFF)
        local r = bit.band(bit.rshift(argb, 16), 0xFF)
        local g = bit.band(bit.rshift(argb, 8), 0xFF)
        local b = bit.band(argb, 0xFF)
        return a, r, g, b
    end

    local getcolor = function(color)
        if color:sub(1, 6):upper() == 'SSSSSS' then
            local r, g, b = colors[1].x, colors[1].y, colors[1].z
            local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
            return ImVec4(r, g, b, a / 255)
        end
        local color = type(color) == 'string' and tonumber(color, 16) or color
        if type(color) ~= 'number' then return end
        local r, g, b, a = explode_argb(color)
        return imgui.ImColor(r, g, b, a):GetVec4()
    end

    local render_text = function(text_)
        for w in text_:gmatch('[^\r\n]+') do
            local text, colors_, m = {}, {}, 1
            w = w:gsub('{(......)}', '{%1FF}')
            while w:find('{........}') do
                local n, k = w:find('{........}')
                local color = getcolor(w:sub(n + 1, k - 1))
                if color then
                    text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
                    colors_[#colors_ + 1] = color
                    m = n
                end
                w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
            end
            if text[0] then
                for i = 0, #text do
                    imgui.TextColored(colors_[i] or colors[1], u8(text[i]))
                    imgui.SameLine(nil, 0)
                end
                imgui.NewLine()
            else imgui.Text(u8(w)) end
        end
    end

    render_text(text)
end

function imgui.DisableButton(text, size)
    imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0.0, 0.0, 0.0, 0.2))
    imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(0.0, 0.0, 0.0, 0.2))
    imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(0.0, 0.0, 0.0, 0.2))
    local button = imgui.Button(text, size)
    imgui.PopStyleColor(3)
    return button
end

function imgui.CenterTextColoredRGB(text)
    local width = imgui.GetWindowWidth()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local ImVec4 = imgui.ImVec4

    local explode_argb = function(argb)
    local a = bit.band(bit.rshift(argb, 24), 0xFF)
    local r = bit.band(bit.rshift(argb, 16), 0xFF)
    local g = bit.band(bit.rshift(argb, 8), 0xFF)
    local b = bit.band(argb, 0xFF)
    return a, r, g, b
    end

    local getcolor = function(color)
    if color:sub(1, 6):upper() == 'SSSSSS' then
    local r, g, b = colors[1].x, colors[1].y, colors[1].z
    local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
    return ImVec4(r, g, b, a / 255)
    end
    local color = type(color) == 'string' and tonumber(color, 16) or color
    if type(color) ~= 'number' then return end
    local r, g, b, a = explode_argb(color)
    return imgui.ImColor(r, g, b, a):GetVec4()
    end

    local render_text = function(text_)
    for w in text_:gmatch('[^\r\n]+') do
    local textsize = w:gsub('{.-}', '')
    local text_width = imgui.CalcTextSize(u8(textsize))
    imgui.SetCursorPosX( width / 2 - text_width .x / 2 )
    local text, colors_, m = {}, {}, 1
    w = w:gsub('{(......)}', '{%1FF}')
    while w:find('{........}') do
    local n, k = w:find('{........}')
    local color = getcolor(w:sub(n + 1, k - 1))
    if color then
    text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
    colors_[#colors_ + 1] = color
    m = n
    end
    w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
    end
    if text[0] then
    for i = 0, #text do
    imgui.TextColored(colors_[i] or colors[1], u8(text[i]))
    imgui.SameLine(nil, 0)
    end
    imgui.NewLine()
    else
    imgui.Text(u8(w))
    end
    end
    end
    render_text(text)
end

function imgui.CenterText(text)
    imgui.SetCursorPosX(imgui.GetWindowSize().x / 2 - imgui.CalcTextSize(text).x / 2)
    imgui.Text(text)
end

function onWindowMessage(msg, wparam, lparam)
    if msg == 0x100 or msg == 0x101 then
        if (wparam == keys.VK_ESCAPE and windowleader.v) and not isPauseMenuActive() then
            consumeWindowMessage(true, false)
            if msg == 0x101 then
                windowleader.v = false
            end
        end
    end
end

function imgui.VerticalSeparator()
    local p = imgui.GetCursorScreenPos()
    imgui.GetWindowDrawList():AddLine(imgui.ImVec2(p.x, p.y), imgui.ImVec2(p.x, p.y + imgui.GetContentRegionMax().y), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.Separator]))
end

function imgui.Link(label, description)

    local size = imgui.CalcTextSize(label)
    local p = imgui.GetCursorScreenPos()
    local p2 = imgui.GetCursorPos()
    local result = imgui.InvisibleButton(label, size)

    imgui.SetCursorPos(p2)

    if imgui.IsItemHovered() then
        if description then
            imgui.BeginTooltip()
            imgui.PushTextWrapPos(600)
            imgui.TextUnformatted(description)
            imgui.PopTextWrapPos()
            imgui.EndTooltip()

        end

        imgui.TextColored(imgui.GetStyle().Colors[imgui.Col.CheckMark], label)
        imgui.GetWindowDrawList():AddLine(imgui.ImVec2(p.x, p.y + size.y), imgui.ImVec2(p.x + size.x, p.y + size.y), imgui.GetColorU32(imgui.GetStyle().Colors[imgui.Col.CheckMark]))

    else
        imgui.TextColored(imgui.GetStyle().Colors[imgui.Col.CheckMark], label)
    end

    return result
end

if sampevcheck then
    function sampev.onSendChat(msg)
        if msg:find('{my:name}') then
            local _, myid = sampGetPlayerIdByCharHandle(PLAYER_PED)
            local returnMsg = msg:gsub('{my:name}', rpNick(myid))
            sampSendChat(returnMsg)
            return false
        end
        if msg:find('{my:id}') then
            local _, myid = sampGetPlayerIdByCharHandle(PLAYER_PED)
            local returnMsg = msg:gsub('{my:id}', myid)
            sampSendChat(returnMsg)
            return false
        end
        if msg:find('{my:rank}') then
            local returnMsg = msg:gsub('{my:rank}', cfg.Settings.rank)
            sampSendChat(returnMsg)
            return false
        end
        if msg:find('{time}') then
            local returnMsg = msg:gsub('{time}', '/time')
            sampSendChat(returnMsg)
            return false
        end
        if msg:find('{screen}') then
            Screen()
            local returnMsg = msg:gsub('{screen}', '')
            sampSendChat(returnMsg)
            return false
        end
    end
end

function rpNick(id)
    local nick = sampGetPlayerNickname(id)
    if nick:match('_') then return nick:gsub('_', ' ') end
    return nick
end

function imgui.Tooltip(text)
    if imgui.IsItemHovered() then
       imgui.BeginTooltip()
       imgui.Text(text)
       imgui.EndTooltip()
    end
end

function GHsms(text)
    sampAddChatMessage("{0000CD}[Onfroy Family Helper] {FFFFFF}"..text, 0x0000CD)
end

function sampev.onShowDialog(id, style, title, button1, button2, text)
    if title:find("Лидеры в сети") then
        list = {}
        for v in string.gmatch(text, '[^\n]+') do
            if not v:find("Организация") then
                table.insert(list, v)
            end
        end
        sampSendDialogResponse(id, 1)
        windowleader.v = true
        return false
    end
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/resource/fonts/fa-solid-900.ttf', 13.0, font_config, fa_glyph_ranges)
        if fontsize == nil then
            fontsizefa25 = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/resource/fonts/fa-solid-900.ttf', 25.0, font_config2, fa_glyph_ranges)
            fontsize = imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\trebucbd.ttf', 55.0, nil, imgui.GetIO().Fonts:GetGlyphRangesCyrillic()) -- вместо 30 любой нужный размер
        end
    end
end

if not doesFileExist(getWorkingDirectory()..'/config/Medical Helper.ini') then
    if inicfg.save(cfg, 'Onfroy Family Helper.ini') then log('Директория "Onfroy Family Helper.ini" была создана!') end
end
if not doesFileExist(getWorkingDirectory() .. "/resource/fonts/fa-solid-900.ttf") then
    GHsms("Отсутствует файл шрифта fa-solid-900.ttf. Пытаюсь его установить.")
    createDirectory(getWorkingDirectory() .. "/resource/fonts/")
    DownloadFile('https://github.com/FortAwesome/Font-Awesome/raw/master/webfonts/fa-solid-900.ttf', getWorkingDirectory().."/resource/fonts/fa-solid-900.ttf")
    GHsms('Шрифт "fa-solid-900.ttf" готов! Перезапускаю скрипт.')
    thisScript():reload()
    return false
end

if autologin.v then
    function onReceiveRpc(id,bitStream)
    if id == 61 then
        dialogId = raknetBitStreamReadInt16(bitStream)
            style = raknetBitStreamReadInt8(bitStream)
            str = raknetBitStreamReadInt8(bitStream)
            title = raknetBitStreamReadString(bitStream, str)
        if title:find("Авторизация") then
            sampSendDialogResponse(dialogId,1,0,"".. cfg.password) end end end end

function Screen()
    lua_thread.create(function()
        wait(500)
        setVirtualKeyDown(VK_F8, true)
        wait(10)
        setVirtualKeyDown(VK_F8, false)
    end)
end

function localtag()
if imgui.BeginPopupModal(u8'Локальные тэги', false, imgui.WindowFlags.NoResize + imgui.WindowFlags.AlwaysAutoResize + imgui.WindowFlags.NoTitleBar) then
    imgui.CenterTextColoredRGB('Тэги:')
    --
    if imgui.Button('{my:name}') then setClipboardText('{my:name}'); GHsms('Тэг "{my:name}" скопирован в буфер обмена!') else imgui.Hint(u8'Нажмите, чтобы скопировать') end; imgui.SameLine(); imgui.TextColoredRGB('Выведет Ваше имя в РП формате')
    --
    if imgui.Button('{my:id}') then setClipboardText('{my:id}'); GHsms('Тэг "{my:id}" скопирован в буфер обмена!') else imgui.Hint(u8'Нажмите, чтобы скопировать') end; imgui.SameLine(); imgui.TextColoredRGB('Выведет Ваш Ид')
    --
    if imgui.Button('{time}') then setClipboardText('{time}'); GHsms('Тэг "{time}" скопирован в буфер обмена!') else imgui.Hint(u8'Нажмите, чтобы скопировать.\nВ биндере использовать на новой строчке!') end; imgui.SameLine(); imgui.TextColoredRGB('Напишет "/time" в чат')
    --
    if imgui.Button('{screen}') then setClipboardText('{screen}'); GHsms('Тэг "{screen}" скопирован в буфер обмена!') else imgui.Hint(u8'Нажмите, чтобы скопировать.\nВ биндере советую использовать в строчке с текстом, иначе будет пустая строка в чате!') end; imgui.SameLine(); imgui.TextColoredRGB('Делает скриншот экрана (F8)')
    --
    if imgui.Button(u8'Закрыть##LocalTag', imgui.ImVec2(-1,20)) then
        imgui.CloseCurrentPopup()
    end
    imgui.EndPopup()
end
end

function play_bind(num)
    lua_thread.create(function()
        if num ~= -1 then
            for bp in cfg.Binds_Action[num]:gmatch('[^~]+') do
                sampSendChat(u8:decode(tostring(bp)))
                wait(cfg.Binds_Deleay[num])
            end
            num = -1
        end
    end)
end

function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4
 
    style.WindowPadding = imgui.ImVec2(15, 15)
    style.WindowRounding = 6.5
    style.FramePadding = imgui.ImVec2(5, 5)
    style.FrameRounding = 4.0
    style.ItemSpacing = imgui.ImVec2(12, 8)
    style.ItemInnerSpacing = imgui.ImVec2(8, 6)
    style.IndentSpacing = 25.0
    style.ScrollbarSize = 15.0
    style.ScrollbarRounding = 9.0
    style.GrabMinSize = 5.0
    style.GrabRounding = 3.0
 
    colors[clr.Text] = ImVec4(0.80, 0.80, 0.83, 1.00)
    colors[clr.TextDisabled] = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.WindowBg] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ChildWindowBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.PopupBg] = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.Border] = ImVec4(0.80, 0.80, 0.83, 0.88)
    colors[clr.BorderShadow] = ImVec4(0.92, 0.91, 0.88, 0.00)
    colors[clr.FrameBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.FrameBgHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.FrameBgActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.TitleBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.TitleBgCollapsed] = ImVec4(1.00, 0.98, 0.95, 0.75)
    colors[clr.TitleBgActive] = ImVec4(0.07, 0.07, 0.09, 1.00)
    colors[clr.MenuBarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ScrollbarBg] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ScrollbarGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.ScrollbarGrabHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.ScrollbarGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ComboBg] = ImVec4(0.19, 0.18, 0.21, 1.00)
    colors[clr.CheckMark] = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.SliderGrab] = ImVec4(0.80, 0.80, 0.83, 0.31)
    colors[clr.SliderGrabActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.Button] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.ButtonHovered] = ImVec4(0.24, 0.23, 0.29, 1.00)
    colors[clr.ButtonActive] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.Header] = ImVec4(0.10, 0.09, 0.12, 1.00)
    colors[clr.HeaderHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.HeaderActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
    colors[clr.ResizeGrip] = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.ResizeGripHovered] = ImVec4(0.56, 0.56, 0.58, 1.00)
    colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 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.40, 0.39, 0.38, 0.63)
    colors[clr.PlotLinesHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
    colors[clr.PlotHistogram] = ImVec4(0.40, 0.39, 0.38, 0.63)
    colors[clr.PlotHistogramHovered] = ImVec4(0.25, 1.00, 0.00, 1.00)
    colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
    colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
  end
  apply_custom_style()

@chapo @Rice. @Tufar tufan
 
Последнее редактирование:
Решение
Если я не ошибаюсь, то в inicfg нужно использовать данные в массиве:
Lua:
local cfg = inicfg.load({
    config = {
        password = "",
        autologin = false
    },
    Binds_Name = {},
    Binds_Action = {},
    Binds_Deleay = {},
}, "Onfroy Family Helper")

Rice.

https://t.me/riceoff
Модератор
1,673
1,360
Если я не ошибаюсь, то в inicfg нужно использовать данные в массиве:
Lua:
local cfg = inicfg.load({
    config = {
        password = "",
        autologin = false
    },
    Binds_Name = {},
    Binds_Action = {},
    Binds_Deleay = {},
}, "Onfroy Family Helper")