Esempio n. 1
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. 2
0
 /// <summary>
 /// Gets the team color of a <see cref="ReferenceHub"/>
 /// </summary>
 /// <param name="player"></param>
 /// <returns></returns>
 public static string GetColor(this ReferenceHub player) => player.GetTeam().GetColor();
Esempio n. 3
0
        public (string response, string color) OnCall(ReferenceHub sender, string[] args)
        {
            (string message, bool isValid) = CheckMessageValidity(args.GetMessage(), sender);

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

            message = $"[{sender.GetNickname()}][{Language.Team} ({sender.GetRole().ToString().ToUpper()})]: {message}";

            IEnumerable <ReferenceHub>     targets     = Player.GetHubs().Where(chatPlayer => chatPlayer != sender && chatPlayer.GetTeam() == sender.GetTeam());
            List <Collections.Chat.Player> chatTargets = targets.GetChatPlayers();

            if (chatTargets.Count == 0)
            {
                return(Language.NoAvailablePlayersToChatWithError, "red");
            }

            color = sender.GetColor();

            if (Configs.saveChatToDatabase)
            {
                SaveMessage(message, sender.GetChatPlayer(), chatTargets, type);
            }

            SendMessage(ref message, sender, targets);

            return(message, color);
        }
Esempio n. 4
0
        public (string response, string color) OnCall(ReferenceHub sender, string[] args)
        {
            (string message, bool isValid) = CheckMessageValidity(args.GetMessage(), sender);

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

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

            IEnumerable <ReferenceHub> targets = Player.GetHubs().Where(target =>
            {
                return(sender != target && (Configs.canSpectatorSendMessagesToAlive || sender.GetTeam() != Team.RIP || target.GetTeam() == Team.RIP));
            });

            List <Collections.Chat.Player> chatPlayers = targets.GetChatPlayers();

            if (chatPlayers.Count == 0)
            {
                return(Language.NoAvailablePlayersToChatWithError, "red");
            }

            if (Configs.saveChatToDatabase)
            {
                SaveMessage(message, sender.GetChatPlayer(), chatPlayers, type);
            }

            SendMessage(ref message, sender, targets);

            return(message, color);
        }
Esempio n. 5
0
 /// <summary>
 /// Gets the <see cref="ReferenceHub">player</see>'s <see cref="Side">side</see> they're currently in.
 /// </summary>
 /// <param name="hub"></param>
 /// <returns></returns>
 public static Side GetSide(this ReferenceHub hub) => hub.GetTeam().GetSide();