Example #1
0
        public void OnRegionEnter(RegionHooks.RegionEnteredEventArgs args)
        {
            RegionBuff rb = Array.Find(config.regionbuffs, p => p.regionName == args.Region.Name && p.buffs.Count > 0);

            if (rb == null)
            {
                return;
            }

            if (hasAnnounced[args.Player.Index].Contains(args.Region.Name))
            {
                return;
            }

            args.Player.SendSuccessMessage("You have entered a region with the following buffs enabled: {0}", string.Join(", ", rb.buffs.Keys.Select(p => Main.buffName[p])));
            hasAnnounced[args.Player.Index].Add(args.Region.Name);

            //KeyValuePair<string, List<int>> regionkvp;

            //regionkvp = new KeyValuePair<string, List<int>>("null", new List<int>() { 0 });

            //foreach (RegionBuff rb in config.regionbuffs)
            //{
            //    if (rb.regionName == args.Region.Name && rb.buffIDs.Count > 0)
            //    {
            //        regionkvp = kvp;
            //    }
            //}

            //if (regionkvp.Key != "null" && !hasAnnounced[args.Player.Index].Contains(args.Region.Name))
            //{
            //    args.Player.SendSuccessMessage("You have entered a region with the following buffs enabled: {0}", string.Join(", ", regionkvp.Value.Select(p => Main.buffName[p])));
            //    hasAnnounced[args.Player.Index].Add(args.Region.Name);
            //}
        }
Example #2
0
        private void OnElapsed(object sender, ElapsedEventArgs args)
        {
            for (int i = 0; i < TShock.Players.Length; i++)
            {
                if (TShock.Players[i] == null)
                {
                    continue;
                }

                foreach (int buff in globalbuffs)
                {
                    TShock.Players[i].SetBuff(buff, 18000);
                }

                if (TShock.Players[i].CurrentRegion != null)
                {
                    RegionBuff rb = Array.Find(config.regionbuffs, p => TShock.Players[i].CurrentRegion.Name == p.regionName && p.buffs.Count > 0);

                    if (rb != null)
                    {
                        foreach (KeyValuePair <int, int> kvp in rb.buffs)
                        {
                            TShock.Players[i].SetBuff(kvp.Key, kvp.Value * 60);
                        }
                    }
                }

                if (!TShock.Players[i].IsLoggedIn)
                {
                    continue;
                }

                int id = TShock.Players[i].User.ID;

                if (permas[id].bufflist.Count > 0)
                {
                    for (int k = 0; k < permas[id].bufflist.Count; k++)
                    {
                        TShock.Players[i].SetBuff(permas[id].bufflist[k], 18000);
                    }
                }

                //foreach (KeyValuePair<string, List<int>> kvp in config.regionbuffs)
                //{
                //    if (kvp.Key == null || kvp.Key == "null" || kvp.Value.Count == 0)
                //        continue;

                //    if (TShock.Players[i].CurrentRegion.Name == kvp.Key)
                //    {
                //        foreach (int buff in kvp.Value)
                //        {
                //            TShock.Players[i].SetBuff(buff, 1000);
                //        }
                //    }
                //}
            }
        }
Example #3
0
        public void OnRegionEnter(RegionHooks.RegionEnteredEventArgs args)
        {
            RegionBuff rb = Array.Find(config.regionbuffs, p => p.regionName == args.Region.Name && p.buffs.Count > 0);

            if (rb == null)
            {
                return;
            }

            if (hasAnnounced[args.Player.Index].Contains(args.Region.Name))
            {
                return;
            }

            args.Player.SendSuccessMessage("You have entered a region with the following buffs enabled: {0}", string.Join(", ", rb.buffs.Keys.Select(p => Main.buffName[p])));
            hasAnnounced[args.Player.Index].Add(args.Region.Name);
        }
Example #4
0
        private void OnElapsed(object sender, ElapsedEventArgs args)
        {
            for (int i = 0; i < TShock.Players.Length; i++)
            {
                if (TShock.Players[i] == null)
                {
                    continue;
                }

                foreach (int buff in globalbuffs)
                {
                    TShock.Players[i].SetBuff(buff, 18000);
                }

                if (TShock.Players[i].CurrentRegion != null)
                {
                    RegionBuff rb = config.regionbuffs.FirstOrDefault(p => TShock.Players[i].CurrentRegion.Name == p.regionName && p.buffs.Count > 0);

                    if (rb != null)
                    {
                        foreach (KeyValuePair <int, int> kvp in rb.buffs)
                        {
                            TShock.Players[i].SetBuff(kvp.Key, kvp.Value * 60);
                        }
                    }
                }

                if (!TShock.Players[i].IsLoggedIn)
                {
                    continue;
                }

                if (DB.PlayerBuffs.ContainsKey(TShock.Players[i].Account.ID))
                {
                    foreach (var buff in DB.PlayerBuffs[TShock.Players[i].Account.ID].bufflist)
                    {
                        TShock.Players[i].SetBuff(buff, 18000);
                    }
                }
            }
        }
Example #5
0
        public void OnRegionEnter(RegionHooks.RegionEnteredEventArgs args)
        {
            RegionBuff rb = config.regionbuffs.FirstOrDefault(p => p.regionName == args.Region.Name && p.buffs.Count > 0);

            if (rb == null)
            {
                return;
            }

            //Probably occurs when this is thrown before Greet (ie when spawning)
            if (!hasAnnounced.ContainsKey(args.Player.Index))
            {
                return;
            }

            if (hasAnnounced[args.Player.Index].Contains(args.Region.Name))
            {
                return;
            }

            args.Player.SendSuccessMessage("You have entered a region with the following buffs enabled: {0}", string.Join(", ", rb.buffs.Keys.Select(p => TShock.Utils.GetBuffName(p))));
            hasAnnounced[args.Player.Index].Add(args.Region.Name);
        }