Example #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;
            }
        }
Example #2
0
        private void Events_OnPlayerConnected(Rocket.Unturned.Player.UnturnedPlayer player)
        {
            SetTimer();
            void OnTimedEvent(Object source, ElapsedEventArgs e)
            {
                if (player.HasPermission("queue.pass") == false)
                {
                    if (Provider.clients.Count() >= Configuration.Instance.PlayerLimit)
                    {
                        UnturnedChat.Say(player, QueuePlugin.Instance.Translate("QueueRemind"));
                    }
                }
            }

            void SetTimer()
            {
                // Create a timer with a two second interval.
                aTimer = new System.Timers.Timer(Configuration.Instance.AutoRemind);
                // Hook up the Elapsed event for the timer.
                aTimer.Elapsed  += OnTimedEvent;
                aTimer.AutoReset = true;
                aTimer.Enabled   = true;
            }

            if (Provider.clients.Count() >= Configuration.Instance.PlayerLimit)
            {
                if (player.HasPermission("queue.pass"))
                {
                    UnturnedChat.Say(player, QueuePlugin.Instance.Translate("QueueSucceed"));
                    Logger.Log($"{player.DisplayName} has been let into the server via priority queue!");
                }
                else
                {
                    player.Kick(QueuePlugin.Instance.Translate("ExceedKick", Configuration.Instance.PlayerLimit));
                    Logger.Log($"{player.DisplayName} has been kicked since they do not have priority queue!");
                }
            }
        }