Esempio n. 1
0
        public ChaosSpawnHandler(Plugin plugin, string[] message)
        {
            Thread.Sleep(50);
            string text = CustomAnnouncements.ReplaceVariables(CustomAnnouncements.SpacePeriods(CustomAnnouncements.StringArrayToString(message, 0)));

            plugin.pluginManager.Server.Map.AnnounceCustomMessage(text);
        }
        public void OnRoundEnd(RoundEndEvent ev)
        {
            CustomAnnouncements.roundStarted = false;

            string[] message = File.ReadAllLines(CustomAnnouncements.RoundEndFilePath);
            if (message.Length > 0)
            {
                string text = CustomAnnouncements.ReplaceVariables(CustomAnnouncements.SpacePeriods(CustomAnnouncements.StringArrayToString(message, 0)));
                plugin.pluginManager.Server.Map.AnnounceCustomMessage(text);
                plugin.Info("Running round end announcement...");
            }
        }
Esempio n. 3
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            CustomAnnouncements.ann = UnityEngine.Object.FindObjectOfType <NineTailedFoxAnnouncer>();
            if (!an.CanRunCommand(sender))
            {
                return new string[] { "You are not allowed to run this command." }
            }
            ;

            if (args.Length > 1)
            {
                int start, end = 0;

                if (int.TryParse(args[0], out int a))
                {
                    start = a;
                }
                else
                {
                    return(new string[] { "Not a valid number!" });
                }

                if (int.TryParse(args[1], out int b))
                {
                    end = b;
                }
                else
                {
                    return(new string[] { "Not a valid number!" });
                }

                string[] statement = GetCountdown(start, end);

                if (statement != null)
                {
                    if (args.Length > 2)
                    {
                        string saveText = CustomAnnouncements.HandleNumbers(CustomAnnouncements.SpacePeriods(CustomAnnouncements.StringArrayToString(args, 2)));
                        return(an.PlayCustomAnnouncement(string.Join(" ", statement) + " . . " + CustomAnnouncements.ReplaceVariables(saveText), "Countdown started."));
                    }
                    else
                    {
                        return(an.PlayCustomAnnouncement(string.Join(" ", statement), "Countdown started."));
                    }
                }
                else
                {
                    return(new string[] { "Error: starting value is less than or equal to ending value." });
                }
            }
            return(new string[] { GetUsage() });
        }
    }
        public void OnRoundStart(RoundStartEvent ev)
        {
            CustomAnnouncements.roundStarted = true;
            Thread TimerHandler = new Thread(new ThreadStart(() => new TimerHandler(plugin)));

            TimerHandler.Start();

            string[] message = File.ReadAllLines(CustomAnnouncements.RoundStartFilePath);
            if (message.Length > 0)
            {
                string text = CustomAnnouncements.ReplaceVariables(CustomAnnouncements.SpacePeriods(CustomAnnouncements.StringArrayToString(message, 0)));
                plugin.pluginManager.Server.Map.AnnounceCustomMessage(text);
                plugin.Info("Running round start announcement...");
            }
        }
        public string[] SetAnnouncement(string text, string successMessage)
        {
            if (FilePath == "")
            {
                return new string[] { "Error: missing filepath." }
            }
            ;

            if (text.Length > 0)
            {
                string testText = CustomAnnouncements.GetNonValidText(CustomAnnouncements.HandleNumbers(CustomAnnouncements.SpacePeriods(text)).Split(' '));

                if (testText != null)
                {
                    return(new string[] { "Error: phrase \"" + testText + "\" is not in text to speech." });
                }
            }
            else
            {
                return(new string[] { GetUsage });
            }
            File.WriteAllText(FilePath, String.Empty);
            File.AppendAllText(FilePath, text);

            return(new string[] { successMessage });
        }
 public string[] PlayCustomAnnouncement(string text, string successResponse)
 {
     if (text.Length > 0)
     {
         string testText = CustomAnnouncements.GetNonValidText(CustomAnnouncements.HandleNumbers(CustomAnnouncements.SpacePeriods(text)).Split(' '));
         if (testText != null)
         {
             return(new string[] { "Error: phrase \"" + testText + "\" is not in text to speech." });
         }
         PluginManager.Manager.Server.Map.AnnounceCustomMessage(CustomAnnouncements.ReplaceVariables(CustomAnnouncements.HandleNumbers(CustomAnnouncements.SpacePeriods(text))));
         return(new string[] { successResponse });
     }
     return(new string[] { GetUsage });
 }
        public string[] SetVariable(string name, string input, string existsResponse, string successResponse)
        {
            if (FilePath == "")
            {
                return new string[] { "Error: missing filepath." }
            }
            ;

            string[] currentText = File.ReadAllLines(FilePath);

            if (input.Length > 0)
            {
                string text = CustomAnnouncements.GetNonValidText(CustomAnnouncements.HandleNumbers(CustomAnnouncements.SpacePeriods(input)).Split(' '));

                if (text != null)
                {
                    return(new string[] { "Error: phrase \"" + text + "\" is not in text to speech." });
                }
            }
            else
            {
                return(new string[] { GetUsage });
            }

            int output = CustomAnnouncements.AddLineToFile(FilePath, name.ToString(), input);

            if (output == -1)
            {
                return(new string[] { existsResponse });
            }

            return(new string[] { successResponse });
        }
