Example #1
0
        private void SendMessage(IPlayer target, IPlayer sender, string message)
        {
            var prefix = sender.Name;

            if (BetterChat != null)
            {
                message = (string)BetterChat.Call("API_GetFormattedMessage", sender, message);
                prefix  = (string)BetterChat.Call("API_GetFormattedUsername", sender);
            }
            else if (config.UseRandomColors)
            {
                prefix = covalence.FormatText($"[#{random.Next(0x1000000):X6}]{sender.Name}[/#]");
            }
            else
            {
                prefix = covalence.FormatText($"[{(sender.IsAdmin ? "#af5af5" : "#55aaff")}]{sender.Name}[/#]");
            }
#if RUST
            var basePlayer = target.Object as BasePlayer;
            basePlayer.SendConsoleCommand("chat.add2", sender.Id, message, prefix);
#else
            target.Message(message, prefix);
#endif
            if (config.LogChatMessages)
            {
                LogToFile("log", message, this);
                Log($"{sender.Name}: {message}");
            }
        }
        private void SendMessage(IPlayer target, IPlayer sender, string message)
        {
            if (config.LogChatMessages)
            {
                LogToFile("log", message, this);
                Log($"{sender.Name}: {message}");
            }

            string prefix = null;

            if (BetterChat != null)
            {
                message = covalence.FormatText(BetterChat.Call <string>("API_GetFormattedMessage", sender, message));
            }
            else if (config.UseRandomColors)
            {
                prefix = covalence.FormatText($"[#{Random.Next(0x1000000):X6}]{sender.Name}[/#]");
            }
            else
            {
                prefix = covalence.FormatText($"[{(sender.IsAdmin ? "#af5af5" : "#55aaff")}]{sender.Name}[/#]");
            }

#if RUST
            target.Command(BetterChat != null ? "chat.add" : "chat.add2", sender.Id, message, prefix);
#else
            target.Message(message, prefix);
#endif
        }
Example #3
0
        private void SendMessage(IPlayer target, IPlayer sender, string message)
        {
            var format = $"{sender.Name}: {message}";

            if (BetterChat != null)
            {
                format = (string)BetterChat.Call("API_GetFormattedMessage", sender.Id, message);
            }
            else if (config.UseRandomColors)
            {
                format = covalence.FormatText($"[#{random.Next(0x1000000):X6}]{sender.Name}[/#]: {message}");
            }
            else
            {
                format = covalence.FormatText($"[{(sender.IsAdmin ? "#af5af5" : "#55aaff")}]{sender.Name}[/#]: {message}");
            }
#if RUST
            var basePlayer = target.Object as BasePlayer;
            basePlayer.SendConsoleCommand("chat.add", sender.Id, format, 1.0);
            if (config.LogChatMessages)
            {
                ConVar.Server.Log("Log.Chat.txt", $"{basePlayer.ToString()}: {message}\n");
                LogToFile("log", message, this);
                Log($"{sender.Name}: {message}");
            }
#else
            target.Message(format);
            if (config.LogChatMessages)
            {
                LogToFile("log", message, this);
                Log($"{sender.Name}: {message}");
            }
#endif
        }
Example #4
0
        private void OnServerInitialized()
        {
            if (DiscordCore == null)
            {
                PrintError("Missing plugin dependency DiscordCore: https://umod.org/plugins/discord-core");
                return;
            }

            if (_pluginConfig.EnableDiscordTag)
            {
                BetterChat?.Call("API_RegisterThirdPartyTitle", this, new Func <IPlayer, string>(GetDiscordTag));
            }

            OnDiscordCoreReady();
        }
Example #5
0
        private void Loaded()
        {
            _instance = this;

            LoadData(ref _chatGroups);

            if (_chatGroups.Count == 0)
            {
                _chatGroups.Add(new ChatGroup("default"));
            }

            foreach (ChatGroup group in _chatGroups)
            {
                if (!permission.GroupExists(group.GroupName))
                {
                    permission.CreateGroup(group.GroupName, string.Empty, 0);
                }
            }

            SaveData(_chatGroups);
        }
Example #6
0
        void Loaded()
        {
            Instance = this;

            LoadConfig();
            LoadMessages();

            LoadData(ref ChatGroups);

            if (ChatGroups.Count == 0)
            {
                ChatGroups.Add(new ChatGroup("default"));
            }

            foreach (ChatGroup group in ChatGroups)
            {
                if (!permission.GroupExists(group.GroupName))
                {
                    permission.CreateGroup(group.GroupName, string.Empty, 0);
                }
            }

            SaveData(ChatGroups);
        }
Example #7
0
 private string GetBetterChatMessage(IPlayer player, string message)
 {
     return(BetterChat.Call <string>("API_GetFormattedMessage", player, message, false));
 }