local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local color = imgui.ImFloat4(1, 0, 0, 1)
local window = imgui.ImBool(false)
function main()
while not isSampAvailable() do wait(200) end
imgui.Process = false
window.v = true --show window on start
while true do
wait(0)
imgui.Process = window.v
end
end
function imgui.OnDrawFrame()
if window.v then
local resX, resY = getScreenResolution()
local sizeX, sizeY = 300, 300 -- 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', window)
--window code
imgui.ColorEdit4('Color Picker', color)
if imgui.Button('Get HEX', imgui.ImVec2(100, 20)) then
sampAddChatMessage('TEXT WITH COLOR', join_argb(color.v[4] * 255, color.v[1] * 255, color.v[2] * 255, color.v[3] * 255))
end
imgui.Text('HEX: '..intToHex(join_argb(color.v[4] * 255, color.v[1] * 255, color.v[2] * 255, color.v[3] * 255)))
imgui.End()
end
end
function join_argb(a, r, g, b)
local argb = b -- b
argb = bit.bor(argb, bit.lshift(g, 8)) -- g
argb = bit.bor(argb, bit.lshift(r, 16)) -- r
argb = bit.bor(argb, bit.lshift(a, 24)) -- a
return argb
end
function intToHex(int)
return '{'..string.sub(bit.tohex(int), 3, 8)..'}'
end