C#:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using ConVar;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Game.Rust.Cui;
using UnityEngine;
namespace Oxide.Plugins {
[Info("IQChat", "Mercury", "0.1.0")]
[Description("aaaaaaaaaaaaaaaaaaa")]
class IQChat : RustPlugin {
#region Vars
public string PermMuteMenu = "iqchat.muteuse";
#endregion
#region Configuration
private static Configuration config = new Configuration();
private class Configuration {
[JsonProperty("Права для смены ника")]
public string RenamePermission;
[JsonProperty("Настройка префиксов")]
public Dictionary<string, string> PrefixList = new Dictionary<string, string>();
[JsonProperty("Настройка цветов для ников")]
public Dictionary<string, string> NickColorList = new Dictionary<string, string>();
[JsonProperty("Настройка цветов для сообщений")]
public Dictionary<string, string> MessageColorList = new Dictionary<string, string>();
[JsonProperty("Настройка сообщений в чате")]
public MessageSettings MessageSetting;
[JsonProperty("Настройка причин блокировок чата")]
public Dictionary<string, int> ReasonListChat = new Dictionary<string, int>();
[JsonProperty("Настройка интерфейса")]
public InterfaceSettings InterfaceSetting;
[JsonProperty("Настройка оповещения")]
public AlertSetting AlertSettings;
internal class MessageSettings {
[JsonProperty("Наименование оповещения в чат")]
public string BroadcastTitle;
[JsonProperty("Цвет сообщения оповещения в чат")]
public string BroadcastColor;
[JsonProperty("На какое сообщение заменять плохие слова")]
public string ReplaceBadWord;
[JsonProperty("Steam64ID для аватарки в чате")]
public ulong Steam64IDAvatar;
[JsonProperty("Список плохих слов")]
public List<string> BadWords = new List<string>();
[JsonProperty("Время,через которое удалится сообщение с UI от администратора")]
public int TimeDeleteAlertUI;
[JsonProperty("Включить форматирование сообщений")]
public bool FormatingMessage;
[JsonProperty("Включить личные сообщения")]
public bool PMActivate;
[JsonProperty("Включить Анти-Спам")]
public bool AntiSpamActivate;
[JsonProperty("Звук при при получении личного сообщения")]
public string SoundPM;
[JsonProperty("Время через которое игрок может отправлять сообщение (АнтиСпам)")]
public int FloodTime;
}
internal class InterfaceSettings {
[JsonProperty("Основной цвет UI")]
public string MainColor;
[JsonProperty("Дополнительный #1 цвет UI")]
public string TwoMainColor;
[JsonProperty("Дополнительный #2 цвет UI")]
public string ThreeMainColor;
[JsonProperty("Основной цвет UI панели МУТОВ")]
public string MainColorMute;
}
internal class AlertSetting {
[JsonProperty("Включить случайное сообщение зашедшему игроку")]
public bool WelcomeMessageUse;
[JsonProperty("Список сообщений игроку при входе")]
public List<string> WelcomeMessage = new List<string>();
[JsonProperty("Уведомлять о входе игрока в чат")]
public bool ConnectedAlert;
[JsonProperty("Уведомлять о выходе игрока в чат")]
public bool DisconnectedAlert;
[JsonProperty("При уведомлении о входе/выходе игрока отображать его аватар напротив ника")]
public bool ConnectedAvatarUse;
[JsonProperty("Включить автоматические сообщения в чат")]
public bool AlertMessage;
[JsonProperty("Настройка отправки автоматических сообщений в чат")]
public List<string> MessageList;
[JsonProperty("Интервал отправки сообщений в чат(Броадкастер)")]
public int MessageListTimer;
}
public static Configuration GetNewConfiguration() {
return new Configuration {
PrefixList = new Dictionary<string, string> {
["iqchat.default"]
= "<color=yellow><b>[+]</b></color>", ["iqchat.vip"] = "<color=yellow><b>[VIP]</b></color>", ["iqchat.premium"] = "<color=red><b>[PREMIUM]</b></color>",
}
, NickColorList = new Dictionary<string, string> {
["iqchat.default"]
= "#DBEAEC", ["iqchat.vip"] = "#FFC428", ["iqchat.premium"] = "#45AAB4",
}
, MessageColorList = new Dictionary<string, string> {
["iqchat.default"]
= "#DBEAEC", ["iqchat.vip"] = "#FFC428", ["iqchat.premium"] = "#45AAB4",
}
, MessageSetting = new MessageSettings {
BroadcastTitle = "<color=#007FFF><b>[ОПОВЕЩЕНИЕ]</b></color>", BroadcastColor = "#74ade1", ReplaceBadWord = "Ругаюсь матом", Steam64IDAvatar = 0, TimeDeleteAlertUI = 5, PMActivate = true, SoundPM = "assets/bundled/prefabs/fx/notice/stack.world.fx.prefab", AntiSpamActivate = true, FloodTime = 5, FormatingMessage = true, BadWords = new List<string> {
"хуй", "гей", "говно", "бля", "тварь"
}
}
, ReasonListChat = new Dictionary<string, int> {
["Оскорбление игроков"]
= 120, ["Оскорбление родителей"] = 1200,
}
, RenamePermission = "iqchat.renameuse", AlertSettings = new AlertSetting {
MessageListTimer = 60, WelcomeMessageUse = true, ConnectedAlert = true, DisconnectedAlert = true, AlertMessage = true, ConnectedAvatarUse = true, MessageList = new List<string> {
"Автоматическое сообщение #1", "Автоматическое сообщение #2", "Автоматическое сообщение #3", "Автоматическое сообщение #4", "Автоматическое сообщение #5", "Автоматическое сообщение #6",
}
, WelcomeMessage = new List<string> {
"Добро пожаловать на сервер SUPERSERVER\nРады,что выбрал именно нас!", "С возвращением на сервер!\nЖелаем тебе удачи", "Добро пожаловать на сервер\nУ нас самые лучшие плагины",
}
,
}
, InterfaceSetting = new InterfaceSettings {
MainColor = "#6B803EFF", TwoMainColor = "#6D942BFF", ThreeMainColor = "#8EBA43FF", MainColorMute = "#6A803EFF",
}
}
;
}
}
protected override void LoadConfig() {
base.LoadConfig();
try {
config = Config.ReadObject<Configuration>();
if (config == null) LoadDefaultConfig();
}
catch {
PrintWarning("Ошибка #1" + $"чтения конфигурации 'oxide/config/{Name}', создаём новую конфигурацию!!");
LoadDefaultConfig();
}
NextTick(SaveConfig);
}
void RegisteredPermissions() {
for(int i = 0; i < config.MessageColorList.Count; i++) permission.RegisterPermission(config.MessageColorList.ElementAt(i).Key, this);
for (int j = 0; j < config.NickColorList.Count; j++) permission.RegisterPermission(config.NickColorList.ElementAt(j).Key, this);
for (int g = 0; g < config.PrefixList.Count; g++) permission.RegisterPermission(config.PrefixList.ElementAt(g).Key, this);
permission.RegisterPermission(config.RenamePermission, this);
permission.RegisterPermission(PermMuteMenu, this);
PrintWarning("Permissions - completed");
}
protected override void LoadDefaultConfig() => config = Configuration.GetNewConfiguration();
protected override void SaveConfig() => Config.WriteObject(config);
#endregion
#region Data
[JsonProperty("Дата с настройкой чата игрока")]
public Dictionary<ulong, SettingUser> ChatSettingUser = new Dictionary<ulong, SettingUser>();
[JsonProperty("Дата с Административной настройкой")]
public AdminSettings AdminSetting = new AdminSettings();
public class SettingUser {
public string ChatPrefix;
public string NickColor;
public string MessageColor;
public double MuteChatTime;
public double MuteVoiceTime;
}
public class AdminSettings {
public bool MuteChatAll;
public bool MuteVoiceAll;
public Dictionary<ulong, string> RenameList = new Dictionary<ulong, string>();
}
void ReadData() {
ChatSettingUser = Oxide.Core.Interface.Oxide.DataFileSystem.ReadObject<Dictionary<ulong, SettingUser>>("IQChat/IQUser");
AdminSetting = Oxide.Core.Interface.Oxide.DataFileSystem.ReadObject<AdminSettings>("IQChat/AdminSetting");
}
void WriteData() => timer.Every(60f, () => {
Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject("IQChat/IQUser", ChatSettingUser);
Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject("IQChat/AdminSetting", AdminSetting);
}
);
void RegisteredDataUser(BasePlayer player) {
if (!ChatSettingUser.ContainsKey(player.userID)) ChatSettingUser.Add(player.userID, new SettingUser {
ChatPrefix = config.PrefixList.ElementAt(0).Value, NickColor = config.NickColorList.ElementAt(0).Value, MessageColor = config.MessageColorList.ElementAt(0).Value, MuteChatTime = 0, MuteVoiceTime = 0,
}
);
}
#endregion
#region Hooks
private bool OnPlayerChat(BasePlayer player, string message, Chat.ChatChannel channel) {
if (Interface.Oxide.CallHook("CanChatMessage", player, message) != null) return false;
Message(channel, player, message);
return false;
}
object OnPlayerVoice(BasePlayer player, Byte[] data) {
var DataPlayer = ChatSettingUser[player.userID];
bool IsMuted = DataPlayer.MuteVoiceTime > CurrentTime() ? true : false;
if (IsMuted) return false;
return null;
}
private void OnServerInitialized() {
ReadData();
BasePlayer.activePlayerList.ForEach(p => RegisteredDataUser(p));
RegisteredPermissions();
WriteData();
BroadcastAuto();
}
private void OnPlayerInit(BasePlayer player) {
RegisteredDataUser(player);
ReturnDefaultData(player);
var Alert = config.AlertSettings;
if (Alert.ConnectedAlert) {
string Avatar = Alert.ConnectedAvatarUse ? player.UserIDString : "";
ReplyBroadcast(String.Format(lang.GetMessage("WELCOME_PLAYER", this, player.UserIDString), player.displayName), "", Avatar);
}
if (Alert.WelcomeMessageUse) {
int RandomMessage = UnityEngine.Random.Range(0, Alert.WelcomeMessage.Count);
string WelcomeMessage = Alert.WelcomeMessage[RandomMessage];
ReplySystem(Chat.ChatChannel.Global, player, WelcomeMessage);
}
}
void OnPlayerDisconnected(BasePlayer player, string reason) {
var Alert = config.AlertSettings;
if (Alert.DisconnectedAlert) {
string Avatar = Alert.ConnectedAvatarUse ? player.UserIDString : "";
ReplyBroadcast(String.Format(lang.GetMessage("LEAVE_PLAYER", this, player.UserIDString), player.displayName), "", Avatar);
}
}
#endregion
#region Func
private void Message(Chat.ChatChannel channel, BasePlayer player, string message) {
if (config.MessageSetting.FormatingMessage) {
message = message.ToLower();
var firstLetter = message.Substring(0, 1);
message = message.Remove(0, 1);
message = firstLetter.ToUpper() + message;
}
var cfg = config.MessageSetting;
for (int i = 0; i < cfg.BadWords.Count; i++) {
var BadWord = cfg.BadWords[i];
foreach (var msg in message.Split(' ')) {
if (msg.ToLower() == BadWord.ToLower()) message = message.Replace(msg, cfg.ReplaceBadWord, StringComparison.OrdinalIgnoreCase);
}
}
string FormatMessage = "";
var DataPlayer = ChatSettingUser[player.userID];
bool IsMuted = DataPlayer.MuteChatTime > CurrentTime() ? true : false;
if(IsMuted) {
ReplySystem(Chat.ChatChannel.Global, player, string.Format(lang.GetMessage("FUNC_MESSAGE_ISMUTED_TRUE", this, player.UserIDString), FormatTime(TimeSpan.FromSeconds(DataPlayer.MuteChatTime - CurrentTime()))));
return;
}
Dictionary<string, object> ChatTags = new Dictionary<string, object> {
["Player"]
= player, ["Message"] = message, ["Prefixes"] = DataPlayer.ChatPrefix
}
;
var HookResult = Interface.Oxide.CallHook("OnChatSystemMessage", ChatTags);
var DisplayNick = AdminSetting.RenameList.ContainsKey(player.userID) ? AdminSetting.RenameList[player.userID] : player.displayName;
if (HookResult != null) {
if (HookResult is bool) return;
if (channel == Chat.ChatChannel.Team) FormatMessage = $"<color=#a5e664>[Team]</color> {ChatTags["Prefixes"].ToString().Replace("— ", "")} <color={DataPlayer.NickColor}>{DisplayNick}</color>: <color={DataPlayer.MessageColor}>{ChatTags["Message"]}</color>";
else FormatMessage = $"{ChatTags["Prefixes"].ToString().Replace("— ", "")} <color={DataPlayer.NickColor}>{DisplayNick}</color>: <color={DataPlayer.MessageColor}>{ChatTags["Message"]}</color>";
}
else if (channel == Chat.ChatChannel.Team) FormatMessage = $"<color=#a5e664>[Team]</color> {DataPlayer.ChatPrefix.Replace("—", "")} <color={DataPlayer.NickColor}>{DisplayNick}</color>: <color={DataPlayer.MessageColor}>{message}</color>";
else FormatMessage = $"{DataPlayer.ChatPrefix.Replace("—", "")} <color={DataPlayer.NickColor}>{DisplayNick}</color>: <color={DataPlayer.MessageColor}>{message}</color>";
ReplyChat(channel, player, FormatMessage);
Puts($"{player}: {message}");
Log($"СООБЩЕНИЕ В ЧАТ : {FormatMessage}");
}
public void ReturnDefaultData(BasePlayer player) {
var DataPlayer = ChatSettingUser[player.userID];
var PrefixPerm = config.PrefixList.FirstOrDefault(x => x.Value == DataPlayer.ChatPrefix).Key;
var PrefixColorMsg= config.MessageColorList.FirstOrDefault(x => x.Value == DataPlayer.MessageColor).Key;
var PrefixColorNick = config.NickColorList.FirstOrDefault(x => x.Value == DataPlayer.NickColor).Key;
if (!permission.UserHasPermission(player.UserIDString, PrefixPerm)) DataPlayer.ChatPrefix = config.PrefixList.ElementAt(0).Value;
if (!permission.UserHasPermission(player.UserIDString, PrefixColorMsg)) DataPlayer.MessageColor = config.MessageColorList.ElementAt(0).Value;
if (!permission.UserHasPermission(player.UserIDString, PrefixColorNick)) DataPlayer.NickColor = config.NickColorList.ElementAt(0).Value;
}
public void BroadcastAuto() {
var Alert = config.AlertSettings;
if (Alert.AlertMessage) {
timer.Every(Alert.MessageListTimer, () => {
var RandomMsg = Alert.MessageList[UnityEngine.Random.Range(0, Alert.MessageList.Count)];
ReplyBroadcast(RandomMsg);
}
);
}
}
public void MutePlayer(BasePlayer player, BasePlayer Initiator, string Format, int ReasonIndex) {
var cfg = config.ReasonListChat.ElementAt(ReasonIndex);
string Reason = cfg.Key;
float TimeMute = cfg.Value;
switch (Format) {
case "mutechat" : {
ChatSettingUser[player.userID].MuteChatTime = TimeMute + CurrentTime();
ReplyBroadcast(string.Format(lang.GetMessage("FUNC_MESSAGE_MUTE_CHAT", this, player.UserIDString), Initiator.displayName, player.displayName, FormatTime(TimeSpan.FromSeconds(TimeMute)), Reason));
break;
}
case "unmutechat" : {
ChatSettingUser[player.userID].MuteChatTime = 0;
ReplyBroadcast(string.Format(lang.GetMessage("FUNC_MESSAGE_UNMUTE_CHAT", this, player.UserIDString), Initiator.displayName));
break;
}
case "mutevoice" : {
ChatSettingUser[player.userID].MuteVoiceTime = TimeMute + CurrentTime();
ReplyBroadcast(string.Format(lang.GetMessage("FUNC_MESSAGE_MUTE_VOICE", this), Initiator.displayName, player.displayName, FormatTime(TimeSpan.FromSeconds(TimeMute)), Reason));
break;
}
}
}
public void MuteAllChatPlayer(BasePlayer player, float TimeMute = 86400) => ChatSettingUser[player.userID].MuteChatTime = TimeMute + CurrentTime();
public void RenameFunc(BasePlayer player, string NewName) {
if (permission.UserHasPermission(player.UserIDString, config.RenamePermission)) {
if (!AdminSetting.RenameList.ContainsKey(player.userID)) AdminSetting.RenameList.Add(player.userID, NewName);
else AdminSetting.RenameList[player.userID] = NewName;
ReplySystem(Chat.ChatChannel.Global, player, String.Format(lang.GetMessage("COMMAND_RENAME_SUCCES", this, player.UserIDString), NewName));
}
else ReplySystem(Chat.ChatChannel.Global, player, lang.GetMessage("COMMAND_NOT_PERMISSION", this, player.UserIDString));
}
#endregion
#region Interface
static string MAIN_PARENT = "MAIN_PARENT_UI";
static string MUTE_MENU_PARENT = "MUTE_MENU_UI";
static string ELEMENT_SETTINGS = "NEW_ELEMENT_SETTINGS";
static string MAIN_ALERT_UI = "ALERT_UI_PLAYER";
public void UI_MainMenu(BasePlayer player) {
CuiElementContainer container = new CuiElementContainer();
CuiHelper.DestroyUi(player, MAIN_PARENT);
#region Panels
container.Add(new CuiPanel {
CursorEnabled = true, RectTransform = {
AnchorMin = "1 0.5", AnchorMax = "1 0.5", OffsetMin = "-300 -150", OffsetMax = "0 200"
}
, Image = {
FadeIn = 0.15f, Color = HexToRustFormat(config.InterfaceSetting.MainColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, "Overlay", MAIN_PARENT);
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0.8628572", AnchorMax = "1 1"
}
, Image = {
Color = HexToRustFormat(config.InterfaceSetting.TwoMainColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, MAIN_PARENT, "TITLE_PANEL");
#endregion
#region Labels
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0.3888887", AnchorMax = "1 1"
}
, Text = {
Text = lang.GetMessage("TITLE_ONE", this, player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FadeIn = 0.3f
}
}
, "TITLE_PANEL");
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 0.4694438"
}
, Text = {
Text = lang.GetMessage("TITLE_TWO", this, player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FadeIn = 0.3f
}
}
, "TITLE_PANEL");
#region BtnLabels
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.01 0.7828571", AnchorMax = "1 0.8419046"
}
, Text = {
Text = lang.GetMessage("UI_TEXT_PREFIX", this, player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleLeft, FadeIn = 0.3f
}
}
, MAIN_PARENT);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.01 0.6285695", AnchorMax = "1 0.6876169"
}
, Text = {
Text = lang.GetMessage("UI_TEXT_COLOR_NICK", this, player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleLeft, FadeIn = 0.3f
}
}
, MAIN_PARENT);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.01 0.3806", AnchorMax = "1 0.5428537"
}
, Text = {
Text = lang.GetMessage("UI_TEXT_COLOR_MSG", this, player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleLeft, FadeIn = 0.3f
}
}
, MAIN_PARENT);
#endregion
#endregion
#region Buttons
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "0 -30", OffsetMax = "300 -1"
}
, Button = {
Close = MAIN_PARENT, Color = HexToRustFormat("#C43E28FF"), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Text = lang.GetMessage("UI_CLOSE_BTN", this, player.UserIDString), Color = HexToRustFormat("#FFBBB0FF"), Align = TextAnchor.MiddleCenter
}
}
, MAIN_PARENT, "BTN_CLOSE_PARENT");
container.Add(new CuiElement {
Parent = "BTN_CLOSE_PARENT", Components = {
new CuiImageComponent {
Color = HexToRustFormat("#772500FF"), Sprite = "assets/icons/close.png"
}
, new CuiRectTransformComponent {
AnchorMin = "0.01896266 0.1418719", AnchorMax = "0.09458128 0.8512315"
}
}
}
);
#region PrefixSettings
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = "0 0.7085695", AnchorMax = "1 0.7790456"
}
, Button = {
Command = "iq_chat newelementsettingsprefix", Color = HexToRustFormat(config.InterfaceSetting.ThreeMainColor), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Text = lang.GetMessage("UI_TEXT_GO_SETTINGS", this, player.UserIDString), Align = TextAnchor.MiddleCenter
}
}
, MAIN_PARENT, "BTN_PREFIX_SETTINGS");
container.Add(new CuiElement {
Parent = "BTN_PREFIX_SETTINGS", Components = {
new CuiImageComponent {
Color = HexToRustFormat("#FFFFFFFF"), Sprite = "assets/icons/gear.png",
}
, new CuiRectTransformComponent {
AnchorMin = "0.01333339 0.1621625", AnchorMax = "0.06666672 0.8108124"
}
}
}
);
container.Add(new CuiElement {
Parent = "BTN_PREFIX_SETTINGS", Components = {
new CuiImageComponent {
Color = HexToRustFormat("#FFFFFFFF"), Sprite = "assets/icons/gear.png"
}
, new CuiRectTransformComponent {
AnchorMin = "0.9333356 0.1621625", AnchorMax = "0.9866689 0.8108124"
}
}
}
);
#endregion
#region NickColorSettings
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = "0 0.5542819", AnchorMax = "1 0.62475266"
}
, Button = {
Command = "iq_chat newelementsettingscolornick", Color = HexToRustFormat(config.InterfaceSetting.ThreeMainColor), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Text = lang.GetMessage("UI_TEXT_GO_SETTINGS", this, player.UserIDString), Align = TextAnchor.MiddleCenter
}
}
, MAIN_PARENT, "BTN_NICK_COLOR_SETTINGS");
container.Add(new CuiElement {
Parent = "BTN_NICK_COLOR_SETTINGS", Components = {
new CuiImageComponent {
Color = HexToRustFormat("#FFFFFFFF"), Sprite = "assets/icons/gear.png"
}
, new CuiRectTransformComponent {
AnchorMin = "0.01333339 0.1621625", AnchorMax = "0.06666672 0.8108124"
}
}
}
);
container.Add(new CuiElement {
Parent = "BTN_NICK_COLOR_SETTINGS", Components = {
new CuiImageComponent {
Color = HexToRustFormat("#FFFFFFFF"), Sprite = "assets/icons/gear.png"
}
, new CuiRectTransformComponent {
AnchorMin = "0.9333356 0.1621625", AnchorMax = "0.9866689 0.8108124"
}
}
}
);
#endregion
#region MsgColorSettings
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = "0 0.4114244", AnchorMax = "1 0.19015"
}
, Button = {
Command = "iq_chat newelementsettingcolormessage", Color = HexToRustFormat(config.InterfaceSetting.ThreeMainColor), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Text = lang.GetMessage("UI_TEXT_GO_SETTINGS", this, player.UserIDString), Align = TextAnchor.MiddleCenter
}
}
, MAIN_PARENT, "BTN_MSG_COLOR_SETTINGS");
container.Add(new CuiElement {
Parent = "BTN_MSG_COLOR_SETTINGS", Components = {
new CuiImageComponent {
Color = HexToRustFormat("#FFFFFFFF"), Sprite = "assets/icons/gear.png"
}
, new CuiRectTransformComponent {
AnchorMin = "0.01333339 0.1621625", AnchorMax = "0.06666672 0.8108124"
}
}
}
);
container.Add(new CuiElement {
Parent = "BTN_MSG_COLOR_SETTINGS", Components = {
new CuiImageComponent {
Color = HexToRustFormat("#FFFFFFFF"), Sprite = "assets/icons/gear.png"
}
, new CuiRectTransformComponent {
AnchorMin = "0.9333356 0.1621625", AnchorMax = "0.9866689 0.8108124"
}
}
}
);
#endregion
#endregion
#region AdminPanel
if (player.IsAdmin) {
string CommandChat = "iq_chat admin_chat";
string ColorMuteChatButton = AdminSetting.MuteChatAll ? "#C43E28FF" : config.InterfaceSetting.ThreeMainColor;
string TextMuteChatButton = AdminSetting.MuteChatAll ? "UI_TEXT_ADMIN_PANEL_UNMUTE_CHAT_ALL" : "UI_TEXT_ADMIN_PANEL_MUTE_CHAT_ALL";
string CommandMuteChatButton = AdminSetting.MuteChatAll ? "unmutechat" : "mutechat";
string CommandVoice = "iq_chat admin_voice";
string ColorMuteVoiceButton = AdminSetting.MuteVoiceAll ? "#C43E28FF" : config.InterfaceSetting.ThreeMainColor;
string TextMuteVoiceButton = AdminSetting.MuteVoiceAll ? "UI_TEXT_ADMIN_PANEL_UNMUTE_VOICE_ALL" : "UI_TEXT_ADMIN_PANEL_MUTE_VOICE_ALL";
string CommandMuteVoiceButton = AdminSetting.MuteVoiceAll ? "unmutevoice" : "mutevoice";
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0.3104762", AnchorMax = "1 0.3923809"
}
, Image = {
Color = HexToRustFormat(config.InterfaceSetting.TwoMainColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, MAIN_PARENT, "AdminPanel_TITLE");
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1"
}
, Text = {
Text = lang.GetMessage("UI_TEXT_ADMIN_PANEL", this, player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FadeIn = 0.3f
}
}
, "AdminPanel_TITLE");
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = "0 0.2342857", AnchorMax = "1 0.3047618"
}
, Button = {
Close = MAIN_PARENT, Command = $"{CommandChat} {CommandMuteChatButton}", Color = HexToRustFormat(ColorMuteChatButton), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Text = lang.GetMessage(TextMuteChatButton, this, player.UserIDString), Align = TextAnchor.MiddleCenter
}
}
, MAIN_PARENT);
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = "0 0.1580954", AnchorMax = "1 0.2285715"
}
, Button = {
Close = MAIN_PARENT, Command = $"{CommandVoice} {CommandMuteVoiceButton}", Color = HexToRustFormat(ColorMuteVoiceButton), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Text = lang.GetMessage(TextMuteVoiceButton, this, player.UserIDString), Align = TextAnchor.MiddleCenter
}
}
, MAIN_PARENT);
}
#endregion
CuiHelper.AddUi(player, container);
}
public void UI_MuteMenu(BasePlayer player) {
CuiElementContainer container = new CuiElementContainer();
CuiHelper.DestroyUi(player, MUTE_MENU_PARENT);
container.Add(new CuiPanel {
CursorEnabled = true, RectTransform = {
AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-500 -250", OffsetMax = "500 300"
}
, Image = {
FadeIn = 0.15f, Color = HexToRustFormat(config.InterfaceSetting.MainColorMute), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, "Overlay", MUTE_MENU_PARENT);
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0.8957576", AnchorMax = "1 1"
}
, Image = {
Color = HexToRustFormat(config.InterfaceSetting.TwoMainColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, MUTE_MENU_PARENT, "TITLE_PANEL_MUTE");
#region PlayerList
int x = 0;
int y = 0;
foreach (var pList in BasePlayer.activePlayerList) {
string ColorButton = ChatSettingUser[pList.userID].MuteChatTime > CurrentTime() ? "#C43E28FF" : ChatSettingUser[pList.userID].MuteVoiceTime > CurrentTime() ? "#C43E28FF" : config.InterfaceSetting.ThreeMainColor;
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = $"{0.004058793 + (x * 0.144)} {0.7551514 - (y * 0.05)}", AnchorMax = $"{0.1306667 + (x * 0.144)} {0.7974398 - (y * 0.05)}"
}
, Button = {
Command = $"iq_chat mute_take_action {pList.userID}", Color = HexToRustFormat(ColorButton), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Text = pList.displayName, Align = TextAnchor.MiddleCenter
}
}
, MUTE_MENU_PARENT, "BUTTON" + player.userID);
x++;
if (x == 7) {
y++;
x = 0;
}
if (y == 13 && x == 6) break;
}
;
#endregion
#region Helps
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.002666675 0.05212118", AnchorMax = "0.02333329 0.0881"
}
, Image = {
Color = HexToRustFormat(config.InterfaceSetting.ThreeMainColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, MUTE_MENU_PARENT);
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.002666662 0.006060584", AnchorMax = "0.02333332 0.04242422"
}
, Image = {
Color = HexToRustFormat("#C43E28FF"), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, MUTE_MENU_PARENT);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.02133331 0.05212118", AnchorMax = "0.282 0.0882"
}
, Text = {
Text = lang.GetMessage("UI_MUTE_PANEL_TITLE_HELPS_GREEN", this, player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FadeIn = 0.3f
}
}
, MUTE_MENU_PARENT);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0.02133331 0.00823", AnchorMax = "0.2746667 0.04"
}
, Text = {
Text = lang.GetMessage("UI_MUTE_PANEL_TITLE_HELPS_RED", this, player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FadeIn = 0.3f
}
}
, MUTE_MENU_PARENT);
#endregion
#region Labels
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0.2906973", AnchorMax = "1 1"
}
, Text = {
Text = lang.GetMessage("UI_MUTE_PANEL_TITLE", this, player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FadeIn = 0.3f
}
}
, "TITLE_PANEL_MUTE");
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 0.4418605"
}
, Text = {
Text = lang.GetMessage("UI_MUTE_PANEL_TITLE_ACTION", this, player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FadeIn = 0.3f
}
}
, "TITLE_PANEL_MUTE");
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0.8036363", AnchorMax = "1 0.8436363"
}
, Text = {
Text = lang.GetMessage("UI_MUTE_PANEL_TITLE_PLIST", this, player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FadeIn = 0.3f
}
}
, MUTE_MENU_PARENT);
#endregion
#region Buttons
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 0", OffsetMin = "0 -35", OffsetMax = "0 -3"
}
, Button = {
Close = MUTE_MENU_PARENT, Color = HexToRustFormat("#C43E28FF"), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Text = lang.GetMessage("UI_CLOSE_BTN", this, player.UserIDString), Color = HexToRustFormat("#FFBBB0FF"), Align = TextAnchor.MiddleCenter
}
}
, MUTE_MENU_PARENT, "BTN_CLOSE_MUTE_MENU_PARENT");
#endregion
CuiHelper.AddUi(player, container);
}
public void UI_MuteTakeAction(BasePlayer player, ulong userID) {
CuiElementContainer container = new CuiElementContainer();
CuiHelper.DestroyUi(player, "TAKE_ACTION_MUTE");
#region Panels
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.3526041 0.6037037", AnchorMax = "0.65125 0.778889"
}
, Image = {
Color = HexToRustFormat(config.InterfaceSetting.MainColorMute), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, MUTE_MENU_PARENT, "TAKE_ACTION_MUTE");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0.6712323", AnchorMax = "1 1"
}
, Image = {
Color = HexToRustFormat(config.InterfaceSetting.TwoMainColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, "TAKE_ACTION_MUTE", "TITLE_MENU_MUTE_ACTION");
#endregion
#region Labels
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1"
}
, Text = {
Text = lang.GetMessage("UI_MUTE_TAKE_ACTION_PANEL", this, player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FadeIn = 0.3f
}
}
, "TITLE_MENU_MUTE_ACTION");
#endregion
#region Buttons
string ButtonColorChat = ChatSettingUser[userID].MuteChatTime > CurrentTime() ? "#C43E28FF" : config.InterfaceSetting.ThreeMainColor;
string ButtonColorVoice = ChatSettingUser[userID].MuteVoiceTime > CurrentTime() ? "#C43E28FF" : config.InterfaceSetting.ThreeMainColor;
string ButtonChat = ChatSettingUser[userID].MuteChatTime > CurrentTime() ? "UI_MUTE_TAKE_ACTION_CHAT_UNMUTE" : "UI_MUTE_TAKE_ACTION_CHAT";
string ButtonVoice = ChatSettingUser[userID].MuteVoiceTime > CurrentTime() ? "UI_MUTE_TAKE_ACTION_VOICE_UNMUTE" : "UI_MUTE_TAKE_ACTION_VOICE";
string ButtonCommandChat = ChatSettingUser[userID].MuteChatTime > CurrentTime() ? $"iq_chat mute_action {userID} unmutechat" : $"iq_chat mute_action {userID} mute mutechat";
string ButtonCommandVoice = ChatSettingUser[userID].MuteVoiceTime > CurrentTime() ? $"iq_chat mute_action {userID} unmutevoice" : $"iq_chat mute_action {userID} mute mutevoice";
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = "0 0.3787669", AnchorMax = "1 0.6127237"
}
, Button = {
Command = ButtonCommandChat, Color = HexToRustFormat(ButtonColorChat), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Text = lang.GetMessage(ButtonChat, this, player.UserIDString), Align = TextAnchor.MiddleCenter
}
}
, "TAKE_ACTION_MUTE");
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = "0 0.07369863", AnchorMax = "1 0.3150686"
}
, Button = {
Command = ButtonCommandVoice, Color = HexToRustFormat(ButtonColorVoice), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Text = lang.GetMessage(ButtonVoice, this, player.UserIDString), Align = TextAnchor.MiddleCenter
}
}
, "TAKE_ACTION_MUTE");
#endregion
CuiHelper.AddUi(player, container);
}
void UI_MuteTakeActionShowListReason(BasePlayer player, ulong userID, string MuteFormat) {
CuiElementContainer container = new CuiElementContainer();
CuiHelper.DestroyUi(player, "TAKE_PANEL_REASON");
#region Panels
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "0 -300", OffsetMax = "300 0"
}
, Image = {
Color = HexToRustFormat(config.InterfaceSetting.MainColorMute), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, "TAKE_ACTION_MUTE", "TAKE_PANEL_REASON");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0.8859987", AnchorMax = "1 1"
}
, Image = {
Color = HexToRustFormat(config.InterfaceSetting.TwoMainColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, "TAKE_PANEL_REASON", "TAKE_ACTION_MUTE_TITLE");
#endregion
#region Labels
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1"
}
, Text = {
Text = lang.GetMessage("UI_MUTE_TAKE_REASON_TITLE", this, player.UserIDString), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FadeIn = 0.3f
}
}
, "TAKE_ACTION_MUTE_TITLE");
#endregion
#region Buttons
for (int i = 0; i < config.ReasonListChat.Count; i++) {
var Reason = config.ReasonListChat.ElementAt(i);
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = $"0 {0.76898 - (i * 0.118)}", AnchorMax = $"1 {0.8694967 - (i * 0.118)}"
}
, Button = {
Command = $"iq_chat mute_action {userID} mute_reason {MuteFormat} {i}", Color = HexToRustFormat("#90BC37FF"), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Text = Reason.Key, Align = TextAnchor.MiddleCenter
}
}
, "TAKE_PANEL_REASON", "BUTTON" + i);
}
#endregion
CuiHelper.AddUi(player, container);
}
#region NewElementSettings
public void NewElementSettings(BasePlayer player) {
CuiElementContainer container = new CuiElementContainer();
CuiHelper.DestroyUi(player, ELEMENT_SETTINGS);
#region Panels
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "-300 -30", OffsetMax = "-1 350"
}
, Image = {
FadeIn = 0.15f, Color = HexToRustFormat(config.InterfaceSetting.MainColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, MAIN_PARENT, ELEMENT_SETTINGS);
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "0.9959 0.07606"
}
, Image = {
Color = HexToRustFormat(config.InterfaceSetting.TwoMainColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, ELEMENT_SETTINGS, "MySettingPanel");
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0 0.9126315", AnchorMax = "0.9959 1"
}
, Image = {
Color = HexToRustFormat(config.InterfaceSetting.TwoMainColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, ELEMENT_SETTINGS, "TitlePanel");
#endregion
CuiHelper.AddUi(player, container);
}
#endregion
#region NewElementPrefixSettings
public void NewElementPrefixSetting(BasePlayer player) {
CuiElementContainer container = new CuiElementContainer();
var Prefix = ChatSettingUser[player.userID].ChatPrefix;
var MyColorNick = ChatSettingUser[player.userID].NickColor;
var PrefixList = config.PrefixList;
#region Buttons
int x = 0, y = 0;
for(int i = 0; i < PrefixList.Count; i++) {
var ElementPrefix = PrefixList.ElementAt(i);
if (!permission.UserHasPermission(player.UserIDString, ElementPrefix.Key)) continue;
container.Add(new CuiButton {
FadeOut = 0.2f, RectTransform = {
AnchorMin = $"{0.009514093 + (x * 0.594)} {0.77595 - (y * 0.07)}", AnchorMax = $"{0.3950973 + (x * 0.594)} {0.8368425 - (y * 0.07)}"
}
, Button = {
Command = $"iq_chat prefix_selected {ElementPrefix.Value} MySettingPanel Prefix_Label {ElementPrefix.Value}<color={MyColorNick}>{player.displayName}</color>", Color = HexToRustFormat(config.InterfaceSetting.ThreeMainColor), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Tex
// ... [Code preview truncated due to length. Full source in attached file] ...