local imgui = require 'mimgui'
local ffi = require 'ffi'
local inicfg = require 'inicfg'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local directIni = 'filename.ini'
local ini = inicfg.load(inicfg.load({
main = {
text = ''
},
}, directIni))
inicfg.save(ini, directIni)
local renderWindow = imgui.new.bool(false)
local char = imgui.new.char[64](u8(ini.main.text))
imgui.OnFrame(function() return renderWindow[0] end, function(player)
local resX, resY = getScreenResolution(ini.main.text)
imgui.SetNextWindowPos(imgui.ImVec2(resX / 2, resY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(300, 300), imgui.Cond.FirstUseEver)
imgui.Begin('pisun', renderWindow)
imgui.InputText('inputtext', char, 64)
if imgui.Button('send') then
sampSendChat(u8:decode(ffi.string(char)))
end
if imgui.Button('Save INI') then
sampAddChatMessage(ini.main.text, -1)
ini.main.text = u8:decode(ffi.string(char))
inicfg.save(ini, directIni)
end
imgui.End()
end)
function main()
sampRegisterChatCommand('mimgui', function() renderWindow[0] = not renderWindow[0] end)
end