require('lib.moonloader')
require('encoding').default = 'CP1251'
local u8 = require('encoding').UTF8
local imgui = require 'mimgui'
local inicfg = require 'inicfg'
local new, str = imgui.new, ffi.string
-- Конфиг
local settings = inicfg.load({
setting =
{
inputsaved = '', -- значение инпута
checkboxstatus = false, -- значение чекбокса
}}, 'FrapsHelper.ini')
-- Окна
local WinState, show = imgui.new.bool(), imgui.new.bool()
local checkboxone = new.bool(settings.setting.checkboxstatus)
local inputt = new.char[256](u8(settings.setting.inputsaved))
function imgui.ColSeparator(hex,trans)
local r,g,b = tonumber("0x"..hex:sub(1,2)), tonumber("0x"..hex:sub(3,4)), tonumber("0x"..hex:sub(5,6))
if tonumber(trans) ~= nil and tonumber(trans) < 101 and tonumber(trans) > 0 then a = trans else a = 100 end
imgui.PushStyleColor(imgui.Col.Separator, imgui.ImVec4(r/255, g/255, b/255, a/100))
local colsep = imgui.Separator()
imgui.PopStyleColor(1)
return colsep
end
function imgui.ColoredButton(text,hex,trans,size)
local r,g,b = tonumber("0x"..hex:sub(1,2)), tonumber("0x"..hex:sub(3,4)), tonumber("0x"..hex:sub(5,6))
if tonumber(trans) ~= nil and tonumber(trans) < 101 and tonumber(trans) > 0 then a = trans else a = 60 end
imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(r/255, g/255, b/255, a/100))
imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(r/255, g/255, b/255, a/100))
imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(r/255, g/255, b/255, a/100))
local button = imgui.Button(text, size)
imgui.PopStyleColor(3)
return button
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.ImVec4(r/255, g/255, b/255, a/255)
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
local sizeX = imgui.GetIO().DisplaySize.x -- Получаем ширину дисплея
local sizeY = imgui.GetIO().DisplaySize.y -- Получаем высоту дисплея
imgui.OnFrame(function() return show[0] and not isGamePaused() end, function()
imgui.SetNextWindowPos(imgui.ImVec2(sizeX / 8.5, sizeY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(300, 370)) -- Размер окна
imgui.Begin('Window Two', show, imgui.WindowFlags.NoDecoration)
imgui.ColSeparator('7BFF00', 100)
imgui.ColSeparator('7BFF00', 100)
if imgui.TextColoredRGB(u8'{FF0000}TG Author: @Diego_skuf{FF0000}')then
end
imgui.ColSeparator('7BFF00', 100)
imgui.ColSeparator('7BFF00',100)
-- Кнопка "Time"
if imgui.ColoredButton(u8'/time', '80FF00', 50,imgui.ImVec2(150, 50)) then
sampSendChat("/time")
end
imgui.SameLine()
-- Кнопка "/id"
if imgui.ColoredButton(u8"/id", "80FF00",50, imgui.ImVec2(150, 50)) then
sampSendChat("/id " .. select(2, sampGetPlayerIdByCharHandle(PLAYER_PED)))
end
imgui.ColSeparator('7BFF00', 100)
imgui.ColSeparator('7BFF00',100)
-- Кнопка "/showpass"
if imgui.ColoredButton(u8" Passport My", '80FF00', 50, imgui.ImVec2(150, 50)) then
sampSendChat("/showpass Justin_Williams")
end
imgui.SameLine()
-- Кнопка "/jobprogress"
if imgui.ColoredButton(u8"Успеваемость", '80FF00', 50, imgui.ImVec2(150, 50)) then
sampSendChat("/jobprogress")
end
imgui.ColSeparator('7BFF00', 100)
imgui.ColSeparator('7BFF00', 100)
-- Кнопка "/members "
if imgui.ColoredButton(u8"Мемберс", '80FF00', 50, imgui.ImVec2(150, 50)) then
sampSendChat ("/members")
end
imgui.SameLine()
if imgui.ColoredButton(u8"Статс", '80FF00', 50, imgui.ImVec2(150, 50)) then
sampSendChat ("/stats")
end
imgui.ColSeparator('7BFF00',100)
imgui.ColSeparator('7BFF00',100)
imgui.End()
end).HideCursor = true -- HideCursor отвечает за то, чтобы курсор не показывался
imgui.OnFrame(function() return WinState[0] end, function(player)
imgui.SetNextWindowPos(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(245, 280), imgui.Cond.Always)
imgui.Begin('Window One', WinState, imgui.WindowFlags.NoResize + imgui.WindowFlags.AlwaysAutoResize)
if imgui.Button('Open new window') then -- вкл/выкл второе окошко
show[0] = not show[0]
end
if imgui.InputText('##Add', inputt, 256) then
settings.setting.inputsaved = u8:decode(str(inputt)) -- значение вписывается в конфиг
inicfg.save(settings, 'FrapsHelper.ini') -- конфиг сохраняется
end
if imgui.Checkbox(u8' ',checkboxone) then -- , ,
settings.setting.checkboxstatus = checkboxone[0] --
inicfg.save(settings, 'FrapsHelper.ini') --
end
imgui.Text(u8'() '..(settings.nigger.checkboxstatus and u8'' or u8''))
imgui.Text(u8'() '..(checkboxone[0] and u8'' or u8''))
-- --
imgui.SameLine()
if imgui.Button(u8'Очистить строчку') then -- по этой кнопке можно очистить значение в конфиге
imgui.StrCopy(inputt, '') -- очищает поле инпута
settings.setting.inputsaved = ''
inicfg.save(settings, 'FrapsHelper.ini')
end
imgui.End()
end)
function main()
sampRegisterChatCommand('cmd', function() WinState[0] = not WinState[0] end)
while true do wait(0)
if changepos then -- редактирование позиции окошка, его можно впихнуть и в сам мимгуи
posX, posY = getCursorPos() -- функция позволяет получить координаты курсора на экране
if isKeyJustPressed(1) then -- если нажата ЛКМ, то сохраняем позицию
changepos = false
end
end
end
end