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); }
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); }
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); }
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"); }