Палитра цветов mimgui - ошибка

boy next door

Участник
Автор темы
251
23
Версия MoonLoader
.026-beta
короче, делаю палитру цветов для замены текста в чате, но чёт пошло не так. помогите пожалуйста.
Lua:
[00:23:22.408001] (error)   custom chat argb.lua: E:\Games\16 pixeley\moonloader\custom chat argb.lua:69: bad argument #2 to 'ColorEdit4' (cannot convert 'number' to 'float *')
stack traceback:
    [C]: in function 'ColorEdit4'
    E:\Games\16 pixeley\moonloader\custom chat argb.lua:69: in function '_draw'
    E:\Games\16 pixeley\moonloader\lib\mimgui\init.lua:107: in function <E:\Games\16 pixeley\moonloader\lib\mimgui\init.lua:91>
[00:23:22.409004] (error)   custom chat argb.lua: Script died due to an error. (0991DB44)
Lua:
require('lib.moonloader')
local event = require('lib.samp.events')
local imgui = require 'mimgui'
local encoding = require 'encoding'
local ad = require 'ADDONS'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local new = imgui.new
local chatSettings = new.bool(false)

local directConfig = getWorkingDirectory()..'/config/customvipargb.json'
print(getWorkingDirectory())
local defaultTable =
{
    ['settings'] =
    {  
        ['color'] = 0xFFFF0000,
        ['active'] = false
    }
}
local sconfig = {}

if not doesFileExist(directConfig) then
    conf = assert(io.open(directConfig, 'w'), 'No permission to create file')
    conf:write(encodeJson(defaultTable))
    conf:close()
end
conf = io.open(directConfig, 'r')
local config = decodeJson(conf:read("*a"))
conf:close()
if type(config) ~= 'table' then config = defaultTable
else
    for i, v in pairs(defaultTable) do
        if type(config[i]) == 'table' then
            for i1, v1 in pairs(defaultTable[i]) do
                if type(config[i][i1]) ~= type(v1) then config[i][i1] = v1 end
            end
        elseif type(config[i]) ~= type(v) then config[i] = v end
    end
end
conf = io.open(directConfig, 'w')
conf:write(encodeJson(config))
conf:close()

local elements =
{
    value =
    {
        ['color'] = 0xFFFF0000,
        active = new.bool(config['settings']['active'])
    }
}


imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    local tmp = imgui.ColorConvertU32ToFloat4(config['settings']['color'])
    color = new.float[4](tmp.x, tmp.y, tmp.z, tmp.w)
end)

local newFrame = imgui.OnFrame(function() return chatSettings[0] end, function(player)
    local resX, resY = getScreenResolution()
    local sizeX, sizeY = 415, 200
    imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
    imgui.Begin('Custom chat', chatSettings, imgui.WindowFlags.NoResize)
    if ad.ToggleButton(u8'заменять цвет вип чата', elements.value.active) then
        if imgui.ColorEdit4(u8"ебучий цвет вип чата", elements.value.color) then
            config['settings']['color'] = imgui.ColorConvertFloat4ToU32(
                imgui.ImVec4( color[0], color[1], color[2], color[3] )
            )
        end
    end
    imgui.End()
end)

function argb2abgr(argb)
    local abgr = bit.bor(
        bit.lshift(bit.band(bit.rshift(argb, 24), 0xFF), 24),
        bit.lshift(bit.band(argb, 0xFF), 16),
        bit.lshift(bit.band(bit.rshift(argb, 8), 0xFF), 8),
        bit.band(bit.rshift(argb, 16), 0xFF)
    )
    return abgr
end

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('vvc', function() chatSettings[0] = not chatSettings[0] end)
    while true do wait(0)
    end
end


