local sampev = require('lib.samp.events')
local imgui = require 'mimgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local renderWindow = imgui.new.bool()
imgui.OnInitialize(function()
imgui.GetIO().IniFilename = nil
end)
local punishes = {}
local newFrame = imgui.OnFrame(
function() return renderWindow[0] end,
function(player)
local resX, resY = getScreenResolution()
local sizeX, sizeY = 300, 300
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)
if imgui.Begin('Main Window', renderWindow) then
for k, v in ipairs(punishes) do
if imgui.CollapsingHeader(u8("Дата: " .. v.date .. ", Причина: " .. v.reason)) then
if imgui.Button(u8'Дать леща') then
sampAddChatMessage('Дали леща', -1)
end
imgui.SameLine()
if imgui.Button(u8'Сломать колени') then
sampAddChatMessage('Не смогли сломать колени', -1)
end
end
end
if #punishes < 1 then
imgui.Text(u8'Тут пока что пусто')
end
imgui.End()
end
end
)
function main()
while not isSampAvailable() do wait(0) end
sampRegisterChatCommand('nakaz', function()
renderWindow[0] = not renderWindow[0]
end)
wait(-1)
end
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
if title:find('История наказания') then
for line in text:gmatch("[^\r\n]+") do
local date, situation, reason = line:match('{.-}%[(.-)%]%s(.+)%. Причина:%s(.+)')
if date and reason then
local punishment = {date = date, reason = reason}
table.insert(punishes, punishment)
end
end
end
end