Exemplo n.º 1
0
        public void ReInitialize()
        {
            if (config.UseDebugMessages)
            {
                Adverts.Register("Every Ten Seconds!?!?!?!?!?", Color.Chartreuse, TimeSpan.FromSeconds(10));
                Adverts.Register("Every Fifteen Seconds!?!?!?!?!?", Color.OrangeRed, TimeSpan.FromSeconds(15));
            }

            foreach (Advert.Message msg in adverts)
            {
                Adverts.Deregister(msg.Index);
            }

            adverts.Clear();

            foreach (var adv in config.Adverts)
            {
                string message = adv.Text;
                Color  color   = (Color)typeof(Color)
                                 .GetConstructor(new Type[] { typeof(int), typeof(int), typeof(int) })
                                 .Invoke(adv.Color.Cast <object>().ToArray());
                TimeSpan delay  = adv.Time.ToTimeSpan();
                TimeSpan offset = adv.Offset.ToTimeSpan();

                if (adv.RunOnce)
                {
                    offset = delay;

                    delay = TimeSpan.MaxValue - TimeSpan.FromDays(1);
                }

                adverts.Add(Adverts.Register(message, color, delay, offset));
            }
        }
Exemplo n.º 2
0
        private void DeleteConfigAdvert(int index)
        {
            ConfigAdverts.Config.Advert cfad = ConfigAdverts.config.Adverts[index];
            ConfigAdverts.config.Adverts.RemoveNoShift(index);

            foreach (var m in Advert.Instance.Messages)
            {
                if (!EqualityComparer <Advert.Message> .Default.Equals(m, default(Advert.Message)) &&
                    m.Text == cfad.Text && m.Delay == cfad.Time.ToTimeSpan() && m.Offset == cfad.Offset.ToTimeSpan() &&
                    new int[] { m.Color.R, m.Color.G, m.Color.B } == cfad.Color)
                {
                    Adverts.Deregister(m.Index);
                }
            }
        }
Exemplo n.º 3
0
        private void RemindCommand(CommandArgs args)
        {
            if (args.Parameters.Count < 2)
            {
                args.Player.SendMessage("Syntax: <message> <time>\nWhere 'time'is in the format '<num><unit>+', with unit being one of 'd', 'h', 'm', 's', or 'ms'.", Color.Red);
                return;
            }

            string message = args.Parameters[0];
            string time    = args.Parameters[1];

            TimeSpan tim = time.ToTimeSpan();

            RemindPlayerCheck chk = new RemindPlayerCheck(args.Player, this);

            var msg = Adverts.Register("Reminder: " + message, Color.LimeGreen, tim, chk.Check, chk.Send);

            args.Player.SendMessage("OK! You will be reminded '{0}' in {1}".SFormat(message, tim.ToReadable()), Color.LimeGreen);

            Reminders.EnsurePosition(args.Player.Index);
            Reminders[args.Player.Index].Add(msg);
        }
Exemplo n.º 4
0
 public bool Send(Advert.Message m, TSPlayer ply)
 {
     self.Reminders[ply.Index].Remove(m);
     Adverts.Deregister(m.Index);
     return(true);
 }