--[[ __ .__ .__ _/ |_____________ |__| ____ |__| ____ ____ \ __\_ __ \__ \ | |/ \| |/ \ / ___\ | | | | \// __ \| | | \ | | \/ /_/ > |__| |__| (____ /__|___| /__|___| /\___ / \/ \/ \//_____/ ARIZONA TRAINING 2.0 made by Terror_Punisher for ARIZONA TRAINING 2.0 t.me/arztraining with love <3 trrpnsher ]] --[[ ]] require 'lib.moonloader' require "sampfuncs" local encoding = require 'encoding' encoding.default = 'CP1251' local u8 = encoding.UTF8 local sampev = require "lib.samp.events" local imgui = require "imgui" local inicfg = require 'inicfg' local srvip = "62.60.149.60" local port = 7777 local cfg_dir = getWorkingDirectory() .. "\\config" local cfg_name = "training" local cfg = { main = { nickname = "" } } local lstpress = 0 local showGUI = imgui.ImBool(false) local customNick = imgui.ImBuffer("", 256) local replaced = false function imgui.TextCentered(text) local width = imgui.GetWindowSize().x local calc = imgui.CalcTextSize(text) imgui.SetCursorPosX((width - calc.x) / 2) imgui.Text(text) end local function darkth() local style = imgui.GetStyle() local colors = style.Colors style.WindowRounding = 8.0 style.FrameRounding = 5.0 style.ScrollbarRounding = 8.0 style.GrabRounding = 5.0 style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5) style.WindowPadding = imgui.ImVec2(15, 15) style.FramePadding = imgui.ImVec2(10, 8) style.ItemSpacing = imgui.ImVec2(10, 10) colors[imgui.Col.Text] = imgui.ImVec4(0.95, 0.96, 0.98, 1.00) colors[imgui.Col.TextDisabled] = imgui.ImVec4(0.50, 0.50, 0.50, 1.00) colors[imgui.Col.WindowBg] = imgui.ImVec4(0.11, 0.11, 0.14, 1.00) colors[imgui.Col.PopupBg] = imgui.ImVec4(0.11, 0.11, 0.14, 0.95) colors[imgui.Col.Border] = imgui.ImVec4(0.22, 0.22, 0.26, 1.00) colors[imgui.Col.BorderShadow] = imgui.ImVec4(0.00, 0.00, 0.00, 0.00) colors[imgui.Col.FrameBg] = imgui.ImVec4(0.18, 0.18, 0.22, 1.00) colors[imgui.Col.FrameBgHovered] = imgui.ImVec4(0.24, 0.24, 0.28, 1.00) colors[imgui.Col.FrameBgActive] = imgui.ImVec4(0.28, 0.28, 0.33, 1.00) colors[imgui.Col.TitleBg] = imgui.ImVec4(0.15, 0.15, 0.18, 1.00) colors[imgui.Col.TitleBgActive] = imgui.ImVec4(0.17, 0.15, 0.22, 1.00) colors[imgui.Col.TitleBgCollapsed] = imgui.ImVec4(0.11, 0.11, 0.14, 1.00) colors[imgui.Col.Button] = imgui.ImVec4(0.85, 0.50, 0.10, 1.00) colors[imgui.Col.ButtonHovered] = imgui.ImVec4(0.95, 0.58, 0.15, 1.00) colors[imgui.Col.ButtonActive] = imgui.ImVec4(0.75, 0.42, 0.05, 1.00) colors[imgui.Col.ScrollbarBg] = imgui.ImVec4(0.15, 0.15, 0.18, 1.00) colors[imgui.Col.ScrollbarGrab] = imgui.ImVec4(0.24, 0.24, 0.28, 1.00) colors[imgui.Col.ScrollbarGrabHovered] = imgui.ImVec4(0.30, 0.30, 0.35, 1.00) colors[imgui.Col.ScrollbarGrabActive] = imgui.ImVec4(0.40, 0.40, 0.45, 1.00) end local function chatInfo(text) sampAddChatMessage("{5CD65C}[Training]{FFFFFF} " .. text, -1) end local function chatWarn(text) sampAddChatMessage("{FFAA00}[Training]{FFFFFF} " .. text, -1) end local function chatError(text) sampAddChatMessage("{FF5555}[Training]{FFFFFF} " .. text, -1) end local function getNickname() local result, id = sampGetPlayerIdByCharHandle(PLAYER_PED) if result then return sampGetPlayerNickname(id) end return "" end local function saveNickname(nick) cfg.main.nickname = nick or "" if not doesDirectoryExist(cfg_dir) then createDirectory(cfg_dir) end inicfg.save(cfg, cfg_name, cfg_dir) end local function tr_con(nick) local name = nick and #nick > 0 and nick or nil if name then sampSetLocalPlayerName(name) end chatWarn("Подключаемся к {FFD700}Arizona Training 2.0{FFFFFF}...") sampConnectToServer(srvip, port) end function sampev.onServerMessage(color, text) local prefix = "Вы успешно сменили формат никнейма, заходите на сервер строго с этим никнеймом:" if text and text:find(prefix, 1, true) then local newNick = text:match("никнеймом:%s*(.+)$") if newNick and #newNick > 0 then newNick = newNick:gsub("{%x%x%x%x%x%x}", "") sampSetLocalPlayerName(newNick) customNick.v = newNick saveNickname(newNick) replaced = true chatInfo("Игровой никнейм успешно обновлён.") chatInfo("Новый ник: {FFD700}" .. newNick .. "{FFFFFF}") else chatError("Не удалось определить новый никнейм из сообщения сервера.") end end end function imgui.OnDrawFrame() if not showGUI.v then return end local w, h = getScreenResolution() imgui.SetNextWindowSize(imgui.ImVec2(340, 250), imgui.Cond.Always) imgui.SetNextWindowPos(imgui.ImVec2(w / 2, h / 2), imgui.Cond.Always, imgui.ImVec2(0.5, 0.5)) imgui.Begin(u8"TRAINING CONNECT", showGUI, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse) imgui.Dummy(imgui.ImVec2(0, 15)) imgui.TextDisabled(u8"Ваш игровой никнейм:") imgui.PushItemWidth(-1) imgui.InputText("##NicknameInput", customNick) imgui.PopItemWidth() if replaced then imgui.Spacing() imgui.TextColored(imgui.ImVec4(0.36, 0.84, 0.36, 1.00), u8"Никнейм успешно заменён.") else imgui.Spacing() end imgui.Dummy(imgui.ImVec2(0, 20)) if imgui.Button(u8"ПОДКЛЮЧИТЬСЯ", imgui.ImVec2(-1, 40)) then saveNickname(customNick.v) tr_con(customNick.v) showGUI.v = false end imgui.End() end function main() if not isSampLoaded() or not isSampfuncsLoaded() then return end while not isSampAvailable() do wait(0) end darkth() if not doesDirectoryExist(cfg_dir) then createDirectory(cfg_dir) end if doesFileExist(cfg_dir .. "\\" .. cfg_name .. ".ini") then cfg = inicfg.load(nil, cfg_dir .. "\\" .. cfg_name .. ".ini") or cfg else inicfg.save(cfg, cfg_name, cfg_dir) end if cfg.main and cfg.main.nickname and cfg.main.nickname ~= "" then customNick.v = cfg.main.nickname else local nick = getNickname() if nick and #nick > 0 then customNick.v = nick end end imgui.Process = true sampRegisterChatCommand("training", function() showGUI.v = not showGUI.v end) while true do wait(0) if isKeyJustPressed(VK_PAUSE) and os.clock() - lstpress > 1 then lstpress = os.clock() tr_con(customNick.v) end imgui.ShowCursor = showGUI.v end end