Exemplo n.º 1
0
        private void UnturnedPlayerEvents_OnPlayerChatted(Rocket.Unturned.Player.UnturnedPlayer player, ref UnityEngine.Color color, string message, SDG.Unturned.EChatMode chatMode, ref bool cancel)
        {
            ChatControlPlayerComponent component = player.GetComponent <ChatControlPlayerComponent>();

            if (!player.HasPermission("ChatControl.IgnoreBadwords"))
            {
                foreach (string badword in ChatControl.Instance.Configuration.Instance.Badwords)
                {
                    if (message.ToLower().Contains(badword.ToLower()))
                    {
                        UnturnedChat.Say(player, Translate("badword_detected", badword, ++component.Warnings), MessageColor);
                        cancel = true;
                        break;
                    }
                }
            }

            if (Configuration.Instance.WarningsBeforeKick > 0 && component.Warnings >= Configuration.Instance.WarningsBeforeKick)
            {
                player.Kick(Translate("kick_ban_reason"));
                return;
            }
            if (Configuration.Instance.WarningsBeforeBan > 0 && component.Warnings >= Configuration.Instance.WarningsBeforeBan)
            {
                player.Ban(Translate("kick_ban_reason"), Configuration.Instance.BanDuration);
                return;
            }



            if (!player.HasPermission("ChatControl.IgnoreMute"))
            {
                if (component.Warnings >= Configuration.Instance.WarningsBeforeMute)
                {
                    component.IsMuted = true;
                }
            }

            if (component.IsMuted)
            {
                cancel = true;
                UnturnedChat.Say(player, Translate("you_are_muted"), MessageColor);
                return;
            }
        }
Exemplo n.º 2
0
        private void UnturnedPlayerEvents_OnPlayerChatted(Rocket.Unturned.Player.UnturnedPlayer player, ref UnityEngine.Color color, string message, SDG.Unturned.EChatMode chatMode, ref bool cancel)
        {
            var result = GetChannel(player.CSteamID);

            if (result != null && chatMode == 0 && player.HasPermission("channel." + result.Channel.ToLower()) && result.Channel.ToLower() != "global" && !message.StartsWith("/") && !message.StartsWith("@"))
            {
                cancel = true;
                foreach (var steamplayer in Provider.clients)
                {
                    UnturnedPlayer stm = UnturnedPlayer.FromSteamPlayer(steamplayer);
                    if (stm.HasPermission("channel." + result.Channel.ToLower()))
                    {
                        UnturnedChat.Say(steamplayer.playerID.steamID, "[" + result.Channel + "] " + player.CharacterName + " : " + message);
                        Times = 1;
                    }
                }
            }
            if (result.Channel.ToLower() == "global" && chatMode == 0 && (!message.StartsWith("/") && !message.StartsWith("@")))
            {
                if (player.HasPermission("chat.global"))
                {
                    ChatManager.instance.askChat(player.CSteamID, 0, message);
                    Times = 1;
                }
            }
            if (Times == 0)
            {
                UnturnedChat.Say(player, Translate("no_permission"));
            }
        }
        private void OnPlayerChatted(Rocket.Unturned.Player.UnturnedPlayer player, ref UnityEngine.Color color, string message, SDG.Unturned.EChatMode chatMode, ref bool cancel)
        {
            PlayerComponent component = player.GetComponent <PlayerComponent>();

            if (component.isMuted)
            {
                cancel = true;
                UnturnedChat.Say(player, "Sorry, you are muted.", Color.red);
                return;
            }
        }