Esempio n. 8
0
        public TimerHandler(Plugin plugin)
        {
            string[] timers = File.ReadAllLines(CustomAnnouncements.TimersFilePath);

            while (CustomAnnouncements.roundStarted)
            {
                foreach (string timer in timers)
                {
                    if (timer.Length > 0)
                    {
                        if (plugin.pluginManager.Server.Round.Duration == Int32.Parse(timer.Split(':')[0]))
                        {
                            string message = timer.Split(':')[1].Substring(1);
                            plugin.pluginManager.Server.Map.AnnounceCustomMessage(CustomAnnouncements.ReplaceVariables(CustomAnnouncements.SpacePeriods(message)));
                            plugin.Info("Running timer announcement...");
                        }
                    }
                }
                Thread.Sleep(1000);
            }
        }
 public void OnCheckEscape(PlayerCheckEscapeEvent ev)
 {
     string[] message = File.ReadAllLines(CustomAnnouncements.PlayerEscapeFilePath);
     if (message.Length > 0)
     {
         if (!isPlaying)
         {
             string str = CustomAnnouncements.StringArrayToString(message, 0).Replace("$escape_class", RoleConversions.RoleConversionDict[ev.Player.TeamRole.Role]);
             plugin.pluginManager.Server.Map.AnnounceCustomMessage(CustomAnnouncements.ReplaceVariables(CustomAnnouncements.SpacePeriods(str)));
             plugin.Info("Running player escape announcement...");
             Thread WaitingForPlayersHandler = new Thread(new ThreadStart(() => new PlayerEscapeHandler(str)));
             WaitingForPlayersHandler.Start();
         }
     }
 }
        public void OnWaitingForPlayers(WaitingForPlayersEvent ev)
        {
            foreach (Announcement an in CustomAnnouncements.anList)
            {
                an.LoadWhitelist();
            }

            string[] message = File.ReadAllLines(CustomAnnouncements.WaitingForPlayersFilePath);
            if (message.Length > 0)
            {
                Thread WaitingForPlayersHandler = new Thread(new ThreadStart(() => new WaitingForPlayersHandler(plugin, CustomAnnouncements.ReplaceVariables(CustomAnnouncements.SpacePeriods(CustomAnnouncements.StringArrayToString(message, 0))))));
                WaitingForPlayersHandler.Start();
            }
        }
 public void OnPlayerJoin(PlayerJoinEvent ev)
 {
     if (File.ReadAllLines(CustomAnnouncements.PlayerJoinFilePath).Length > 0)
     {
         if (CustomAnnouncements.DoesKeyExistInFile(CustomAnnouncements.PlayerJoinFilePath, ev.Player.SteamId))
         {
             plugin.pluginManager.Server.Map.AnnounceCustomMessage(CustomAnnouncements.ReplaceVariables(CustomAnnouncements.SpacePeriods(CustomAnnouncements.GetValueOfKey(CustomAnnouncements.PlayerJoinFilePath, ev.Player.SteamId.ToString()))));
             plugin.Info("Running player join announcement for player: " + ev.Player.Name);
         }
     }
 }
 public void OnStartCountdown(WarheadStartEvent ev)
 {
     if (ev.Activator == null)
     {
         string[] message = File.ReadAllLines(CustomAnnouncements.WarheadAutoStartFilePath);
         if (message.Length > 0)
         {
             plugin.pluginManager.Server.Map.AnnounceCustomMessage(CustomAnnouncements.ReplaceVariables(CustomAnnouncements.SpacePeriods(CustomAnnouncements.StringArrayToString(message, 0))));
             plugin.Info("Running auto warhead announcement...");
         }
     }
 }