public static void SetPatronRoles(Player[] players)
        {
            if (ArgumentParsing.ArrayIsNullOrEmpty(players))
            {
                return;
            }

            PatreonPlugin.CreateFile();

            Patron[] patronIds = PatreonPlugin.Patrons;

            foreach (Player player in players)
            {
                foreach (Patron patron in patronIds)
                {
                    if (string.IsNullOrEmpty(player.SteamId) || patron.SteamId != player.SteamId)
                    {
                        continue;
                    }

                    player.SetRank(patron.Colour, patron.Tag);
                    break;
                }
            }
        }
示例#2
0
        public override void OnEnable()
        {
            CreateFile();

            Singleton = this;

            Info(Details.name + " v" + Details.version + " has been enabled!");
        }
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            List <string> output = new List <string>();

            PatreonPlugin.CreateFile();

            if (args.Length >= 1)
            {
                switch (args[0].ToLower())
                {
                case "add":
                    if (args.Length >= 2)
                    {
                        string entry = string.Join(" ", args.Skip(1)).Trim();
                        output.Add(IsValidEntry(entry) ? AddPatron(entry) : Errors.InvalidEntry);
                    }
                    else
                    {
                        output.Add(Errors.NotEnoughArgs);
                    }

                    break;

                case "remove":
                    if (args.Length >= 2)
                    {
                        output.Add(RemovePatron(args[1].Trim()));
                    }
                    else
                    {
                        output.Add(Errors.NotEnoughArgs);
                    }

                    break;

                case "refresh":
                    output.Add(RefreshPatrons());
                    break;

                default:
                    output.Add(Errors.FuncNotFound);
                    break;
                }
            }
            else
            {
                output.Add(Errors.NotEnoughArgs);
            }

            return(output.ToArray());
        }
        public void OnSetRole(PlayerSetRoleEvent ev)
        {
            ev.Items.AddRange(GetPatronItems(ev.Player, ev.TeamRole));

            foreach (Patron patron in PatreonPlugin.GetPatrons())
            {
                if (patron.SteamId != ev.Player.SteamId || !patron.AutoRefresh)
                {
                    continue;
                }

                PlayerJoinHandler.SetPatronRoles(ev.Player);
                break;
            }
        }
示例#5
0
        public bool HasSteamId(string steamId)
        {
            if (string.IsNullOrEmpty(steamId))
            {
                return(false);
            }

            foreach (Patron patron in PatreonPlugin.GetPatrons())
            {
                if (steamId.Trim() == patron.SteamId)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#6
0
        public static void SetPatronRoles(Player[] players)
        {
            PatreonPlugin.CreateFile();

            List <Patron> patronIds = PatreonPlugin.GetPatrons();

            foreach (Player player in players)
            {
                foreach (Patron patron in patronIds)
                {
                    if (string.IsNullOrEmpty(player.SteamId) || patron.SteamId != player.SteamId)
                    {
                        continue;
                    }

                    player.SetRank(patron.Colour, patron.Tag);
                    break;
                }
            }
        }
        public ItemType[] GetPatronItems(Player player, TeamRole teamRole)
        {
            PatreonPlugin.CreateFile();

            List <ItemType> items = new List <ItemType>();

            foreach (Patron patron in PatreonPlugin.GetPatrons())
            {
                if (patron.SteamId != player.SteamId || string.IsNullOrEmpty(patron.Items))
                {
                    continue;
                }

                foreach (string item in patron.Items.Split(','))
                {
                    string[] split = item.Trim().Split(new[] { ':' }, 2);

                    if (split.Length >= 2 && int.TryParse(split[0].Trim(), out int charClass) && int.TryParse(split[1].Trim(), out int classItem))
                    {
                        if (((int)teamRole.Role == charClass || charClass < 0) && !teamRole.Team.Equals(Team.RIP) && !teamRole.Team.Equals(Team.SCP))
                        {
                            items.Add((ItemType)classItem);
                        }
                    }
                    else if (split.Length >= 2)
                    {
                        PatreonPlugin.Singleton.Error(string.Format(Errors.IntegerParse, item));
                    }
                    else
                    {
                        PatreonPlugin.Singleton.Error(string.Format(Errors.MissingSplitChar, item));
                    }
                }
            }

            return(items.ToArray());
        }