- 64
- 9
- Версия MoonLoader
- .027.0-preview
Делал скрипт для репорта но почему-то не сохраняется конфиг, парсил ник и айди
Код:
local sampev = require 'lib.samp.events'
local ffi = require("ffi")
local gta = ffi.load("GTASA")
local imgui = require("mimgui")
local encoding = require("encoding")
encoding.default = "CP1251"
local u8 = encoding.UTF8
local new = imgui.new
local faicons = require("fAwesome6")
local fa = faicons
-- Инициализация конфигурации
local inicfg = require "inicfg"
local ini = inicfg.load({
cfg = {
id = "null",
nick = "null",
idrep = "null"
}
}, "rephelp.ini")
local WinState = imgui.new.bool()
-- Функция сохранения конфигурации
function cfg_save()
pcall(function()
inicfg.save(ini, "rephelp.ini")
sampAddChatMessage("Конфигурация сохранена", -1)
end)
end
imgui.OnFrame(function()
return WinState[0]
end, function(player)
local sizeX, sizeY = getScreenResolution()
imgui.SetNextWindowPos(imgui.ImVec2(sizeX / 2, sizeY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(1200, 910), imgui.Cond.FirstUseEver)
imgui.Begin(u8'ArepHelp', WinState, imgui.WindowFlags.AlwaysAutoResize)
if imgui.Button(u8"Слежу", imgui.ImVec2(180, 80)) then
sampSendDialogResponse(5753, 1, 0, "Слежу")
sampSendChat("тест "..ini.cfg.nick)
WinState[0] = false
end
imgui.SameLine()
if imgui.Button(u8"Иду", imgui.ImVec2(180, 80)) then
sampSendDialogResponse(5753, 1, 0, "Иду к вам")
sampSendChat("/g ")
WinState[0] = false
end
imgui.SameLine()
if imgui.Button(u8"Работаю по жб", imgui.ImVec2(180, 80)) then
sampSendDialogResponse(5753, 1, 0, " | Работаю по вашей жалобе |")
sampSendChat("тест "..ini.cfg.nick)
WinState[0] = false
end
if imgui.IsWindowAppearing() then
cfg_save()
end
imgui.End()
end)
function sampev.onShowDialog(id, style, title, button1, button2, text)
if id == 5753 then
WinState[0] = true
local match = text:match('Жалоба от: (%a+_%a+)%[(%d+)%]')
if match then
local nick, id = match:match('(%a+_%a+)%[(%d+)%]')
if nick and id then
ini.cfg.id = id
ini.cfg.nick = nick
cfg_save()
sampAddChatMessage("Сохранено: ID="..id..", Ник="..nick, -1)
end
end
end
end
function main()
sampRegisterChatCommand('reps', function()
WinState[0] = not WinState[0]
cfg_save()
end)
wait(-1)
end