function event.onServerMessage(col, text)
    if elements.value.active[0] then
        if text:find('^%[Bronze VIP%]') then
            local viptext = text:gsub("%[Bronze VIP%]", "%[Bronze VIP%]")
            sampAddChatMessage(viptext, argb2abgr)
            return false
        end
        if text:find('^%[Silver VIP%]') then
            local viptext = text:gsub("%[Silver VIP%]", "%[Silver VIP%]")
            sampAddChatMessage(viptext, argb2abgr)
            return false
        end
        if text:find('^%[Gold VIP%]') then
            local viptext = text:gsub("%[Gold VIP%]", "%[Gold VIP%]")
            sampAddChatMessage(viptext, argb2abgr)
            return false
        end
    end
end

function saveConfig()
    conf = io.open(directConfig, 'w')
    conf:write(encodeJson(config))
    conf:close()
end

короче, делаю палитру цветов для замены текста в чате, но чёт пошло не так. помогите пожалуйста.
Lua:
[00:23:22.408001] (error)   custom chat argb.lua: E:\Games\16 pixeley\moonloader\custom chat argb.lua:69: bad argument #2 to 'ColorEdit4' (cannot convert 'number' to 'float *')
stack traceback:
    [C]: in function 'ColorEdit4'
    E:\Games\16 pixeley\moonloader\custom chat argb.lua:69: in function '_draw'
    E:\Games\16 pixeley\moonloader\lib\mimgui\init.lua:107: in function <E:\Games\16 pixeley\moonloader\lib\mimgui\init.lua:91>
[00:23:22.409004] (error)   custom chat argb.lua: Script died due to an error. (0991DB44)
Lua:
require('lib.moonloader')
local event = require('lib.samp.events')
local imgui = require 'mimgui'
local encoding = require 'encoding'
local ad = require 'ADDONS'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local new = imgui.new
local chatSettings = new.bool(false)

local directConfig = getWorkingDirectory()..'/config/customvipargb.json'
print(getWorkingDirectory())
local defaultTable =
{
    ['settings'] =
    { 
        ['color'] = 0xFFFF0000,
        ['active'] = false
    }
}
local sconfig = {}

if not doesFileExist(directConfig) then
    conf = assert(io.open(directConfig, 'w'), 'No permission to create file')
    conf:write(encodeJson(defaultTable))
    conf:close()
end
conf = io.open(directConfig, 'r')
local config = decodeJson(conf:read("*a"))
conf:close()
if type(config) ~= 'table' then config = defaultTable
else
    for i, v in pairs(defaultTable) do
        if type(config[i]) == 'table' then
            for i1, v1 in pairs(defaultTable[i]) do
                if type(config[i][i1]) ~= type(v1) then config[i][i1] = v1 end
            end
        elseif type(config[i]) ~= type(v) then config[i] = v end
    end
end
conf = io.open(directConfig, 'w')
conf:write(encodeJson(config))
conf:close()

local elements =
{
    value =
    {
        ['color'] = 0xFFFF0000,
        active = new.bool(config['settings']['active'])
    }
}


imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    local tmp = imgui.ColorConvertU32ToFloat4(config['settings']['color'])
    color = new.float[4](tmp.x, tmp.y, tmp.z, tmp.w)
end)

local newFrame = imgui.OnFrame(function() return chatSettings[0] end, function(player)
    local resX, resY = getScreenResolution()
    local sizeX, sizeY = 415, 200
    imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
    imgui.Begin('Custom chat', chatSettings, imgui.WindowFlags.NoResize)
    if ad.ToggleButton(u8'заменять цвет вип чата', elements.value.active) then
        if imgui.ColorEdit4(u8"ебучий цвет вип чата", elements.value.color) then
            config['settings']['color'] = imgui.ColorConvertFloat4ToU32(
                imgui.ImVec4( color[0], color[1], color[2], color[3] )
            )
        end
    end
    imgui.End()
end)

function argb2abgr(argb)
    local abgr = bit.bor(
        bit.lshift(bit.band(bit.rshift(argb, 24), 0xFF), 24),
        bit.lshift(bit.band(argb, 0xFF), 16),
        bit.lshift(bit.band(bit.rshift(argb, 8), 0xFF), 8),
        bit.band(bit.rshift(argb, 16), 0xFF)
    )
    return abgr
