C#:
using System;
using System.Collections.Generic;
using System.Linq;
using CompanionServer;
using ConVar;
using Facepunch;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;
namespace Oxide.Plugins {
[Info("IQChat", "Mercury", "0.2.7")]
[Description("")]
class IQChat : RustPlugin {
#region Reference
[PluginReference]
Plugin IQPersonal;
public void SetMute(BasePlayer player) => IQPersonal?.CallHook("API_SET_MUTE", player.userID);
public void BadWords(BasePlayer player) => IQPersonal?.CallHook("API_DETECTED_BAD_WORDS", player.userID);
#endregion
#region Vars
public Dictionary<BasePlayer, BasePlayer> PMHistory = new Dictionary<BasePlayer, BasePlayer>();
public string PermMuteMenu = "iqchat.muteuse";
class Response {
[JsonProperty("country")]
public string Country {
get;
set;
}
}
#endregion
#region Configuration
private static Configuration config = new Configuration();
private class Configuration {
[JsonProperty("Права для смены ника")]
public string RenamePermission;
[JsonProperty("Настройка префиксов")]
public List<AdvancedFuncion> PrefixList = new List<AdvancedFuncion>();
[JsonProperty("Настройка цветов для ников")]
public List<AdvancedFuncion> NickColorList = new List<AdvancedFuncion>();
[JsonProperty("Настройка цветов для сообщений")]
public List<AdvancedFuncion> MessageColorList = new List<AdvancedFuncion>();
[JsonProperty("Настройка сообщений в чате")]
public MessageSettings MessageSetting;
[JsonProperty("Настройка причин блокировок чата")]
public List<ReasonMuteChat> ReasonListChat = new List<ReasonMuteChat>();
[JsonProperty("Настройка интерфейса")]
public InterfaceSettings InterfaceSetting;
[JsonProperty("Настройка оповещения")]
public AlertSetting AlertSettings;
[JsonProperty("Настройка сброса привилегий")]
public PrefixFoDefault PrefixFoDefaults;
[JsonProperty("Настройка Rust+")]
public RustPlus RustPlusSettings;
internal class AdvancedFuncion {
[JsonProperty("Права")]
public string Permissions;
[JsonProperty("Значение")]
public string Argument;
}
internal class RustPlus {
[JsonProperty("Использовать Rust+")]
public bool UseRustPlus;
[JsonProperty("Название для уведомления Rust+")]
public string DisplayNameAlert;
}
internal class ReasonMuteChat {
[JsonProperty("Причина мута")]
public string Reason;
[JsonProperty("Время мута")]
public int TimeMute;
}
internal class PrefixFoDefault {
[JsonProperty("При окончании префикса, установится данный префикс")]
public string PrefixDefault;
[JsonProperty("При окончании цвета ника, установится данный цвет")]
public string NickDefault;
[JsonProperty("При окончании цвета сообщения, установится данный цвета")]
public string MessageDefault;
}
internal class MessageSettings {
[JsonProperty("Включить форматирование сообщений")]
public bool FormatingMessage;
[JsonProperty("Включить личные сообщения")]
public bool PMActivate;
[JsonProperty("Включить игнор ЛС игрокам(/ignore nick)")]
public bool IgnoreUsePM;
[JsonProperty("Включить Анти-Спам")]
public bool AntiSpamActivate;
[JsonProperty("Скрыть из чата выдачу предметов Админу")]
public bool HideAdminGave;
[JsonProperty("Использовать список запрещенных слов?")]
public bool UseBadWords;
[JsonProperty("Включить возможность использовать несколько префиксов сразу")]
public bool MultiPrefix;
[JsonProperty("Переносить мут в командный чат(В случае мута,игрок не сможет писать даже в командный чат)")]
public bool MuteTeamChat;
[JsonProperty("Пермишенс для иммунитета к антиспаму")]
public string PermAdminImmunitetAntispam;
[JsonProperty("Наименование оповещения в чат")]
public string BroadcastTitle;
[JsonProperty("Цвет сообщения оповещения в чат")]
public string BroadcastColor;
[JsonProperty("На какое сообщение заменять плохие слова")]
public string ReplaceBadWord;
[JsonProperty("Звук при при получении личного сообщения")]
public string SoundPM;
[JsonProperty("Время,через которое удалится сообщение с UI от администратора")]
public int TimeDeleteAlertUI;
[JsonProperty("Steam64ID для аватарки в чате")]
public ulong Steam64IDAvatar;
[JsonProperty("Время через которое игрок может отправлять сообщение (АнтиСпам)")]
public int FloodTime;
[JsonProperty("Список плохих слов")]
public List<string> BadWords = new List<string>();
}
internal class InterfaceSettings {
[JsonProperty("Основной цвет UI")]
public string MainColor;
[JsonProperty("Дополнительный цвет UI")]
public string TwoMainColor;
[JsonProperty("Цвет кнопок")]
public string ButtonColor;
[JsonProperty("Цвет текста")]
public string LabelColor;
[JsonProperty("Настройка расположения UI уведомления")]
public AlertInterfaceSettings AlertInterfaceSetting;
internal class AlertInterfaceSettings {
[JsonProperty("AnchorMin")]
public string AnchorMin;
[JsonProperty("AnchorMax")]
public string AnchorMax;
[JsonProperty("OffsetMin")]
public string OffsetMin;
[JsonProperty("OffsetMax")]
public string OffsetMax;
}
}
internal class AlertSetting {
[JsonProperty("Включить случайное сообщение зашедшему игроку")]
public bool WelcomeMessageUse;
[JsonProperty("Список сообщений игроку при входе")]
public List<string> WelcomeMessage = new List<string>();
[JsonProperty("Уведомлять о входе игрока в чат")]
public bool ConnectedAlert;
[JsonProperty("Отображать страну зашедшего игрока")]
public bool ConnectedWorld;
[JsonProperty("Уведомлять о выходе игрока в чат")]
public bool DisconnectedAlert;
[JsonProperty("Отображать причину выхода игрока")]
public bool DisconnectedReason;
[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 List<AdvancedFuncion> {
new AdvancedFuncion {
Permissions = "iqchat.default", Argument = "<color=yellow><b>[+]</b></color>",
}
, new AdvancedFuncion {
Permissions = "iqchat.default", Argument = "<color=yellow><b>[ИГРОК]</b></color>",
}
, new AdvancedFuncion {
Permissions = "iqchat.vip", Argument = "<color=yellow><b>[VIP]</b></color>",
}
,
}
, NickColorList = new List<AdvancedFuncion> {
new AdvancedFuncion {
Permissions = "iqchat.default", Argument = "#DBEAEC",
}
, new AdvancedFuncion {
Permissions = "iqchat.default", Argument = "#FFC428",
}
, new AdvancedFuncion {
Permissions = "iqchat.vip", Argument = "#45AAB4",
}
,
}
, MessageColorList = new List<AdvancedFuncion> {
new AdvancedFuncion {
Permissions = "iqchat.default", Argument = "#DBEAEC",
}
, new AdvancedFuncion {
Permissions = "iqchat.default", Argument = "#FFC428",
}
, new AdvancedFuncion {
Permissions = "iqchat.vip", Argument = "#45AAB4",
}
,
}
, PrefixFoDefaults = new PrefixFoDefault {
PrefixDefault = "", NickDefault = "", MessageDefault = "",
}
, RustPlusSettings = new RustPlus {
UseRustPlus = true, DisplayNameAlert = "СУПЕР СЕРВЕР",
}
, MessageSetting = new MessageSettings {
UseBadWords = true, HideAdminGave = true, IgnoreUsePM = true, MuteTeamChat = true, PermAdminImmunitetAntispam = "iqchat.adminspam", 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, MultiPrefix = true, BadWords = new List<string> {
"хуй", "гей", "говно", "бля", "тварь"
}
}
, ReasonListChat = new List<ReasonMuteChat> {
new ReasonMuteChat {
Reason = "Оскорбление родителей", TimeMute = 1200,
}
, new ReasonMuteChat {
Reason = "Оскорбление игроков", TimeMute = 100
}
}
, RenamePermission = "iqchat.renameuse", AlertSettings = new AlertSetting {
MessageListTimer = 60, WelcomeMessageUse = true, ConnectedAlert = true, ConnectedWorld = true, DisconnectedAlert = true, DisconnectedReason = 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 = "#000000C0", TwoMainColor = "#762424FF", ButtonColor = "#802A2AFF", LabelColor = "#D1C7BEFF", AlertInterfaceSetting = new InterfaceSettings.AlertInterfaceSettings {
AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = "0 -90", OffsetMax = "320 -20"
}
}
}
;
}
}
protected override void LoadConfig() {
base.LoadConfig();
try {
config = Config.ReadObject<Configuration>();
if (config == null) LoadDefaultConfig();
}
catch {
PrintWarning("Ошибка #132" + $"чтения конфигурации 'oxide/config/{Name}', создаём новую конфигурацию!!");
LoadDefaultConfig();
}
NextTick(SaveConfig);
}
void RegisteredPermissions() {
for (int MsgColor = 0; MsgColor < config.MessageColorList.Count; MsgColor++) if (!permission.PermissionExists(config.MessageColorList[MsgColor].Permissions, this)) permission.RegisterPermission(config.MessageColorList[MsgColor].Permissions, this);
for (int NickColorList = 0; NickColorList < config.NickColorList.Count; NickColorList++) if (!permission.PermissionExists(config.NickColorList[NickColorList].Permissions, this)) permission.RegisterPermission(config.NickColorList[NickColorList].Permissions, this);
for (int PrefixList = 0; PrefixList < config.PrefixList.Count; PrefixList++) if (!permission.PermissionExists(config.PrefixList[PrefixList].Permissions, this)) permission.RegisterPermission(config.PrefixList[PrefixList].Permissions, this);
permission.RegisterPermission(config.RenamePermission, this);
permission.RegisterPermission(PermMuteMenu, this);
permission.RegisterPermission(config.MessageSetting.PermAdminImmunitetAntispam, 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 List<string> MultiPrefix = new List<string>();
public string NickColor;
public string MessageColor;
public double MuteChatTime;
public double MuteVoiceTime;
public List<ulong> IgnoredUsers = new List<ulong>();
}
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() {
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.PrefixFoDefaults.PrefixDefault, NickColor = config.PrefixFoDefaults.NickDefault, MessageColor = config.PrefixFoDefaults.MessageDefault, MuteChatTime = 0, MuteVoiceTime = 0, MultiPrefix = new List<string> {
}
, IgnoredUsers = new List<ulong> {
}
,
}
);
}
#endregion
#region Hooks
private bool OnPlayerChat(BasePlayer player, string message, Chat.ChatChannel channel) {
if (Interface.Oxide.CallHook("CanChatMessage", player, message) != null) return false;
SeparatorChat(channel, player, message);
return false;
}
private object OnServerMessage(string message, string name) {
if (config.MessageSetting.HideAdminGave) if (message.Contains("gave") && name == "SERVER") return true;
return null;
}
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();
foreach (var p in BasePlayer.activePlayerList) {
RegisteredDataUser(p);
}
timer.Every(320f, () => {
ReturnDefaultData();
}
);
ReturnDefaultData();
RegisteredPermissions();
WriteData();
BroadcastAuto();
}
void OnPlayerConnected(BasePlayer player) {
RegisteredDataUser(player);
var Alert = config.AlertSettings;
if (Alert.ConnectedAlert) {
string Avatar = Alert.ConnectedAvatarUse ? player.UserIDString : "";
if(config.AlertSettings.ConnectedWorld) {
webrequest.Enqueue("http://ip-api.com/json/" + player.net.connection.ipaddress.Split(':')[0], null, (code, response) => {
if (code != 200 || response == null) return;
string country = JsonConvert.DeserializeObject<Response>(response).Country;
ReplyBroadcast(String.Format(lang.GetMessage("WELCOME_PLAYER_WORLD", this, player.UserIDString), player.displayName, country), "", Avatar);
}
, this);
}
else 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 Unload() => WriteData();
void OnPlayerDisconnected(BasePlayer player, string reason) {
var Alert = config.AlertSettings;
if (Alert.DisconnectedAlert) {
string Avatar = Alert.ConnectedAvatarUse ? player.UserIDString : "";
string LangLeave = config.AlertSettings.DisconnectedReason ? String.Format(lang.GetMessage("LEAVE_PLAYER_REASON", this, player.UserIDString), player.displayName, reason) : String.Format(lang.GetMessage("LEAVE_PLAYER", this, player.UserIDString), player.displayName);
ReplyBroadcast(LangLeave, "", Avatar);
}
}
#endregion
#region Func
public bool IsMutedUser(ulong userID) {
var DataPlayer = ChatSettingUser[userID];
return DataPlayer.MuteChatTime > CurrentTime() ? true : false;
}
private void SeparatorChat(Chat.ChatChannel channel, BasePlayer player, string Message) {
var DataPlayer = ChatSettingUser[player.userID];
if (IsMutedUser(player.userID)) {
ReplySystem(Chat.ChatChannel.Global, player, String.Format(lang.GetMessage("FUNC_MESSAGE_ISMUTED_TRUE", this, player.UserIDString), FormatTime(TimeSpan.FromSeconds(DataPlayer.MuteChatTime - CurrentTime()))));
return;
}
var MessageSettings = config.MessageSetting;
string OutMessage = Message;
string PrefxiPlayer = "";
string MessageSeparator = "";
string ColorNickPlayer = DataPlayer.NickColor;
string ColorMessagePlayer = DataPlayer.MessageColor;
string DisplayName = AdminSetting.RenameList.ContainsKey(player.userID) ? AdminSetting.RenameList[player.userID] : player.displayName;
if (MessageSettings.FormatingMessage) OutMessage = $"{Message.ToLower().Substring(0, 1).ToUpper()}{Message.Remove(0, 1).ToLower()}";
if (MessageSettings.UseBadWords) foreach (var DetectedMessage in OutMessage.Split(' ')) if (MessageSettings.BadWords.Contains(DetectedMessage.ToLower())) {
OutMessage = OutMessage.Replace(DetectedMessage, MessageSettings.ReplaceBadWord);
BadWords(player);
}
if (MessageSettings.MultiPrefix) {
if (DataPlayer.MultiPrefix != null) for (int i = 0; i < DataPlayer.MultiPrefix.Count; i++) PrefxiPlayer += DataPlayer.MultiPrefix[i];
}
else PrefxiPlayer = DataPlayer.ChatPrefix;
string ModifiedNick = string.IsNullOrWhiteSpace(ColorNickPlayer) ? player.IsAdmin ? $"<color=#a8fc55>{DisplayName}</color>" : $"<color=#54aafe>{DisplayName}</color>" : $"<color={ColorNickPlayer}>{DisplayName}</color>";
string ModifiedMessage = string.IsNullOrWhiteSpace(ColorMessagePlayer) ? OutMessage : $"<color={ColorMessagePlayer}>{OutMessage}</color>";
string ModifiedChannel = channel == Chat.ChatChannel.Team ? "<color=#a5e664>[Team]</color>" : "";
MessageSeparator = $"{ModifiedChannel} {PrefxiPlayer} {ModifiedNick}: {ModifiedMessage}";
if (config.RustPlusSettings.UseRustPlus) if (channel == Chat.ChatChannel.Team) Util.BroadcastTeamChat(player.Team, player.userID, player.displayName, OutMessage, DataPlayer.MessageColor);
ReplyChat(channel, player, MessageSeparator);
Puts($"{player}: {OutMessage}");
Log($"СООБЩЕНИЕ В ЧАТ : {player}: {ModifiedChannel} {OutMessage}");
RCon.Broadcast(RCon.LogType.Chat, new Chat.ChatEntry {
Message = $"{player.displayName} : {OutMessage}", UserId = player.UserIDString, Username = player.displayName, Channel = channel, Time = (DateTime.UtcNow.Hour * 3600) + (DateTime.UtcNow.Minute * 60),
}
);
}
public void ReturnDefaultData() {
var Default = config.PrefixFoDefaults;
foreach (var DataPlayer in ChatSettingUser) {
foreach (var Prefix in config.PrefixList.Where(x => x.Argument == DataPlayer.Value.ChatPrefix)) if (!permission.UserHasPermission(DataPlayer.Key.ToString(), Prefix.Permissions)) {
DataPlayer.Value.ChatPrefix = Default.PrefixDefault;
if (config.MessageSetting.MultiPrefix) {
DataPlayer.Value.MultiPrefix.Clear();
DataPlayer.Value.MultiPrefix.Add(Default.PrefixDefault);
}
}
foreach (var ColorMsg in config.MessageColorList.Where(x => x.Argument == DataPlayer.Value.MessageColor)) if (!permission.UserHasPermission(DataPlayer.Key.ToString(), ColorMsg.Permissions)) DataPlayer.Value.MessageColor = Default.MessageDefault;
foreach (var ColorNick in config.NickColorList.Where(x => x.Argument == DataPlayer.Value.NickColor)) if (!permission.UserHasPermission(DataPlayer.Key.ToString(), ColorNick.Permissions)) DataPlayer.Value.NickColor = Default.NickDefault;
}
}
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, string Format, int ReasonIndex, string ResonCustom = "", string TimeCustom = "", BasePlayer Initiator = null) {
var cfg = config.ReasonListChat[ReasonIndex];
string Reason = string.IsNullOrEmpty(ResonCustom) ? cfg.Reason : ResonCustom;
float TimeMute = string.IsNullOrEmpty(TimeCustom) ? cfg.TimeMute : Convert.ToInt32(TimeCustom);
string DisplayInititator = Initiator == null ? "Администратор" : Initiator.displayName;
switch (Format) {
case "mutechat" : {
ChatSettingUser[player.userID].MuteChatTime = TimeMute + CurrentTime();
ReplyBroadcast(string.Format(lang.GetMessage("FUNC_MESSAGE_MUTE_CHAT", this, player.UserIDString), DisplayInititator, player.displayName, FormatTime(TimeSpan.FromSeconds(TimeMute)), Reason));
if (Initiator != null) SetMute(Initiator);
break;
}
case "unmutechat" : {
ChatSettingUser[player.userID].MuteChatTime = 0;
ReplyBroadcast(string.Format(lang.GetMessage("FUNC_MESSAGE_UNMUTE_CHAT", this, player.UserIDString), DisplayInititator));
break;
}
case "mutevoice" : {
ChatSettingUser[player.userID].MuteVoiceTime = TimeMute + CurrentTime();
ReplyBroadcast(string.Format(lang.GetMessage("FUNC_MESSAGE_MUTE_VOICE", this), DisplayInititator, 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));
}
void AlertUI(BasePlayer player, string[] arg) {
if (player != null) if (!player.IsAdmin) return;
if (arg.Length == 0 || arg == null) {
ReplySystem(Chat.ChatChannel.Global, player, lang.GetMessage("FUNC_MESSAGE_NO_ARG_BROADCAST", this, player.UserIDString));
return;
}
string Message = "";
foreach (var msg in arg) Message += " " + msg;
foreach (var p in BasePlayer.activePlayerList) UIAlert(p, Message);
}
void Alert(BasePlayer player, string[] arg) {
if (player != null) if (!player.IsAdmin) return;
if (arg.Length == 0 || arg == null) {
if(player != null) ReplySystem(Chat.ChatChannel.Global, player, lang.GetMessage("FUNC_MESSAGE_NO_ARG_BROADCAST", this, player.UserIDString));
return;
}
string Message = "";
foreach (var msg in arg) Message += " " + msg;
ReplyBroadcast(Message);
if (config.RustPlusSettings.UseRustPlus) foreach(var playerList in BasePlayer.activePlayerList) NotificationList.SendNotificationTo(playerList.userID, NotificationChannel.SmartAlarm, config.RustPlusSettings.DisplayNameAlert, Message, Util.GetServerPairingData());
}
#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";
static string PANEL_ACTION = "PANEL_ACTION";
static string PANEL_ACTION_HELPER = "PANEL_ACTION_HELPER";
#region MainMenu
public void UI_MainMenu(BasePlayer player) {
CuiElementContainer container = new CuiElementContainer();
CuiHelper.DestroyUi(player, MAIN_PARENT);
var Interface = config.InterfaceSetting;
container.Add(new CuiPanel {
CursorEnabled = true, RectTransform = {
AnchorMin = "0 0", AnchorMax = "1 1"
}
, Image = {
FadeIn = 0.15f, Color = "0 0 0 0"
}
}
, "Overlay", MAIN_PARENT);
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.81875 0.1768519", AnchorMax = "0.9869678 0.8814706"
}
, Image = {
Color = HexToRustFormat(Interface.TwoMainColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, MAIN_PARENT, PANEL_ACTION);
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0.93", AnchorMax = "1 1"
}
, Text = {
Text = lang.GetMessage("TITLE_TWO", this, player.UserIDString), Color = HexToRustFormat(Interface.LabelColor), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FadeIn = 0.3f
}
}
, PANEL_ACTION);
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "0 -45", OffsetMax = "215 -5"
}
, Button = {
Close = MAIN_PARENT, Color = HexToRustFormat(Interface.ButtonColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
, Text = {
Text = lang.GetMessage("UI_CLOSE_BTN", this, player.UserIDString), Color = HexToRustFormat(Interface.LabelColor), Align = TextAnchor.MiddleCenter
}
}
, PANEL_ACTION);
#region ACTION BUTTON
#region SettingPrefix
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.1243169 0.8383705", AnchorMax = "1 0.9179095"
}
, Button = {
Command = "iq_chat setting prefix", Color = HexToRustFormat(Interface.ButtonColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
, Text = {
Text = lang.GetMessage("UI_TEXT_PREFIX", this, player.UserIDString), Color = HexToRustFormat(Interface.LabelColor), Align = TextAnchor.MiddleCenter
}
}
, PANEL_ACTION, "PREFIX_SETTING");
container.Add(new CuiElement {
Parent = "PREFIX_SETTING", Components = {
new CuiImageComponent {
Color = HexToRustFormat(Interface.LabelColor), Sprite = "assets/icons/sign.png"
}
, new CuiRectTransformComponent {
AnchorMin = "0.04236809 0.1937432", AnchorMax = "0.1696546 0.7884976"
}
}
}
);
#endregion
#region SettingColorNick
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.1243169 0.7371891", AnchorMax = "1 0.8167281"
}
, Button = {
Command = "iq_chat setting nick", Color = HexToRustFormat(Interface.ButtonColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
, Text = {
Text = lang.GetMessage("UI_TEXT_COLOR_NICK", this, player.UserIDString), Color = HexToRustFormat(Interface.LabelColor), Align = TextAnchor.MiddleCenter
}
}
, PANEL_ACTION, "COLOR_NICK_SETTING");
container.Add(new CuiElement {
Parent = "COLOR_NICK_SETTING", Components = {
new CuiImageComponent {
Color = HexToRustFormat(Interface.LabelColor), Sprite = "assets/icons/sign.png"
}
, new CuiRectTransformComponent {
AnchorMin = "0.04236809 0.1937432", AnchorMax = "0.1696546 0.7884976"
}
}
}
);
#endregion
#region SettingText
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.1243169 0.6346937", AnchorMax = "1 0.7142327"
}
, Button = {
Command = "iq_chat setting chat", Color = HexToRustFormat(Interface.ButtonColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
, Text = {
Text = lang.GetMessage("UI_TEXT_COLOR_MSG", this, player.UserIDString), Color = HexToRustFormat(Interface.LabelColor), Align = TextAnchor.MiddleCenter
}
}
, PANEL_ACTION, "TEXT_SETTING");
container.Add(new CuiElement {
Parent = "TEXT_SETTING", Components = {
new CuiImageComponent {
Color = HexToRustFormat(Interface.LabelColor), Sprite = "assets/icons/sign.png"
}
, new CuiRectTransformComponent {
AnchorMin = "0.04236809 0.1937432", AnchorMax = "0.1696546 0.7884976"
}
}
}
);
#endregion
#endregion
#region ADMIN
#region HELPERS
if (permission.UserHasPermission(player.UserIDString, PermMuteMenu)) {
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0.4323258", AnchorMax = "1 0.5171261"
}
, Text = {
Text = lang.GetMessage("UI_TEXT_MODER_PANEL", this, player.UserIDString), Color = HexToRustFormat(Interface.LabelColor), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter
}
}
, PANEL_ACTION);
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.1243169 0.3298316", AnchorMax = "1 0.4093724"
}
, Button = {
Command = $"iq_chat mute menu", Color = HexToRustFormat(Interface.ButtonColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
, Text = {
Text = lang.GetMessage("UI_TEXT_MUTE_MENU_BTN", this, player.UserIDString), Color = HexToRustFormat(Interface.LabelColor), Align = TextAnchor.MiddleCenter
}
}
, PANEL_ACTION, "CHAT_SETTING_USER");
container.Add(new CuiElement {
Parent = "CHAT_SETTING_USER", Components = {
new CuiImageComponent {
Color = HexToRustFormat(Interface.LabelColor), Sprite = "assets/icons/subtract.png"
}
, new CuiRectTransformComponent {
AnchorMin = "0.04236809 0.1937432", AnchorMax = "0.1696546 0.7884976"
}
}
}
);
}
#endregion
#region OWNER
if (player.IsAdmin) {
string CommandChat = "iq_chat admin_chat";
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 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 CuiLabel {
RectTransform = {
AnchorMin = "0 0.224706", AnchorMax = "1 0.3042471"
}
, Text = {
Text = lang.GetMessage("UI_TEXT_ADMIN_PANEL", this, player.UserIDString), Color = HexToRustFormat(Interface.LabelColor), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter
}
}
, PANEL_ACTION);
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.1243169 0.1208954", AnchorMax = "1 0.200437"
}
, Button = {
Close = MAIN_PARENT, Command = $"{CommandChat} {CommandMuteChatButton}", Color = HexToRustFormat(Interface.ButtonColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
, Text = {
Text = lang.GetMessage(TextMuteChatButton, this, player.UserIDString), Color = HexToRustFormat(Interface.LabelColor), Align = TextAnchor.MiddleCenter
}
}
, PANEL_ACTION, "CHAT_SETTING_ADMIN");
container.Add(new CuiElement {
Parent = "CHAT_SETTING_ADMIN", Components = {
new CuiImageComponent {
Color = HexToRustFormat(Interface.LabelColor), Sprite = "assets/icons/subtract.png"
}
, new CuiRectTransformComponent {
AnchorMin = "0.04236809 0.1937432", AnchorMax = "0.1696546 0.7884976"
}
}
}
);
container.Add(new CuiButton {
RectTransform = {
AnchorMin = "0.1243169 0.02496903", AnchorMax = "1 0.1045107"
}
, Button = {
Close = MAIN_PARENT, Command = $"{CommandVoice} {CommandMuteVoiceButton}", Color = HexToRustFormat(Interface.ButtonColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
, Text = {
Text = lang.GetMessage(TextMuteVoiceButton, this, player.UserIDString), Color = HexToRustFormat(Interface.LabelColor), Align = TextAnchor.MiddleCenter
}
}
, PANEL_ACTION, "VOICE_SETTING_ADMIN");
}
container.Add(new CuiElement {
Parent = "VOICE_SETTING_ADMIN", Components = {
new CuiImageComponent {
Color = HexToRustFormat(Interface.LabelColor), Sprite = "assets/icons/subtract.png"
}
, new CuiRectTransformComponent {
AnchorMin = "0.04236809 0.1937432", AnchorMax = "0.1696546 0.7884976"
}
}
}
);
#endregion
#endregion
CuiHelper.AddUi(player, container);
}
#endregion
#region PrefixSetting
public void UI_PrefixSetting(BasePlayer player) {
CuiElementContainer container = new CuiElementContainer();
CuiHelper.DestroyUi(player, ELEMENT_SETTINGS);
CuiHelper.DestroyUi(player, MUTE_MENU_PARENT);
CuiHelper.DestroyUi(player, PANEL_ACTION_HELPER);
var Interface = config.InterfaceSetting;
string Prefix = "";
if (config.MessageSetting.MultiPrefix) {
if (ChatSettingUser[player.userID].MultiPrefix != null) for (int g = 0; g < ChatSettingUser[player.userID].MultiPrefix.Count; g++) Prefix += ChatSettingUser[player.userID].MultiPrefix[g];
else Prefix = ChatSettingUser[player.userID].ChatPrefix;
}
var PrefixList = config.PrefixList;
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5020834 0.1148148", AnchorMax = "0.8150954 0.8814815"
}
, Image = {
Color = HexToRustFormat(Interface.TwoMainColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, MAIN_PARENT, ELEMENT_SETTINGS);
int x = 0, y = 0, i = 0;
foreach (var ElementPrefix in PrefixList) {
if (!permission.UserHasPermission(player.UserIDString, ElementPrefix.Permissions)) continue;
string LockStatus = "assets/icons/unlock.png";
container.Add(new CuiButton {
RectTransform = {
AnchorMin = $"{0 + (x * 0.525)} {0.8514473 - (y * 0.1)}", AnchorMax = $"{0.4708602 + (x * 0.525)} {0.9245502 - (y * 0.1)}"
}
, Button = {
Command = $"iq_chat action prefix {ElementPrefix.Argument} {ElementPrefix.Permissions}", Color = HexToRustFormat(config.InterfaceSetting.ButtonColor), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Text = ElementPrefix.Argument, FontSize = 17, Color = HexToRustFormat(Interface.LabelColor), Align = TextAnchor.MiddleCenter
}
}
, ELEMENT_SETTINGS, $"BUTTON_{i}");
container.Add(new CuiElement {
Parent = $"BUTTON_{i}", Components = {
new CuiImageComponent {
Color = HexToRustFormat(Interface.LabelColor), Sprite = LockStatus
}
, new CuiRectTransformComponent {
AnchorMin = "0.03887215 0.1982514", AnchorMax = "0.1660901 0.7930056"
}
}
}
);
x++;
if (x == 2) {
y++;
x = 0;
}
i++;
}
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0.93", AnchorMax = "1 1"
}
, Text = {
Text = lang.GetMessage("UI_TITLE_NEW_PREFIX_ELEMENT", this, player.UserIDString), Color = HexToRustFormat(Interface.LabelColor), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FadeIn = 0.3f
}
}
, ELEMENT_SETTINGS);
CuiHelper.AddUi(player, container);
}
#endregion
#region NickSetting
public void UI_NickSetting(BasePlayer player) {
CuiElementContainer container = new CuiElementContainer();
CuiHelper.DestroyUi(player, ELEMENT_SETTINGS);
CuiHelper.DestroyUi(player, MUTE_MENU_PARENT);
CuiHelper.DestroyUi(player, PANEL_ACTION_HELPER);
var Interface = config.InterfaceSetting;
var ColorList = config.NickColorList;
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5020834 0.1148148", AnchorMax = "0.8150954 0.8814815"
}
, Image = {
Color = HexToRustFormat(Interface.TwoMainColor), Material = "assets/content/ui/uibackgroundblur.mat"
}
}
, MAIN_PARENT, ELEMENT_SETTINGS);
int x = 0, y = 0, i = 0;
foreach (var ElementColor in ColorList) {
if (!permission.UserHasPermission(player.UserIDString, ElementColor.Permissions)) continue;
string LockStatus = "assets/icons/unlock.png";
container.Add(new CuiButton {
RectTransform = {
AnchorMin = $"{0 + (x * 0.525)} {0.8514473 - (y * 0.1)}", AnchorMax = $"{0.4708602 + (x * 0.525)} {0.9245502 - (y * 0.1)}"
}
, Button = {
Command = $"iq_chat action nick {ElementColor.Argument} {ElementColor.Permissions}", Color = HexToRustFormat(config.InterfaceSetting.ButtonColor), Material = "assets/content/ui/uibackgroundblur.mat", FadeIn = 0.1f
}
, Text = {
Text = $"<color={ElementColor.Argument}>{player.displayName}</color>", FontSize = 17, Color = HexToRustFormat(Interface.LabelColor), Align = TextAnchor.MiddleCenter
}
}
, ELEMENT_SETTINGS, $"BUTTON_{i}");
container.Add(new CuiElement {
Parent = $"BUTTON_{i}", Components = {
new CuiImageComponent {
Color = HexToRustFormat(Interface.LabelColor), Sprite = LockStatus
}
, new CuiRectTransformComponent {
AnchorMin = "0.03887215 0.1982514", AnchorMax = "0.1660901 0.7930056"
}
}
}
);
x++;
if (x == 2) {
y++;
x = 0;
}
i++;
}
container.Add(new CuiLabel {
RectTransform = {
AnchorMin = "0 0.93", AnchorMax = "1 1"
}
, Text = {
Text = lang.GetMessage("UI_TITLE_NEW_NICK_COLOR_ELEMENT", this, player.UserIDString), Color = HexToRustFormat(Interface.LabelColor), Font = "robotocondensed-bold.ttf", Align = TextAnchor.MiddleCenter, FadeIn = 0.3f
}
}
, ELEMENT_SETTINGS);
CuiHelper.AddUi(player, container);
}
#endregion
#region ColorSetting
public void UI_TextSetting(BasePlayer player) {
CuiElementContainer container = new CuiElementContainer();
CuiHelper.DestroyUi(player, ELEMENT_SETTINGS);
CuiHelper.DestroyUi(player, MUTE_MENU_PARENT);
CuiHelper.DestroyUi(player, PANEL_ACTION_HELPER);
var Interface = config.InterfaceSetting;
var ColorList = config.MessageColorList;
container.Add(new CuiPanel {
RectTransform = {
AnchorMin = "0.5020834 0.1148148", AnchorMax = "0.
// ... [Code preview truncated due to length. Full source in attached file] ...