- 37
- 4
- Версия MoonLoader
- .026-beta
Помогите. Если менять значение в инпут тексте то всё норм, сохраняется, но при перезагрузке скрипта третий четвёртый и пятый слот возвращают значение второго, не понимаю что не так
Lua:
script_author('HeroIAm') -- не меняй или гей лох чмо урод
require "lib.moonloader"
local vkeys = require 'vkeys'
local sampev = require 'lib.samp.events'
local inicfg = require 'inicfg'
local vkeys = require 'vkeys'
local sw, sh = getScreenResolution()
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local cfg = inicfg.load({
Settings = {
call1 = "f",
call2 = "f",
call3 = "f",
call4 = "f",
call5 = "f"
}
}, 'auto_callsign')
local main_window = imgui.ImBool(false)
combo = imgui.ImInt(0)
arr = {"first", "second", "third"}
ch_m = imgui.ImInt(1)
call1 = imgui.ImBuffer(146)
call2 = imgui.ImBuffer(146)
call3 = imgui.ImBuffer(146)
call4 = imgui.ImBuffer(146)
call5 = imgui.ImBuffer(146)
call1.v = cfg.Settings.call1
call2.v = cfg.Settings.call2
call3.v = cfg.Settings.call2
call4.v = cfg.Settings.call2
call5.v = cfg.Settings.call2
function showmenu()
main_window.v = not main_window.v
imgui.Process = main_window.v
end
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
if not doesFileExist(getWorkingDirectory()..'/config/auto_callsign.ini') then
inicfg.save(cfg, 'auto_callsign.ini')
end
sampAddChatMessage('{0099ff}[Auto Callsign] {ffffff}Скрипт загружен [BETA]. Автор: HeroIAm.', 0x0099ff)
theme()
sampRegisterChatCommand('setc', setc)
sampRegisterChatCommand('ac', showmenu)
end
function imgui.OnDrawFrame()
if main_window.v then
imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(400, 280), imgui.Cond.FirstUseEver)
imgui.Begin("Auto Callsign by Hero", main_window, imgui.WindowFlags.NoResize)
imgui.SetCursorPosX(125)
imgui.Text(u8"Режимы")
imgui.RadioButton(u8"Авто",ch_m, 1)
imgui.SameLine()
imgui.SetCursorPosX(250)
imgui.RadioButton(u8"Ручной",ch_m, 2)
if ch_m.v == 2 then
imgui.Text(u8"В ручном режиме используйте /setc для установки callsign")
else
imgui.Text("")
end
imgui.Combo(u8"Слоты", combo, u8"Первый\0Второй\0Третий\0Четвёртый\0Пятый\0\0", 146)
if combo.v == 0 then
imgui.InputText('##1', call1)
end
if combo.v == 1 then
imgui.InputText('##2', call2)
end
if combo.v == 2 then
imgui.InputText('##3', call3)
end
if combo.v == 3 then
imgui.InputText('##4', call4)
end
if combo.v == 4 then
imgui.InputText('##5', call5)
end
if imgui.Button(u8"Сохранить") then
cfg.Settings.call1 = call1.v
cfg.Settings.call2 = call2.v
cfg.Settings.call3 = call3.v
cfg.Settings.call4 = call4.v
cfg.Settings.call5 = call5.v
inicfg.save(cfg, 'auto_callsign.ini')
imgui.SameLine()
imgui.Text(u8"Настройки успешно сохранены.")
else
imgui.SameLine()
imgui.Text("")
end
imgui.Text("Combo: "..combo.v)
imgui.End()
end
end
local sampev = require 'lib.samp.events'
function sampev.onSendEnterVehicle(vehId, pass)
lua_thread.create(function()
if ch_m.v == 1 then
if not pass then
lua_thread.create(function()
while not isCharInAnyCar(PLAYER_PED) do wait(0) end
setc()
end)
end
end
end)
end
function setc()
lua_thread.create(function()
if combo.v == 0 then
sampSendChat('/callsign')
wait(30)
sampSendDialogResponse(32700, 1, nil, u8:decode(" " ..call1.v))
end
if combo.v == 1 then
sampSendChat('/callsign')
wait(30)
sampSendDialogResponse(32700, 1, nil, u8:decode(" " ..call2.v))
end
if combo.v == 2 then
sampSendChat('/callsign')
wait(30)
sampSendDialogResponse(32700, 1, nil, u8:decode(" " ..call3.v))
end
if combo.v == 3 then
sampSendChat('/callsign')
wait(30)
sampSendDialogResponse(32700, 1, nil, u8:decode(" " ..call4.v))
end
if combo.v == 4 then
sampSendChat('/callsign')
wait(30)
sampSendDialogResponse(32700, 1, nil, u8:decode(" " ..call5.v))
end
end)
end
function theme()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
local ImVec2 = imgui.ImVec2
style.WindowPadding = ImVec2(10, 10)
style.WindowRounding = 16
style.ChildWindowRounding = 2
style.FramePadding = ImVec2(5, 4)
style.FrameRounding = 2
style.ItemSpacing = ImVec2(4, 4)
style.TouchExtraPadding = ImVec2(0, 0)
style.IndentSpacing = 21
style.ScrollbarSize = 15
style.ScrollbarRounding = 0
style.GrabMinSize = 10
style.GrabRounding = 1
style.WindowTitleAlign = ImVec2(0.5, 0.5)
style.ButtonTextAlign = ImVec2(0.5, 0.5)
colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.TextDisabled] = ImVec4(0.73, 0.75, 0.74, 1.00)
colors[clr.WindowBg] = ImVec4(0.00, 0.00, 0.00, 0.80)
colors[clr.ChildWindowBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94)
colors[clr.Border] = ImVec4(0.00, 0.60, 1.00, 0.00)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.FrameBg] = ImVec4(0.00, 0.17, 0.28, 1.00)
colors[clr.FrameBgHovered] = ImVec4(0.00, 0.60, 1.00, 0.5)
colors[clr.FrameBgActive] = ImVec4(0.00, 0.60, 1.00, 0.7)
colors[clr.TitleBg] = ImVec4(0.00, 0.60, 1.00, 0.33)
colors[clr.TitleBgActive] = ImVec4(0.00, 0.60, 1.00, 0.33)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.60, 1.00, 0.33)
colors[clr.MenuBarBg] = ImVec4(0.34, 0.16, 0.16, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.53)
colors[clr.ScrollbarGrab] = ImVec4(0.31, 0.31, 0.31, 1.00)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.41, 0.41, 0.41, 1.00)
colors[clr.ScrollbarGrabActive] = ImVec4(0.51, 0.51, 0.51, 1.00)
colors[clr.ComboBg] = ImVec4(0.20, 0.20, 0.20, 0.99)
colors[clr.CheckMark] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.SliderGrab] = ImVec4(0.00, 0.60, 1.00, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.84, 0.66, 0.66, 1.00)
colors[clr.Button] = ImVec4(0.00, 0.60, 1.00, 0.33)
colors[clr.ButtonHovered] = ImVec4(0.71, 0.39, 0.39, 0.65)
colors[clr.ButtonActive] = ImVec4(0.20, 0.20, 0.20, 0.50)
colors[clr.Header] = ImVec4(0.71, 0.39, 0.39, 0.54)
colors[clr.HeaderHovered] = ImVec4(0.84, 0.66, 0.66, 0.65)
colors[clr.HeaderActive] = ImVec4(0.84, 0.66, 0.66, 0.00)
colors[clr.Separator] = ImVec4(0.43, 0.43, 0.50, 0.50)
colors[clr.SeparatorHovered] = ImVec4(0.71, 0.39, 0.39, 0.54)
colors[clr.SeparatorActive] = ImVec4(0.71, 0.39, 0.39, 0.54)
colors[clr.ResizeGrip] = ImVec4(0.71, 0.39, 0.39, 0.54)
colors[clr.ResizeGripHovered] = ImVec4(0.84, 0.66, 0.66, 0.66)
colors[clr.ResizeGripActive] = ImVec4(0.84, 0.66, 0.66, 0.66)
colors[clr.CloseButton] = ImVec4(0.41, 0.41, 0.41, 1.00)
colors[clr.CloseButtonHovered] = ImVec4(0.98, 0.39, 0.36, 1.00)
colors[clr.CloseButtonActive] = ImVec4(0.98, 0.39, 0.36, 1.00)
colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00)
colors[clr.PlotLinesHovered] = ImVec4(1.00, 0.43, 0.35, 1.00)
colors[clr.PlotHistogram] = ImVec4(0.90, 0.70, 0.00, 1.00)
colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
colors[clr.TextSelectedBg] = ImVec4(0.26, 0.59, 0.98, 0.35)
colors[clr.ModalWindowDarkening] = ImVec4(0.80, 0.80, 0.80, 0.35)
end