end

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('vvc', function() chatSettings[0] = not chatSettings[0] end)
    while true do wait(0)
    end
end


function event.onServerMessage(col, text)
    if elements.value.active[0] then
        if text:find('^%[Bronze VIP%]') then
            local viptext = text:gsub("%[Bronze VIP%]", "%[Bronze VIP%]")
            sampAddChatMessage(viptext, argb2abgr)
            return false
        end
        if text:find('^%[Silver VIP%]') then
            local viptext = text:gsub("%[Silver VIP%]", "%[Silver VIP%]")
            sampAddChatMessage(viptext, argb2abgr)
            return false
        end
        if text:find('^%[Gold VIP%]') then
            local viptext = text:gsub("%[Gold VIP%]", "%[Gold VIP%]")
            sampAddChatMessage(viptext, argb2abgr)
            return false
        end
    end
end

function saveConfig()
    conf = io.open(directConfig, 'w')
    conf:write(encodeJson(config))
    conf:close()
end
UPD:
Сделал код немного по иначе, теперь отображает хотя бы. Но проблема новая - не красит строчку из чата.
Lua:
require('lib.moonloader')
local event = require('lib.samp.events')
local imgui = require 'mimgui'
local encoding = require 'encoding'
local ad = require 'ADDONS'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local new = imgui.new
local chatSettings = new.bool(false)

local directConfig = getWorkingDirectory()..'/config/customvipargb.json'
print(getWorkingDirectory())
local defaultTable =
{
    ['settings'] =
    {   
        ['color'] = 0xFFFF0000,
        ['active'] = false
    }
}
local sconfig = {}

if not doesFileExist(directConfig) then
    conf = assert(io.open(directConfig, 'w'), 'No permission to create file')
    conf:write(encodeJson(defaultTable))
    conf:close()
end
conf = io.open(directConfig, 'r')
local config = decodeJson(conf:read("*a"))
conf:close()
if type(config) ~= 'table' then config = defaultTable
else
    for i, v in pairs(defaultTable) do
        if type(config[i]) == 'table' then
            for i1, v1 in pairs(defaultTable[i]) do
                if type(config[i][i1]) ~= type(v1) then config[i][i1] = v1 end
            end
        elseif type(config[i]) ~= type(v) then config[i] = v end
    end
end
conf = io.open(directConfig, 'w')
conf:write(encodeJson(config))
conf:close()

local elements =
{
    value =
    {
        ['color'] = 0xFFFF0000,
        active = new.bool(config['settings']['active'])
    }
}

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    local tmp = imgui.ColorConvertU32ToFloat4(config['settings']['color'])
    color = new.float[4](tmp.x, tmp.y, tmp.z, tmp.w)
end)

local newFrame = imgui.OnFrame(function() return chatSettings[0] end, function(player)
    local resX, resY = getScreenResolution()
    local sizeX, sizeY = 415, 200
    imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
    imgui.Begin('Custom chat', chatSettings, imgui.WindowFlags.NoResize)
    
    if ad.ToggleButton(u8'заменять цвет вип чата', elements.value.active) then
    end
    if elements.value.active[0] then
        if imgui.ColorEdit4(u8"ебучий цвет вип чата", color) then
            config['settings']['color'] = imgui.ColorConvertFloat4ToU32(imgui.ImVec4(color[0], color[1], color[2], color[3]))
        end
    end
    
    imgui.End()
end)

function argb2abgr(argb)
    local abgr = bit.bor(
        bit.lshift(bit.band(bit.rshift(argb, 24), 0xFF), 24),
        bit.lshift(bit.band(argb, 0xFF), 16),
        bit.lshift(bit.band(bit.rshift(argb, 8), 0xFF), 8),
        bit.band(bit.rshift(argb, 16), 0xFF)
    )
    return abgr
end

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('vvc', function() chatSettings[0] = not chatSettings[0] end)
    while true do wait(0)
    end
end


