перестала работать функция

Kegwineye.

Участник
Автор темы
478
20
функция удаления сообщений из чата.
Строки: 100 - 131; 238 - 299.

Lua:
require "lib.moonloader"
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 rkeys = require 'rkeys'
imgui.HotKey = require ('imgui_addons').HotKey
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 cfg = inicfg.load({
    config = {
        arest = false,
        error = false,
        password = "",
        addoff = false,
        gamechenter = false,
        afktime = false,
        action = false,
        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.config.autologin)
local password = imgui.ImBuffer(''.. cfg.config.password, 256)
arest = imgui.ImBool(cfg.config.arest)
gamechenter = imgui.ImBool(cfg.config.gamechenter)
error = imgui.ImBool(cfg.config.error)
afktime = imgui.ImBool(cfg.config.afktime)
action = imgui.ImBool(cfg.config.action)
addoff = imgui.ImBool(cfg.config.addoff)

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

if cfg.hotkey == nil then
    cfg.hotkey = {
        bindLock = "[]",
        bindSbiv = "[]",
        bindPhone = "[]"
    }
end

---------------------- for statistic window.
_, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
nick = sampGetPlayerNickname(id)
hp = sampGetPlayerHealth(id)
lvl = sampGetPlayerScore(id)

function main()
    while not isSampAvailable() do wait(200) end
    sampRegisterChatCommand('opw', openmainwindow)
    sampRegisterChatCommand('leaders', function() sampSendChat("/leaders") ; windowleader.v = not windowleader.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
    end
end

local LockMenu = {
    v = decodeJson(cfg.hotkey.bindLock)
}

local SbivMenu = {
    v = decodeJson(cfg.hotkey.bindSbiv)
}

local PhoneMenu = {
    v = decodeJson(cfg.hotkey.bindPhone)
}

bindLock = rkeys.registerHotKey(LockMenu.v, true, LockFunc)
bindSbiv = rkeys.registerHotKey(SbivMenu.v, true, SbivFunc)
bindPhone = rkeys.registerHotKey(PhoneMenu.v, true, PhoneFunc)

function sampev.onServerMessage(color, text)
    if error.v then
        if text:find("Данная команда не существует. Используйте:") then
            return false
        end
    end
    if arest.v then
        if text:find("покинул игру во время погони") then
            return false
        end
    end
    if addoff.v then
        if text:find("Объявление:") and text:find('Проверил сотрудник Радио24:') then
            return false
        end
    end
    if gamechenter.v then
        if text:find('Игровой центр') then
            return false
        end
    end
    if afktime.v then
        if text:find('Вы простояли в AFK:') then
            return false
        end
    end
    if action.v then
        if text:find('Сегодня акция') and text:find('Акция X2') and text:find('Не забудьте подписаться на наше сообщество') and text:find('Подпишитесь на рассылку группы, чтобы не пропускать') then
            return false
        end
    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(50)
            imgui.SetCursorPosY(450)
            imgui.PushFont(fontsizefa25)
            if imgui.Button(fa.ICON_FA_SYNC_ALT ..'##RELOAD') then
                imgui.ShowCursor = false
                thisScript():reload()
                sampAddChatMessage(localscripttag.. 'Скрипт был успешно перезагружен!', -1)
            end
            imgui.PopFont()
            imgui.SetCursorPosX(30)
            imgui.SetCursorPosY(400)
            if imgui.Button(u8'Save Settings', imgui.ImVec2(140,30)) then -- Кнопка для сохранения настроек
                cfg.config.password = password.v
                cfg.config.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.SetCursorPosY(10)
            imgui.Checkbox(u8 " Автологин", autologin)
                imgui.SameLine()
                imgui.Hint(u8"При входе на сервер будет автоматически вводиться пароль")
            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.Separator()
    imgui.CenterText(u8'Функции для отключения мусора из чата')
    imgui.Separator()
    if imgui.CollapsingHeader(u8'Настройки') then
        if imgui.Checkbox(u8"Неизвестная команда", error) then
            if error.v == true then
                cfg.config.error = true
                inicfg.save(cfg, "Onfroy Family Helper.ini")
            end
            if error.v == false then
                cfg.config.error = false
                inicfg.save(cfg, "Onfroy Family Helper.ini")
            end
        end
        if imgui.Checkbox(u8'Вышел при попытке ареста', arest) then
            if arest.v == true then
                cfg.config.arest = true
                inicfg.save(cfg, "Onfroy Family Helper.ini")
            end
            if arest.v == false then
                cfg.config.arest = false
                inicfg.save(cfg, "Onfroy Family Helper.ini")
            end
        end
        if imgui.Checkbox(u8'Объявления', addoff) then
            if addoff.v == true then
                cfg.config.addoff = true
                inicfg.save(cfg, "Onfroy Family Helper.ini")
            end
            if addoff.v == false then
                cfg.config.addoff = false
                inicfg.save(cfg, "Onfroy Family Helper.ini")
            end
        end
        if imgui.Checkbox(u8'Игровой Центр', gamechenter) then
            if gamechenter.v == true then
                cfg.config.gamechenter = true
                inicfg.save(cfg, "Onfroy Family Helper.ini")
            end
            if gamechenter.v == false then
                cfg.config.gamechenter = false
                inicfg.save(cfg, "Onfroy Family Helper.ini")
            end
        end
        if imgui.Checkbox(u8'Время в АФК', afktime) then
            if afktime.v == true then
                cfg.config.afktime = true
                inicfg.save(cfg, "Onfroy Family Helper.ini")
            end
            if afktime.v == false then
                cfg.config.afktime = false
                inicfg.save(cfg, "Onfroy Family Helper.ini")
            end
        end
        if imgui.Checkbox(u8'Акции', action) then
            if action.v == true then
                cfg.config.action = true
                inicfg.save(cfg, "Onfroy Family Helper.ini")
            end
            if action.v == false then
                cfg.config.action = false
                inicfg.save(cfg, "Onfroy Family Helper.ini")
            end
        end
    end
    if imgui.CollapsingHeader(u8'Hot Keys') then
        imgui.Text(u8"Открыть/закрыть машину (/lock) ")
        
        if imgui.HotKey("##1", LockMenu, tLastKeys, 100) then
        rkeys.changeHotKey(bindLock, LockMenu.v)
        sampAddChatMessage("Успешно! Старое значение: {F4A460}" .. table.concat(rkeys.getKeysName(tLastKeys.v), " + ") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(LockMenu.v), " + "), -1)
        sampAddChatMessage("Строчное значение: {F4A460}" .. encodeJson(LockMenu.v), -1)
        cfg.hotkey.bindLock = encodeJson(LockMenu.v)
        inicfg.save(cfg, 'Onfroy Family Helper.ini')
        end
        
        imgui.Text(u8"Использовать очищение анимации ")
        imgui.SameLine()
        
        if imgui.HotKey("##2", SbivMenu, tLastKeys, 100) then
        rkeys.changeHotKey(bindSbiv, SbivMenu.v)
        sampAddChatMessage("Успешно! Старое значение: {F4A460}" .. table.concat(rkeys.getKeysName(tLastKeys.v), " + ") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(SbivMenu.v), " + "), -1)
        sampAddChatMessage("Строчное значение: {F4A460}" .. encodeJson(SbivMenu.v), -1)
        cfg.hotkey.bindSbiv = encodeJson(SbivMenu.v)
        inicfg.save(cfg, 'Onfroy Family Helper.ini')
        end
        
        imgui.Text(u8"Открыть телефон (/phone) ")
        imgui.SameLine()
        
        if imgui.HotKey("##3", PhoneMenu, tLastKeys, 100) then
        rkeys.changeHotKey(bindPhone, PhoneMenu.v)
        sampAddChatMessage("Успешно! Старое значение: {F4A460}" .. table.concat(rkeys.getKeysName(tLastKeys.v), " + ") .. "{ffffff} | Новое: {F4A460}" .. table.concat(rkeys.getKeysName(PhoneMenu.v), " + "), -1)
        sampAddChatMessage("Строчное значение: {F4A460}" .. encodeJson(PhoneMenu.v), -1)
        cfg.hotkey.bindPhone = encodeJson(PhoneMenu.v)
        inicfg.save(cfg, 'Onfroy Family Helper.ini')
        end
        
    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
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.config.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 @ARMOR @Rice.
 
  • Злость
  • Bug
Реакции: Loocking и qdIbp
Решение
Ошибка какая?
Нахуя это:
Lua:
if imgui.Checkbox(u8'Время в АФК', afktime) then
    if afktime.v == true then
        cfg.config.afktime = true
        inicfg.save(cfg, "Onfroy Family Helper.ini")
    end
    if afktime.v == false then
        cfg.config.afktime = false
        inicfg.save(cfg, "Onfroy Family Helper.ini")
    end
end
Если есть это:
Lua:
if imgui.Checkbox(u8'Время в АФК', afktime) then
    cfg.config.afktime = afktime.v
    inicfg.save(cfg, "Onfroy Family Helper.ini")
end

Rice.

https://t.me/riceoff
Модератор
1,681
1,383
Ошибка какая?
Нахуя это:
Lua:
if imgui.Checkbox(u8'Время в АФК', afktime) then
    if afktime.v == true then
        cfg.config.afktime = true
        inicfg.save(cfg, "Onfroy Family Helper.ini")
    end
    if afktime.v == false then
        cfg.config.afktime = false
        inicfg.save(cfg, "Onfroy Family Helper.ini")
    end
end
Если есть это:
Lua:
if imgui.Checkbox(u8'Время в АФК', afktime) then
    cfg.config.afktime = afktime.v
    inicfg.save(cfg, "Onfroy Family Helper.ini")
end
 
  • Нравится
Реакции: qdIbp

Kegwineye.

Участник
Автор темы
478
20
Ошибка какая?
Нахуя это:
Lua:
if imgui.Checkbox(u8'Время в АФК', afktime) then
    if afktime.v == true then
        cfg.config.afktime = true
        inicfg.save(cfg, "Onfroy Family Helper.ini")
    end
    if afktime.v == false then
        cfg.config.afktime = false
        inicfg.save(cfg, "Onfroy Family Helper.ini")
    end
end
Если есть это:
Lua:
if imgui.Checkbox(u8'Время в АФК', afktime) then
    cfg.config.afktime = afktime.v
    inicfg.save(cfg, "Onfroy Family Helper.ini")
end
что скажешь насчет того что крашется скрипт из-за
attempt to call field 'changeHotKey' (a nil value)
stack traceback: ?
 

Rice.

https://t.me/riceoff
Модератор
1,681
1,383
что скажешь насчет того что крашется скрипт из-за
attempt to call field 'changeHotKey' (a nil value)
stack traceback: ?
у тебя в ошибке сказано, что в changeHotKey у тебя используется переменная, которая равна nil, проверь конфиг
 

Kegwineye.

Участник
Автор темы
478
20
у тебя в ошибке сказано, что в changeHotKey у тебя используется переменная, которая равна nil, проверь конфиг
хуй с ней. скажи че не так со скриптом, он крашится
GTA_ San Andreas 08.10.2022 13_15_37.png


удалаю содержимое скрипта - все ок.
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 rkeys = require 'rkeys'
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 cfg = inicfg.load({
    config = {
        openchatfix = false,
        arest = false,
        error = false,
        password = "",
        addoff = false,
        addoff2 = false,
        gamechenter = false,
        afktime = false,
        action = false,
        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.config.autologin)
local password = imgui.ImBuffer(''.. cfg.config.password, 256)
openchatfix = imgui.ImBool(cfg.config.openchatfix)
arest = imgui.ImBool(cfg.config.arest)
gamechenter = imgui.ImBool(cfg.config.gamechenter)
error = imgui.ImBool(cfg.config.error)
afktime = imgui.ImBool(cfg.config.afktime)
action = imgui.ImBool(cfg.config.action)
addoff = imgui.ImBool(cfg.config.addoff)
addoff2 = imgui.ImBool(cfg.config.addoff2)

local colors = imgui.GetStyle().Colors;
local icol = imgui.Col
local ImVec4 = imgui.ImVec4
---------------------- for statistic window.

function main()
    while not isSampAvailable() do wait(200) end
    sampRegisterChatCommand('opw', openmainwindow)
    sampRegisterChatCommand('leaders', function() sampSendChat("/leaders") ; windowleader.v = not windowleader.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
    end
end

function sampev.onServerMessage(color, text)
    if error.v then
        if text:find("Данная команда не существует. Используйте:") then
            return false
        end
    end
    if arest.v then
        if text:find("покинул игру во время")  then
            return false
        end
    end
    if addoff.v then
        if text:find("Объявление:") then
            return false
        end
    end
    if addoff2.v then
        if text:find('Проверил сотрудник Радио24:') then
            return false
        end
    end
    if gamechenter.v then
        if text:find('Игровой центр') then
            return false
        end
    end
    if afktime.v then
        if text:find('Вы простояли в AFK:') then
            return false
        end
    end
    if action.v then
        if text:find('Акция X2') then
            return false
        end
    end
end

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

--------------------====[FIXES]====---------------------
if openchatfix.v then
    while true do
        if isKeyJustPressed(0x54 --[[VK_T]]) and not sampIsDialogActive() and not sampIsScoreboardOpen() and not isSampfuncsConsoleActive() then
            sampSetChatInputEnabled(true)
        end
    end
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(50)
            imgui.SetCursorPosY(450)
            imgui.PushFont(fontsizefa25)
            if imgui.Button(fa.ICON_FA_SYNC_ALT ..'##RELOAD') then
                imgui.ShowCursor = false
                thisScript():reload()
                sampAddChatMessage(localscripttag.. 'Скрипт был успешно перезагружен!', -1)
            end
            imgui.PopFont()
            imgui.SetCursorPosX(30)
            imgui.SetCursorPosY(400)
            if imgui.Button(u8'Save Settings', imgui.ImVec2(140,30)) then -- Кнопка для сохранения настроек
                cfg.config.password = password.v
                cfg.config.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.SetCursorPosY(10)
            imgui.Checkbox(u8 " Автологин", autologin)
                imgui.SameLine()
                imgui.Hint(u8"При входе на сервер будет автоматически вводиться пароль")
            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.Separator()
    imgui.CenterText(u8'Функции для отключения мусора из чата')
    imgui.Separator()
    if imgui.CollapsingHeader(u8'Настройки') then
        if imgui.Checkbox(u8"Неизвестная команда", error) then
            cfg.config.error = error.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
        if imgui.Checkbox(u8'Вышел при попытке ареста', arest) then
            cfg.config.arest = arest.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
        if imgui.Checkbox(u8'Объявления', addoff) then
            cfg.config.addoff = addoff.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
        imgui.SameLine()
        imgui.SetCursorPosX(220)
        if imgui.Checkbox(u8'Объявления ++', addoff2) then
            cfg.config.addoff2 = addoff2.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
        if imgui.Checkbox(u8'Игровой Центр', gamechenter) then
            cfg.config.gamechenter = gamechenter.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
        if imgui.Checkbox(u8'Время в АФК', afktime) then
            cfg.config.afktime = afktime.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
        if imgui.Checkbox(u8'Акции', action) then
            cfg.config.action = action.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
    end
    if imgui.CollapsingHeader(u8'Исправления') then
        if imgui.Checkbox(u8"Фикс чата", openchatfix) then
            cfg.config.openchatfix = openchatfix.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
        
        
    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
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 LockFunc()
    if not sampIsCursorActive() then
    sampSendChat("/lock") end
end

function SbivFunc()
    if isSampAvailable() and not sampIsDialogActive() and not sampIsChatInputActive() then
        wait(0)
            if isKeyDown(keys.VK_R) then
            wait(10)
        if not isCharInAnyCar(PLAYER_PED) then toggle = not toggle if toggle then freezeCharPosition(PLAYER_PED, true) else freezeCharPosition(PLAYER_PED, false) end end
            wait(10)
            if not isCharInAnyCar(PLAYER_PED) and not isCharOnAnyBike(PLAYER_PED) then
                clearCharTasksImmediately(PLAYER_PED) setPlayerControl(playerHandle, 1) freezeCharPosition(PLAYER_PED, false) restoreCameraJumpcut()
            end
        end
    end
end

function PhoneFunc()
    if PhoneMenu.v and not sampIsCursorActive() then
    sampSendChat("/phone") end
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.config.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()
 

Loocking

Известный
1,372
468
хуй с ней. скажи че не так со скриптом, он крашится
Посмотреть вложение 172296

удалаю содержимое скрипта - все ок.
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 rkeys = require 'rkeys'
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 cfg = inicfg.load({
    config = {
        openchatfix = false,
        arest = false,
        error = false,
        password = "",
        addoff = false,
        addoff2 = false,
        gamechenter = false,
        afktime = false,
        action = false,
        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.config.autologin)
local password = imgui.ImBuffer(''.. cfg.config.password, 256)
openchatfix = imgui.ImBool(cfg.config.openchatfix)
arest = imgui.ImBool(cfg.config.arest)
gamechenter = imgui.ImBool(cfg.config.gamechenter)
error = imgui.ImBool(cfg.config.error)
afktime = imgui.ImBool(cfg.config.afktime)
action = imgui.ImBool(cfg.config.action)
addoff = imgui.ImBool(cfg.config.addoff)
addoff2 = imgui.ImBool(cfg.config.addoff2)

local colors = imgui.GetStyle().Colors;
local icol = imgui.Col
local ImVec4 = imgui.ImVec4
---------------------- for statistic window.

function main()
    while not isSampAvailable() do wait(200) end
    sampRegisterChatCommand('opw', openmainwindow)
    sampRegisterChatCommand('leaders', function() sampSendChat("/leaders") ; windowleader.v = not windowleader.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
    end
end

function sampev.onServerMessage(color, text)
    if error.v then
        if text:find("Данная команда не существует. Используйте:") then
            return false
        end
    end
    if arest.v then
        if text:find("покинул игру во время")  then
            return false
        end
    end
    if addoff.v then
        if text:find("Объявление:") then
            return false
        end
    end
    if addoff2.v then
        if text:find('Проверил сотрудник Радио24:') then
            return false
        end
    end
    if gamechenter.v then
        if text:find('Игровой центр') then
            return false
        end
    end
    if afktime.v then
        if text:find('Вы простояли в AFK:') then
            return false
        end
    end
    if action.v then
        if text:find('Акция X2') then
            return false
        end
    end
end

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

--------------------====[FIXES]====---------------------
if openchatfix.v then
    while true do
        if isKeyJustPressed(0x54 --[[VK_T]]) and not sampIsDialogActive() and not sampIsScoreboardOpen() and not isSampfuncsConsoleActive() then
            sampSetChatInputEnabled(true)
        end
    end
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(50)
            imgui.SetCursorPosY(450)
            imgui.PushFont(fontsizefa25)
            if imgui.Button(fa.ICON_FA_SYNC_ALT ..'##RELOAD') then
                imgui.ShowCursor = false
                thisScript():reload()
                sampAddChatMessage(localscripttag.. 'Скрипт был успешно перезагружен!', -1)
            end
            imgui.PopFont()
            imgui.SetCursorPosX(30)
            imgui.SetCursorPosY(400)
            if imgui.Button(u8'Save Settings', imgui.ImVec2(140,30)) then -- Кнопка для сохранения настроек
                cfg.config.password = password.v
                cfg.config.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.SetCursorPosY(10)
            imgui.Checkbox(u8 " Автологин", autologin)
                imgui.SameLine()
                imgui.Hint(u8"При входе на сервер будет автоматически вводиться пароль")
            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.Separator()
    imgui.CenterText(u8'Функции для отключения мусора из чата')
    imgui.Separator()
    if imgui.CollapsingHeader(u8'Настройки') then
        if imgui.Checkbox(u8"Неизвестная команда", error) then
            cfg.config.error = error.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
        if imgui.Checkbox(u8'Вышел при попытке ареста', arest) then
            cfg.config.arest = arest.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
        if imgui.Checkbox(u8'Объявления', addoff) then
            cfg.config.addoff = addoff.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
        imgui.SameLine()
        imgui.SetCursorPosX(220)
        if imgui.Checkbox(u8'Объявления ++', addoff2) then
            cfg.config.addoff2 = addoff2.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
        if imgui.Checkbox(u8'Игровой Центр', gamechenter) then
            cfg.config.gamechenter = gamechenter.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
        if imgui.Checkbox(u8'Время в АФК', afktime) then
            cfg.config.afktime = afktime.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
        if imgui.Checkbox(u8'Акции', action) then
            cfg.config.action = action.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
    end
    if imgui.CollapsingHeader(u8'Исправления') then
        if imgui.Checkbox(u8"Фикс чата", openchatfix) then
            cfg.config.openchatfix = openchatfix.v
            inicfg.save(cfg, "Onfroy Family Helper.ini")
        end
       
       
    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
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 LockFunc()
    if not sampIsCursorActive() then
    sampSendChat("/lock") end
end

function SbivFunc()
    if isSampAvailable() and not sampIsDialogActive() and not sampIsChatInputActive() then
        wait(0)
            if isKeyDown(keys.VK_R) then
            wait(10)
        if not isCharInAnyCar(PLAYER_PED) then toggle = not toggle if toggle then freezeCharPosition(PLAYER_PED, true) else freezeCharPosition(PLAYER_PED, false) end end
            wait(10)
            if not isCharInAnyCar(PLAYER_PED) and not isCharOnAnyBike(PLAYER_PED) then
                clearCharTasksImmediately(PLAYER_PED) setPlayerControl(playerHandle, 1) freezeCharPosition(PLAYER_PED, false) restoreCameraJumpcut()
            end
        end
    end
end

function PhoneFunc()
    if PhoneMenu.v and not sampIsCursorActive() then
    sampSendChat("/phone") end
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.config.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()
Проверяй end везде
 

Kegwineye.

Участник
Автор темы
478
20
лишний врядли, скорее всего где то в имгуи неправильно его поставил, вот из за и крашит
как сделать открытие чата на русскую Е?
типо я создаю чекбокс openchatfix и как в функцию засунуть открытие чата на РУССКУЮ Е?