--by pavetr.top/ds -- Глобальная переменная для текста PM local customPMText = "" -- Глобальная переменная для формата selectedFormat = "[PM] [NAME] [MESSAGE]" local function DumbBanMenu() local frame = vgui.Create("DFrame") frame:SetSize(400, 400) frame:SetTitle("DUMB BAN CHAT") frame:Center() frame:MakePopup() frame:SetMinWidth(400) frame:SetMinHeight(400) frame:SetSizable(true) -- Цвет фона function frame:Paint(w, h) surface.SetDrawColor(24, 24, 50, 255) surface.DrawRect(0, 0, w, h) end -- Список игроков local playerListView = vgui.Create("DListView", frame) playerListView:Dock(FILL) playerListView:AddColumn("Игрок") playerListView:AddColumn("Профессия") -- Заполнение списка игроков local function PopulatePlayerList() for _, ply in ipairs(player.GetAll()) do playerListView:AddLine(ply:GetName(), ply:getJobTable().name, ply) -- Сохраняем объект игрока end end PopulatePlayerList() local selectedPlayer = "[PM] [NAME] [MESSAGE]" local newFrame = nil -- Новый фрейм local pmCheckbox = vgui.Create("DCheckBoxLabel", frame) pmCheckbox:SetText("Отправить как PM") pmCheckbox:Dock(TOP) pmCheckbox:SetVisible(false) local addButton = vgui.Create("DButton", frame) addButton:SetText("Добавить правило") addButton:SetVisible(false) addButton:Dock(TOP) addButton:SetTall(30) -- Обработчик наведения мыши addButton.OnCursorEntered = function() surface.PlaySound("ui/buttonrollover.wav") end -- Обработчик нажатия addButton.DoClick = function() surface.PlaySound("ui/buttonclick.wav") newFrame = vgui.Create("DFrame") newFrame:SetSize(300, 200) newFrame:SetTitle("Назначить правило") newFrame:Center() newFrame:MakePopup() -- Цвет фона нового фрейма function newFrame:Paint(w, h) surface.SetDrawColor(24, 24, 50, 255) surface.DrawRect(0, 0, w, h) end -- Поле ввода текста для PM local customPMTextEntry = vgui.Create("DTextEntry", newFrame) customPMTextEntry:SetVisible(false) customPMTextEntry:Dock(TOP) customPMTextEntry:SetWide(200) customPMTextEntry:SetTall(30) -- Чекбокс "Нестандартный PM" local customPMCheckbox = vgui.Create("DCheckBoxLabel", newFrame) customPMCheckbox:SetText("Нестандартный PM") customPMCheckbox:Dock(TOP) -- Обработчик изменения состояния чекбокса customPMCheckbox.OnChange = function(self, checked) surface.PlaySound("ui/buttonclickrelease.wav") customPMTextEntry:SetVisible(checked) if not checked then customPMTextEntry:SetValue("") end end -- лабели для формата сообщения local formatLabel = vgui.Create("DLabel", newFrame) formatLabel:SetText("Выберите формат сообщения:") formatLabel:Dock(TOP) formatLabel:SizeToContents() local format1 = vgui.Create("DCheckBoxLabel", newFrame) format1:SetText("[PM] [NAME] [MESSAGE]") format1:Dock(TOP) local format2 = vgui.Create("DCheckBoxLabel", newFrame) format2:SetText("[NAME] [PM] [MESSAGE]") format2:Dock(TOP) -- Установка чекбоксов if selectedFormat == "[PM] [NAME] [MESSAGE]" then format1:SetChecked(true) elseif selectedFormat == "[NAME] [PM] [MESSAGE]" then format2:SetChecked(true) end local formatErrorLabel = vgui.Create("DLabel", newFrame) formatErrorLabel:SetText("") formatErrorLabel:SetTextColor(Color(255, 0, 0)) formatErrorLabel:Dock(TOP) formatErrorLabel:SizeToContents() -- Иконка ошибки local warningIcon = vgui.Create("DImage", newFrame) warningIcon:SetImage("icon16/exclamation.png") warningIcon:SetSize(16, 16) warningIcon:SetVisible(false) -- Обработка изменения формата local function onFormatChange() if format1:GetChecked() and format2:GetChecked() then surface.PlaySound("ui/buttonclickrelease.wav") -- Звук при конфликте форматов format1:SetChecked(false) format2:SetChecked(false) formatErrorLabel:SetText("Можно активировать только один формат сообщения!") warningIcon:SetPos(284, formatErrorLabel:GetTall() + 73) warningIcon:SetVisible(true) -- Показываем иконку при ошибке else formatErrorLabel:SetText("") warningIcon:SetVisible(false) -- Скрываем иконку, если ошибки нет end end format1.OnChange = onFormatChange format2.OnChange = onFormatChange -- Кнопка подтверждения local confirmButton = vgui.Create("DButton", newFrame) confirmButton:SetText("Подтвердить") confirmButton:Dock(BOTTOM) -- Обработчик наведения мыши confirmButton.OnCursorEntered = function() surface.PlaySound("ui/buttonrollover.wav") -- Звук при наведении end -- Обработчик нажатия confirmButton.DoClick = function() surface.PlaySound("ui/buttonclick.wav") -- Проверяем состояние чекбокса и значение поля if customPMCheckbox:GetChecked() then customPMText = customPMTextEntry:GetValue() -- Сохраняем текст else customPMText = "" -- Сбрасываем значение end if not format1:GetChecked() and not format2:GetChecked() then -- Создаем красный лабель, если ни один формат не выбран formatErrorLabel:SetText("Выберите формат сообщения!") warningIcon:SetVisible(true) warningIcon:SetPos(158, formatErrorLabel:GetTall() + 73) else -- Сохраняем выбранный формат if format1:GetChecked() then selectedFormat = "[PM] [NAME] [MESSAGE]" elseif format2:GetChecked() then selectedFormat = "[NAME] [PM] [MESSAGE]" end print("Формат: " .. selectedFormat) newFrame:Close() end end -- Цвет фона кнопки function confirmButton:Paint(w, h) surface.SetDrawColor(50, 50, 70, 255) surface.DrawRect(0, 0, w, h) end end -- Поле ввода текста local textEntry = vgui.Create("DTextEntry", frame) textEntry:SetVisible(false) textEntry:Dock(TOP) textEntry:SetWide(100) textEntry:SetTall(30) -- для отображения имени игрока и текста сообщения local textLabel = vgui.Create("DLabel", frame) textLabel:Dock(BOTTOM) textLabel:SetVisible(true) -- Обновление текста local function UpdateTextLabel() if selectedPlayer then local prefix = pmCheckbox:GetChecked() and (customPMText ~= "" and customPMText or "[PM ОТ] ") or "" local message = textEntry:GetValue() if selectedFormat == "[PM] [NAME] [MESSAGE]" then textLabel:SetText(prefix .. selectedPlayer:GetName() .. ": " .. message) elseif selectedFormat == "[NAME] [PM] [MESSAGE]" then textLabel:SetText(selectedPlayer:GetName() .. " " .. prefix .. message) end end end textEntry.OnTextChanged = UpdateTextLabel -- Кнопка "Отправить PM" local messageButton = vgui.Create("DButton", frame) messageButton:SetVisible(false) messageButton:Dock(BOTTOM) messageButton:SetTall(40) messageButton:SetText("Отправить PM") messageButton:SetTextColor(Color(255, 255, 255)) -- Обработчик наведения мыши messageButton.OnCursorEntered = function() surface.PlaySound("ui/buttonrollover.wav") end -- Обработчик нажатия messageButton.DoClick = function() surface.PlaySound("ui/buttonclick.wav") if selectedPlayer then local message = textEntry:GetValue() if message and message ~= "" then local jobColor = team.GetColor(selectedPlayer:getJobTable().team) local prefixColor = Color(255, 255, 0) -- Желтый цвет -- Устанавливаем prefix в зависимости от значения customPMText local prefix = "" if pmCheckbox:GetChecked() then prefix = customPMText ~= "" and customPMText or "[PM ОТ] " end if selectedFormat == "[PM] [NAME] [MESSAGE]" then chat.AddText(prefixColor, prefix, jobColor, selectedPlayer:GetName(), Color(255, 255, 255), ": ", message) elseif selectedFormat == "[NAME] [PM] [MESSAGE]" then chat.AddText(jobColor, selectedPlayer:GetName(), " ", prefixColor, prefix, Color(255, 255, 255), message) end -- Обновляем текст UpdateTextLabel() end end end -- Цвет фона кнопки function messageButton:Paint(w, h) surface.SetDrawColor(50, 50, 70, 255) surface.DrawRect(0, 0, w, h) end -- Изменение состояния галочки pmCheckbox.OnChange = function(self, checked) surface.PlaySound("ui/buttonclick.wav") addButton:SetVisible(checked) if not checked then if newFrame then newFrame:Close() newFrame = nil end frame:SetWide(400) pmCheckbox:SetVisible(false) textEntry:SetVisible(false) messageButton:SetVisible(false) selectedPlayer = nil end end -- Выбор игрока playerListView.OnRowSelected = function(_, rowIndex) local newSelectedPlayer = player.GetAll()[rowIndex] if selectedPlayer == newSelectedPlayer then return end selectedPlayer = newSelectedPlayer print("Выбран игрок: " .. selectedPlayer:GetName() .. ", Профессия: " .. selectedPlayer:getJobTable().name) -- Обновляем текст UpdateTextLabel() -- Показываем элементы интерфейса frame:SetWide(500) textEntry:SetVisible(true) pmCheckbox:SetVisible(true) addButton:SetVisible(pmCheckbox:GetChecked()) textEntry:RequestFocus() messageButton:SetVisible(true) end end concommand.Add("ban_menu", DumbBanMenu)