Esempio n. 1
0
        public (string response, string color) OnCall(ReferenceHub sender, string[] args)
        {
            if (!sender.CheckPermission("tc.mute"))
            {
                return(Language.CommandNotEnoughPermissionsError, "red");
            }

            if (args.Length < 2)
            {
                return(string.Format(Language.CommandNotEnoughParametersError, 2, Usage), "red");
            }

            ReferenceHub target = Player.GetPlayer(args[0]);

            Collections.Chat.Player chatPlayer = args[0].GetChatPlayer();

            if (chatPlayer == null)
            {
                return(string.Format(Language.PlayerNotFoundError, args[0]), "red");
            }

            if (!double.TryParse(args[1], out double duration) || duration < 1)
            {
                return(string.Format(Language.InvalidDurationError, args[1]), "red");
            }

            string reason = string.Join(" ", args.Skip(2).Take(args.Length - 2));

            if (string.IsNullOrEmpty(reason))
            {
                return(Language.ReasonCannotBeEmptyError, "red");
            }

            if (chatPlayer.IsChatMuted())
            {
                return(string.Format(Language.PlayerIsAlreadyMutedError, chatPlayer.Name), "red");
            }

            LiteDatabase.GetCollection <Collections.Chat.Mute>().Insert(new Collections.Chat.Mute()
            {
                Target    = chatPlayer,
                Issuer    = sender.GetChatPlayer(),
                Reason    = reason,
                Duration  = duration,
                Timestamp = DateTime.Now,
                Expire    = DateTime.Now.AddMinutes(duration)
            });

            if (Configs.showChatMutedBroadcast)
            {
                target?.ClearBroadcasts();
                target?.Broadcast(Configs.chatMutedBroadcastDuration, string.Format(Configs.chatMutedBroadcast, duration, reason), false);
            }

            target?.SendConsoleMessage(string.Format(Language.MuteCommandSuccessPlayer, duration, reason), "red");

            return(string.Format(Language.MuteCommandSuccessModerator, chatPlayer.Name, duration, reason), "green");
        }
Esempio n. 2
0
        public (string response, string color) OnCall(ReferenceHub sender, string[] args)
        {
            (string message, bool isValid) = CheckMessageValidity(args.GetMessage(1), sender);

            if (!isValid)
            {
                return(message, "red");
            }

            message = $"[{sender.GetNickname()}][{Language.Private}]: {message}";

            ReferenceHub target = Player.GetPlayer(args[0]);

            if (target == null)
            {
                return(string.Format(Language.PlayerNotFoundError, args[0]), "red");
            }
            else if (sender == target)
            {
                return(Language.CannotSendMessageToThemselvesError, "red");
            }
            else if (!Configs.canSpectatorSendMessagesToAlive && sender.GetTeam() == Team.RIP && target.GetTeam() != Team.RIP)
            {
                return(Language.CannotSendMessageToAlivePlayersError, "red");
            }

            if (Configs.saveChatToDatabase)
            {
                SaveMessage(message, sender.GetChatPlayer(), new List <Collections.Chat.Player>()
                {
                    sender.GetChatPlayer()
                }, type);
            }

            SendMessage(ref message, sender, new List <ReferenceHub>()
            {
                target
            });

            if (Configs.showPrivateMessageNotificationBroadcast)
            {
                target.ClearBroadcasts();
                target.Broadcast(Configs.privateMessageNotificationBroadcastDuration, Configs.privateMessageNotificationBroadcast, false);
            }

            return(message, color);
        }
Esempio n. 3
0
 public static void TargetSendSubtitle(ReferenceHub player, string text, uint time, bool monospaced = false)
 {
     player.ClearBroadcasts();
     player.Broadcast(time, text, monospaced);
 }