function event.onServerMessage(col, text)
    if elements.value.active[0] then
        if text:find('^%[Bronze VIP%]') then
            local viptext = text:gsub("%[Bronze VIP%]", "%[Bronze VIP%]")
            sampAddChatMessage(viptext, config['settings']['color'])
            return false
        end
        if text:find('^%[Silver VIP%]') then
            local viptext = text:gsub("%[Silver VIP%]", "%[Silver VIP%]")
            sampAddChatMessage(viptext, config['settings']['color'])
            return false
        end
        if text:find('^%[Gold VIP%]') then
            local viptext = text:gsub("%[Gold VIP%]", "%[Gold VIP%]")
            sampAddChatMessage(viptext, config['settings']['color'])
            return false
        end
    end
end

function saveConfig()
    conf = io.open(directConfig, 'w')
    conf:write(encodeJson(config))
    conf:close()
end
 
Последнее редактирование:

- |2347| -

Известный
366
120
вот попробуй

код:
require('lib.moonloader')
local event = require('lib.samp.events')
local imgui = require 'mimgui'
local encoding = require 'encoding'
local ad = require 'ADDONS'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local new = imgui.new
local chatSettings = new.bool(false)

local directConfig = getWorkingDirectory()..'/config/customvipargb.json'
print(getWorkingDirectory())
local defaultTable =
{
    ['settings'] =
    {   
        ['color'] = 0xFFFF0000,
        ['active'] = false
    }
}
local sconfig = {}

if not doesFileExist(directConfig) then
    conf = assert(io.open(directConfig, 'w'), 'No permission to create file')
    conf:write(encodeJson(defaultTable))
    conf:close()
end
conf = io.open(directConfig, 'r')
local config = decodeJson(conf:read("*a"))
conf:close()
if type(config) ~= 'table' then config = defaultTable
else
    for i, v in pairs(defaultTable) do
        if type(config[i]) == 'table' then
            for i1, v1 in pairs(defaultTable[i]) do
                if type(config[i][i1]) ~= type(v1) then config[i][i1] = v1 end
            end
        elseif type(config[i]) ~= type(v) then config[i] = v end
    end
end
conf = io.open(directConfig, 'w')
conf:write(encodeJson(config))
conf:close()

local elements =
{
    value =
    {
        ['color'] = 0xFFFF0000,
        active = new.bool(config['settings']['active'])
    }
}

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    local tmp = imgui.ColorConvertU32ToFloat4(config['settings']['color'])
    color = new.float[4](tmp.x, tmp.y, tmp.z, 1.0)
end)

local newFrame = imgui.OnFrame(function() return chatSettings[0] end, function(player)
    local resX, resY = getScreenResolution()
    local sizeX, sizeY = 415, 200
    imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
    imgui.Begin('Custom chat', chatSettings, imgui.WindowFlags.NoResize)
    
    if ad.ToggleButton(u8'заменять цвет вип чата', elements.value.active) then
    end
    if elements.value.active[0] then
        if imgui.ColorEdit3(u8"цвет вип чата", color) then
            config['settings']['color'] = imgui.ColorConvertFloat4ToU32(imgui.ImVec4(color[0], color[1], color[2], 1.0))
            saveConfig()
        end
    end
    
    imgui.End()
end)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('vvc', function() chatSettings[0] = not chatSettings[0] end)
    while true do wait(0)
    end
end

function hexToRgb(hex)
    local r, g, b = tonumber(hex:sub(2, 3), 16), tonumber(hex:sub(4, 5), 16), tonumber(hex:sub(6, 7), 16)
    return r, g, b
end

