Beispiel #1
0
 public void GivePrize(PlayerMobile pm)
 {
     if (m_prize == null || pm == null || pm.Deleted || pm.Account == null || !(pm.Account is Server.Accounting.Account))
     {
         return;
     }
     try
     {
         object o    = Activator.CreateInstance(m_prize);
         Item   item = o as Item;
         if (item != null && pm.BankBox != null)
         {
             pm.BankBox.TryDropItem(pm, item, false);
             pm.SendMessage("A prize has been added to your bankbox.");
             GeneralLogging.WriteLine("CTF", "Prize of type {0} created for playermobile '{1}', account '{2}'.", m_prize.Name, pm.Name, ((Server.Accounting.Account)pm.Account).Username);
         }
         else
         {
             GeneralLogging.WriteLine("CTF", "Error creating prize of type {0}.", m_prize.Name);
         }
     }
     catch
     {
         GeneralLogging.WriteLine("CTF", "Error creating prize of type {0}.", m_prize.Name);
     }
 }
Beispiel #2
0
        public bool TryGiveOut(Mobile m)
        {
            PlayerMobile pm = m as PlayerMobile;

            if (pm != null && !pm.Deleted && pm.Backpack != null)
            {
                if (pm.Backpack.ConsumeTotal(m_priceType, m_priceAmount))
                {
                    Item newItem = null;
                    if (m_itemParameter == -1)
                    {
                        newItem = Activator.CreateInstance(m_type) as Item;
                    }
                    else
                    {
                        ConstructorInfo[] ctors = m_type.GetConstructors();
                        //Find 1-int-constructor (for amount/skillball bonus/etc.)
                        for (int i = 0; i < ctors.Length && newItem == null; ++i)
                        {
                            ConstructorInfo ctor      = ctors[i];
                            ParameterInfo[] paramList = ctor.GetParameters();
                            if (paramList.Length == 1 && paramList[0].ParameterType.Name == "Int32")
                            {
                                object[] o = new object[1];
                                o[0]    = m_itemParameter;
                                newItem = ctor.Invoke(o) as Item;
                            }
                        }
                    }
                    if (newItem != null)
                    {
                        if (!pm.AddToBackpack(newItem))
                        {
                            newItem.MoveToWorld(pm.Location);
                        }
                        pm.SendMessage("The item has been placed in your backpack.");
                        return(true);
                    }
                    else
                    {
                        GeneralLogging.WriteLine("PrizeSystem", "Acc:{0} purchased {1} and was charged {2} but did not receive the item.", pm.Account.ToString(), m_name, m_priceString);
                    }
                }
                else
                {
                    pm.SendMessage("You need {0} to purchase this item.", this.PriceString);
                }
            }
            return(false);
        }
        public override void OnDoubleClick(Mobile from)
        {
            PlayerMobile m = (PlayerMobile)from;


            if (m == null || m.Deleted)
            {
                return;
            }

            if (m != null && m.NetState != null)
            {
                if (m_MemberShipTime == TimeSpan.Zero)
                {
                    if (m.AccessLevel < AccessLevel.GameMaster)
                    {
                        m.SendMessage("There was a problem with this ticket. You need to give this to an Administrator and ask him to use it.");
                    }
                    else if (m.AccessLevel < AccessLevel.Administrator)
                    {
                        m.SendMessage("Only an person with Administrator accesslevel can fix this ticket. Find one and ask him to doubleclick ticket for instructions");
                    }
                    else if (m.AccessLevel == AccessLevel.Administrator)
                    {
                        m.SendMessage("This is ticket probably from the first version of the ticket. It didn't save properbly and you need to set the MemberShipTime " +
                                      "with [props .The tickets name should tell you how many days to set it to(Hint: 24 hrs = 1 day). If the ticket is for permanent " +
                                      "membership. That cannot be set in props. You have to [add goldendontationbox and get it from there.");
                    }
                }
                else if (m.Backpack != null && IsChildOf(m.Backpack))
                {
                    DateTime DonationStart    = DateTime.MinValue;
                    TimeSpan DonationDuration = TimeSpan.Zero;

                    try
                    {
                        DonationStart    = DateTime.Parse(((Account)from.Account).GetTag("DonationStart"));
                        DonationDuration = TimeSpan.Parse(((Account)from.Account).GetTag("DonationDuration"));
                    }
                    catch
                    {
                    }

                    //Al: added logging
                    GeneralLogging.WriteLine("Donation", "Donationticketuse: Acc:{0}, DStart: {2}, DDur: {3}, Serial:{4}, Tickettime: {1}"
                                             , from.Account, m_MemberShipTime, DonationStart, DonationDuration, Serial);

                    //Al: Also reset DonationStart when the person is no active donator
                    if ((DonationStart == DateTime.MinValue && DonationDuration == TimeSpan.Zero) ||
                        (DateTime.Now - DonationStart > DonationDuration))
                    {
                        try
                        {
                            ((Account)from.Account).SetTag("DonationStart", DateTime.Now.ToString());
                            ((Account)from.Account).SetTag("DonationDuration", m_MemberShipTime.ToString());
                            from.SendMessage("Your donation status has been updated.");
                            this.Delete();
                            GeneralLogging.WriteLine("Donation", "    Acc:{0}, no or outdated previous donation, new DStart: {1}, new DDur: {2}", from.Account, DateTime.Now.ToString(), m_MemberShipTime.ToString());
                        }
                        catch
                        {
                            from.SendMessage("An error ocurred trying to update your donation status. Contact an Administrator.");
                            GeneralLogging.WriteLine("Donation", "    Acc:{0}, error updating donation (1) please contact a developer.", from.Account);
                        }
                    }
                    else if (DonationDuration == TimeSpan.MaxValue)
                    {
                        //already at max
                        from.SendMessage("You are already at permanent membership status.");
                        GeneralLogging.WriteLine("Donation", "    Acc:{0}, already at permanent status.", from.Account, DonationStart, DonationDuration);
                    }
                    else
                    {
                        //existing, active donation
                        try
                        {
                            //Avoid overflow
                            if (m_MemberShipTime == TimeSpan.MaxValue)
                            {
                                DonationDuration = m_MemberShipTime;
                            }
                            else
                            {
                                DonationDuration += m_MemberShipTime;
                            }

                            ((Account)from.Account).SetTag("DonationDuration", DonationDuration.ToString());
                            from.SendMessage("Your donation status has been updated.");
                            this.Delete();
                            GeneralLogging.WriteLine("Donation", "    Acc:{0}, active donation, new DonationStart: {1}, new DonationDuration: {2}", from.Account, DonationStart, DonationDuration);
                        }
                        catch
                        {
                            from.SendMessage("An error ocurred trying to update your donation status. Contact an Administrator.");
                            GeneralLogging.WriteLine("Donation", "    Acc:{0}, error updating donation (2) please contact a developer.", from.Account);
                        }
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1042001);                     // That must be in your pack for you to use it.
                }
            }
        }