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 });
        }
        public string[] RemoveVariable(string name, string noneSavedResponse, string cantFindResponse, string removedAllResponse, string successResponse)
        {
            if (FilePath == "")
            {
                return new string[] { "Error: missing filepath." }
            }
            ;

            if (name.ToLower() == "all" || name == "*")
            {
                File.WriteAllText(FilePath, String.Empty);

                return(new string[] { removedAllResponse });
            }

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

            if (currentText.Length > 0)
            {
                if (CustomAnnouncements.RemoveLineFromFile(currentText, name, FilePath) == -1)
                {
                    return(new string[] { cantFindResponse });
                }
                else
                {
                    return(new string[] { successResponse });
                }
            }
            else
            {
                return(new string[] { noneSavedResponse });
            }
        }
Beispiel #3
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 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 });
        }
Beispiel #5
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 > 0)
            {
                if (args[0].ToLower() == "set")
                {
                    if (args.Length > 1)
                    {
                        string text = CustomAnnouncements.StringArrayToString(args, 1);
                        return(an.SetAnnouncement(text, "Player escape announcement set."));
                    }
                }
                else if (args[0].ToLower() == "view")
                {
                    return(an.ViewAnnouncement("Error: announcement has not been set."));
                }
                else if (args[0].ToLower() == "clear")
                {
                    return(an.ClearAnnouncement("Player escape announcement cleared."));
                }
            }
            return(new string[] { GetUsage() });
        }
    }
Beispiel #6
0
        public PlayerEscapeHandler(string input)
        {
            RoundEventHandler.isPlaying = true;
            float time = CustomAnnouncements.CalculateDuration(input) + 6.3f;

            Thread.Sleep((int)(time * 1000));
            RoundEventHandler.isPlaying = false;
        }
 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);
         }
     }
 }
Beispiel #8
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 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...");
            }
        }
 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...");
         }
     }
 }
 public bool CanRunCommand(ICommandSender sender)
 {
     if (sender is Player)
     {
         Player player = (Player)sender;
         if (!CustomAnnouncements.IsPlayerWhitelisted(player, WhitelistRanks))
         {
             return(false);
         }
     }
     return(true);
 }
 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 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 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...");
            }
        }
Beispiel #15
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 > 0)
            {
                return(an.PlayCustomAnnouncement(CustomAnnouncements.StringArrayToString(args, 0), "Announcement has been made."));
            }
            return(new string[] { GetUsage() });
        }
    }
Beispiel #16
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 > 0)
            {
                if (args[0].ToLower() == "save")
                {
                    if (args.Length > 2)
                    {
                        string name = args[1];

                        if (name.ToLower() == "all" || name == "*")
                        {
                            return(new string[] { "Error: invalid preset name." });
                        }

                        return(an.SetVariable(name, CustomAnnouncements.StringArrayToString(args, 2), "Error: Preset name already exists.", "Saved preset \"" + name + "\"."));
                    }
                }
                else if (args[0].ToLower() == "load")
                {
                    if (args.Length > 1)
                    {
                        return(an.LoadVariable(args[1], "Error: no presets saved.", "Error: couldn't find preset \"" + args[1] + "\".", "Loaded preset \"" + args[1] + "\"."));
                    }
                }
                else if (args[0].ToLower() == "remove")
                {
                    if (args.Length > 1)
                    {
                        return(an.RemoveVariable(args[1], "Error: there are no saved presets.", "Error: couldn't find preset \"" + args[1] + "\".", "Removed all presets.", "Removed preset \"" + args[1] + "\"."));
                    }
                }
                else if (args[0].ToLower() == "list")
                {
                    return(an.ListVariables("Error: there are no saved presets."));
                }
            }
            return(new string[] { GetUsage() });
        }
    }
