Example #1
0
        public static void Run(SvPlayer player, string message)
        {
            string arg1 = GetArgument.Run(1, false, true, message);

            if (string.IsNullOrEmpty(arg1))
            {
                player.SendChatMessage(ArgRequired);
                return;
            }
            var currPlayer = GetShByStr.Run(arg1);

            if (currPlayer == null)
            {
                player.SendChatMessage(NotFoundOnline);
                return;
            }
            ReadFile.Run(MuteListFile);
            if (!MutePlayers.Contains(currPlayer.username))
            {
                MutePlayers.Add(currPlayer.username);
                File.AppendAllText(MuteListFile, currPlayer.username + Environment.NewLine);
                player.SendChatMessage($"<color={infoColor}>Muted </color><color={argColor}>{currPlayer.username}</color><color={infoColor}>.</color>");
                return;
            }
            RemoveStringFromFile.Run(MuteListFile, currPlayer.username);
            ReadFile.Run(MuteListFile);
            player.SendChatMessage($"<color={infoColor}>Unmuted </color><color={argColor}>{currPlayer.username}</color><color={infoColor}>.</color>");
        }
Example #2
0
 public static bool SvLocalChatMessage(SvPlayer player, ref string message)
 {
     if (LocalChatMute && MutePlayers.Contains(player.playerData.username))
     {
         player.SendChatMessage(SelfIsMuted);
         return(true);
     }
     LogMessage.LocalMessage(player, message);
     if (!ProximityChat)
     {
         return(false);
     }
     player.Send(SvSendType.LocalOthers, Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>[Local-Chat]</color> {new Regex("(<)").Replace(player.player.username, "<<b></b>")}: {new Regex("(<)").Replace(message, "<<b></b>")}");
     return(true);
 }
Example #3
0
        public static bool SvGlobalChatMessage(SvPlayer player, ref string message)
        {
            try
            {
                var tempMessage = message;
                if (HandleSpam.Run(player, tempMessage))
                {
                    return(true);
                }
                //Message Logging
                if (!MutePlayers.Contains(player.playerData.username))
                {
                    LogMessage.Run(player, message);
                }

                if (message.StartsWith(CmdCommandCharacter, StringComparison.CurrentCulture))
                {
                    if (OnCommand(player, ref message))
                    {
                        return(true);
                    }
                }

                //Checks if the player is muted.
                if (MutePlayers.Contains(player.playerData.username))
                {
                    player.SendChatMessage(SelfIsMuted);
                    return(true);
                }
                //Checks if the message contains a username that is AFK.
                if (AfkPlayers.Any(message.Contains))
                {
                    player.SendChatMessage(PlayerIsAFK);
                }

                var shPlayer = player.player;
                if (!PlayerList[shPlayer.ID].ChatEnabled)
                {
                    player.SendChatMessage($"<color={warningColor}>Please enable your chat again by typing</color> <color={argColor}>{CmdCommandCharacter}{CmdToggleChat}</color><color={warningColor}>.</color>");
                    return(true);
                }
                if (PlayerList[shPlayer.ID].StaffChatEnabled)
                {
                    SendChatMessageToAdmins.Run(PlaceholderParser.ParseUserMessage(shPlayer, AdminChatMessage, message));
                    return(true);
                }
                foreach (var curr in Groups)
                {
                    if (curr.Value.Users.Contains(player.playerData.username))
                    {
                        SendChatMessage.Run(PlaceholderParser.ParseUserMessage(shPlayer, curr.Value.Message, message));
                        return(true);
                    }
                }
                if (player.player.admin)
                {
                    SendChatMessage.Run(PlaceholderParser.ParseUserMessage(shPlayer, AdminMessage, message));
                    return(true);
                }
                SendChatMessage.Run(PlaceholderParser.ParseUserMessage(shPlayer, PlayerMessage, message));
            }
            catch (Exception ex)
            {
                ErrorLogging.Run(ex);
            }
            return(true);
        }