function event.onServerMessage(color, text)
    if elements.value.active[0] then
        if text:find('^%[Bronze VIP%]') then
            local color1 = config['settings']['color']
            local r, g, b = hexToRgb(string.format("#%06X", color1))
            return { bit.bor(bit.lshift(r, 16), bit.lshift(g, 8), b), text }
        end
        if text:find('^%[Silver VIP%]') then
            local color1 = config['settings']['color']
            local r, g, b = hexToRgb(string.format("#%06X", color1))
            return { bit.bor(bit.lshift(r, 16), bit.lshift(g, 8), b), text }
        end
        if text:find('^%[Gold VIP%]') then
            local color1 = config['settings']['color']
            local r, g, b = hexToRgb(string.format("#%06X", color1))
            return { bit.bor(bit.lshift(r, 16), bit.lshift(g, 8), b), text }
        end
    end
end

function saveConfig()
    conf = io.open(directConfig, 'w')
    conf:write(encodeJson(config))
    conf:close()
end
 

boy next door

Участник
Автор темы
251
23
вот попробуй

код:
require('lib.moonloader')
local event = require('lib.samp.events')
local imgui = require 'mimgui'
local encoding = require 'encoding'
local ad = require 'ADDONS'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local new = imgui.new
local chatSettings = new.bool(false)

local directConfig = getWorkingDirectory()..'/config/customvipargb.json'
print(getWorkingDirectory())
local defaultTable =
{
    ['settings'] =
    {  
        ['color'] = 0xFFFF0000,
        ['active'] = false
    }
}
local sconfig = {}

if not doesFileExist(directConfig) then
    conf = assert(io.open(directConfig, 'w'), 'No permission to create file')
    conf:write(encodeJson(defaultTable))
    conf:close()
end
conf = io.open(directConfig, 'r')
local config = decodeJson(conf:read("*a"))
conf:close()
if type(config) ~= 'table' then config = defaultTable
else
    for i, v in pairs(defaultTable) do
        if type(config[i]) == 'table' then
            for i1, v1 in pairs(defaultTable[i]) do
                if type(config[i][i1]) ~= type(v1) then config[i][i1] = v1 end
            end
        elseif type(config[i]) ~= type(v) then config[i] = v end
    end
end
conf = io.open(directConfig, 'w')
conf:write(encodeJson(config))
conf:close()

local elements =
{
    value =
    {
        ['color'] = 0xFFFF0000,
        active = new.bool(config['settings']['active'])
    }
}

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    local tmp = imgui.ColorConvertU32ToFloat4(config['settings']['color'])
    color = new.float[4](tmp.x, tmp.y, tmp.z, 1.0)
end)

local newFrame = imgui.OnFrame(function() return chatSettings[0] end, function(player)
    local resX, resY = getScreenResolution()
    local sizeX, sizeY = 415, 200
    imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
    imgui.Begin('Custom chat', chatSettings, imgui.WindowFlags.NoResize)
   
    if ad.ToggleButton(u8'заменять цвет вип чата', elements.value.active) then
    end
    if elements.value.active[0] then
        if imgui.ColorEdit3(u8"цвет вип чата", color) then
            config['settings']['color'] = imgui.ColorConvertFloat4ToU32(imgui.ImVec4(color[0], color[1], color[2], 1.0))
            saveConfig()
        end
    end
   
    imgui.End()
end)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('vvc', function() chatSettings[0] = not chatSettings[0] end)
    while true do wait(0)
    end
end

function hexToRgb(hex)
    local r, g, b = tonumber(hex:sub(2, 3), 16), tonumber(hex:sub(4, 5), 16), tonumber(hex:sub(6, 7), 16)
    return r, g, b
end

function event.onServerMessage(color, text)
    if elements.value.active[0] then
        if text:find('^%[Bronze VIP%]') then
            local color1 = config['settings']['color']
            local r, g, b = hexToRgb(string.format("#%06X", color1))
            return { bit.bor(bit.lshift(r, 16), bit.lshift(g, 8), b), text }
        end
        if text:find('^%[Silver VIP%]') then
            local color1 = config['settings']['color']
            local r, g, b = hexToRgb(string.format("#%06X", color1))
            return { bit.bor(bit.lshift(r, 16), bit.lshift(g, 8), b), text }
        end
        if text:find('^%[Gold VIP%]') then
            local color1 = config['settings']['color']
            local r, g, b = hexToRgb(string.format("#%06X", color1))
            return { bit.bor(bit.lshift(r, 16), bit.lshift(g, 8), b), text }
        end
    end