Beispiel #17
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 > 0)
            {
                if (args[0].ToLower() == "set")
                {
                    if (args.Length > 1)
                    {
                        int time = 0;
                        if (Int32.TryParse(args[1], out int a))
                        {
                            time = a;
                        }
                        else
                        {
                            return new string[] { "Error: invalid time" }
                        };

                        if (args.Length > 2)
                        {
                            return(an.SetVariable(time.ToString(), CustomAnnouncements.StringArrayToString(args, 2), "Error: Preset name already exists.", "Saved timer."));
                        }
                    }
                }
                else if (args[0].ToLower() == "remove")
                {
                    if (args.Length > 1)
                    {
                        return(an.RemoveVariable(args[1], "Error: there are no set timers.", "Error: couldn't find timer.", "Removed all timers.", "Removed timer."));
                    }
                }
                else if (args[0].ToLower() == "list")
                {
                    return(an.ListVariables("Error: there are no set timers."));
                }
            }
            return(new string[] { GetUsage() });
        }
    }
}
Beispiel #18
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);
            }
        }
Beispiel #19
0
        public static Player GetPlayer(string args, out Player playerOut)
        {
            int    maxNameLength = 31, LastnameDifference = 31;
            Player plyer = null;
            string str1  = args.ToLower();

            foreach (Player pl in PluginManager.Manager.Server.GetPlayers(str1))
            {
                if (!pl.Name.ToLower().Contains(args.ToLower()))
                {
                    goto NoPlayer;
                }
                if (str1.Length < maxNameLength)
                {
                    int    x    = maxNameLength - str1.Length;
                    int    y    = maxNameLength - pl.Name.Length;
                    string str2 = pl.Name;
                    for (int i = 0; i < x; i++)
                    {
                        str1 += "z";
                    }
                    for (int i = 0; i < y; i++)
                    {
                        str2 += "z";
                    }
                    int nameDifference = CustomAnnouncements.LevenshteinDistance(str1, str2);
                    if (nameDifference < LastnameDifference)
                    {
                        LastnameDifference = nameDifference;
                        plyer = pl;
                    }
                }
                NoPlayer :;
            }
            playerOut = plyer;
            return(playerOut);
        }
Beispiel #20
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 > 0)
            {
                if (args[0].ToLower() == "save")
                {
                    if (args.Length > 2)
                    {
                        string name = "", id = "";
                        Player cPlayer = CustomAnnouncements.GetPlayer(args[1], out cPlayer);
                        if (cPlayer != null)
                        {
                            name = cPlayer.Name;
                            id   = cPlayer.SteamId;
                        }
                        else if (ulong.TryParse(args[1], out ulong a))
                        {
                            name = a.ToString();
                            id   = a.ToString();
                        }
                        else
                        {
                            return(new string[] { "Error: invalid player id." });
                        }

                        return(an.SetVariable(id, CustomAnnouncements.StringArrayToString(args, 2), "Error: Player already exists.", "Saved announcement for player \"" + name + "\"."));
                    }
                }
                else if (args[0].ToLower() == "remove")
                {
                    if (args.Length > 1)
                    {
                        string name = "", id = "";
                        if (args[1].ToLower() != "all" && args[1] != "*")
                        {
                            Player cPlayer = CustomAnnouncements.GetPlayer(args[1], out cPlayer);
                            if (cPlayer != null)
                            {
                                name = cPlayer.Name;
                                id   = cPlayer.SteamId;
                            }
                            else if (ulong.TryParse(args[1], out ulong a))
                            {
                                name = a.ToString();
                                id   = a.ToString();
                            }
                        }
                        else
                        {
                            id = "all";
                        }

                        return(an.RemoveVariable(id, "Error: there are no player announcements.", "Error: couldn't find player \"" + name + "\".", "Removed all player announcements.", "Removed player \"" + name + "\"."));
                    }
                }
                else if (args[0].ToLower() == "list")
                {
                    return(an.ListVariables("Error: there are no player announcements."));
                }
            }
            return(new string[] { GetUsage() });
        }
    }
        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 LoadWhitelist()
 {
     WhitelistRanks = CustomAnnouncements.SetWhitelist(WhitelistConfig);
 }