end

function saveConfig()
    conf = io.open(directConfig, 'w')
    conf:write(encodeJson(config))
    conf:close()
end
оно то типо работает, но выдаёт совсем разные цвета. вот я поставил оранжевый - выдаёт зелёный.
 

- |2347| -

Известный
366
120
вот

dd:
require('lib.moonloader')
local event = require('lib.samp.events')
local imgui = require 'mimgui'
local encoding = require 'encoding'
local ad = require 'ADDONS'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local new = imgui.new
local chatSettings = new.bool(false)

local directConfig = getWorkingDirectory()..'/config/customvipargb.ini'
print(getWorkingDirectory())

local defaultTable = {
    color = 0xFFFF0000,
    active = false
}

local config = {}
if not doesFileExist(directConfig) then
    local conf = assert(io.open(directConfig, 'w'), 'No permission to create file')
    conf:write("[Settings]\n")
    conf:write("color=" .. string.format("0x%08X", defaultTable.color) .. "\n")
    conf:write("active=" .. tostring(defaultTable.active) .. "\n")
    conf:close()
end

local function loadConfig()
    local conf = io.open(directConfig, 'r')
    if conf then
        for line in conf:lines() do
            local key, value = line:match("^(%w+)=(.*)$")
            if key and value then
                config[key] = value:match("^0x") and tonumber(value) or (value == "true")
            end
        end
        conf:close()
    else
        config = defaultTable
    end

    for k, v in pairs(defaultTable) do
        if config[k] == nil then
            config[k] = v
        end
    end
end

local function saveConfig()
    local conf = io.open(directConfig, 'w')
    conf:write("[Settings]\n")
    conf:write("color=" .. string.format("0x%08X", config.color) .. "\n")
    conf:write("active=" .. tostring(config.active) .. "\n")
    conf:close()
end

loadConfig()

local elements = {
    value = {
        color = 0xFFFF0000,
        active = new.bool(config.active)
    }
}

imgui.OnInitialize(function()
    imgui.GetIO().IniFilename = nil
    local tmp = imgui.ColorConvertU32ToFloat4(config.color)
    color = new.float[4](tmp.x, tmp.y, tmp.z, 1.0)
end)

local newFrame = imgui.OnFrame(function() return chatSettings[0] end, function(player)
    local resX, resY = getScreenResolution()
    local sizeX, sizeY = 415, 200
    imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
    imgui.Begin('Custom chat', chatSettings, imgui.WindowFlags.NoResize)
  
    if ad.ToggleButton(u8'заменять цвет вип чата', elements.value.active) then
        config.active = elements.value.active[0]
        saveConfig()
    end
    
    if elements.value.active[0] then
        if imgui.ColorEdit3(u8"цвет вип чата", color) then
            local clr = join_argb(0, color[2] * 255, color[1] * 255, color[0] * 255)
            config.color = clr
            saveConfig()
        end
    end

    imgui.End()
end)

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('vvc', function() chatSettings[0] = not chatSettings[0] end)
    while true do wait(0) end
end

function join_argb(a, b, g, r)
    local argb = b
    argb = bit.bor(argb, bit.lshift(g, 8))
    argb = bit.bor(argb, bit.lshift(r, 16))
    argb = bit.bor(argb, bit.lshift(a, 24))
    return argb
end

function event.onServerMessage(color, text)
    if elements.value.active[0] then
        if text:find('^%[Bronze VIP%]') then
            local color1 = config.color
            sampAddChatMessage(text, color1)
            return false 
        end

        if text:find('^%[Silver VIP%]') then
            local color1 = config.color
            sampAddChatMessage(text, color1)
            return false 
        end
        
        if text:find('^%[Gold VIP%]') then
            local color1 = config.color
            sampAddChatMessage(text, color1)
            return false 
        end
    end
end