Esempio n. 1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (!m_Town.IsFinance(m_From) || m_Town.Owner != m_Faction)
            {
                m_From.SendLocalizedMessage(1010339); // You no longer control this city
                return;
            }

            int type, index;

            if (!FromButtonID(info.ButtonID, out type, out index))
            {
                return;
            }

            switch (type)
            {
            case 0:     // general
            {
                switch (index)
                {
                case 0:             // set price
                {
                    int[] switches = info.Switches;

                    if (switches.Length == 0)
                    {
                        break;
                    }

                    int opt    = switches[0];
                    int newTax = 0;

                    if (opt >= 1 && opt <= m_PriceOffsets.Length)
                    {
                        newTax = m_PriceOffsets[opt - 1];
                    }

                    if (m_Town.Tax == newTax)
                    {
                        break;
                    }

                    if (m_From.AccessLevel == AccessLevel.Player && !m_Town.TaxChangeReady)
                    {
                        TimeSpan remaining = DateTime.UtcNow - (m_Town.LastTaxChange + Town.TaxChangePeriod);

                        if (remaining.TotalMinutes < 4)
                        {
                            m_From.SendLocalizedMessage(1042165);                 // You must wait a short while before changing prices again.
                        }
                        else if (remaining.TotalMinutes < 10)
                        {
                            m_From.SendLocalizedMessage(1042166);                 // You must wait several minutes before changing prices again.
                        }
                        else if (remaining.TotalHours < 1)
                        {
                            m_From.SendLocalizedMessage(1042167);                 // You must wait up to an hour before changing prices again.
                        }
                        else if (remaining.TotalHours < 4)
                        {
                            m_From.SendLocalizedMessage(1042168);                 // You must wait a few hours before changing prices again.
                        }
                        else
                        {
                            m_From.SendLocalizedMessage(1042169);                 // You must wait several hours before changing prices again.
                        }
                    }
                    else
                    {
                        m_Town.Tax = newTax;

                        if (m_From.AccessLevel == AccessLevel.Player)
                        {
                            m_Town.LastTaxChange = DateTime.UtcNow;
                        }
                    }

                    break;
                }
                }

                break;
            }

            case 1:     // make vendor
            {
                List <VendorList> vendorLists = m_Town.VendorLists;

                if (index >= 0 && index < vendorLists.Count)
                {
                    VendorList vendorList = vendorLists[index];

                    Town town = Town.FromRegion(m_From.Region);

                    if (Town.FromRegion(m_From.Region) != m_Town)
                    {
                        m_From.SendLocalizedMessage(1010305);         // You must be in your controlled city to buy Items
                    }
                    else if (vendorList.Vendors.Count >= vendorList.Definition.Maximum)
                    {
                        m_From.SendLocalizedMessage(1010306);         // You currently have too many of this enhancement type to place another
                    }
                    else if (BaseBoat.FindBoatAt(m_From.Location, m_From.Map) != null)
                    {
                        m_From.SendMessage("You cannot place a vendor here");
                    }
                    else if (m_Town.Silver >= vendorList.Definition.Price)
                    {
                        BaseFactionVendor vendor = vendorList.Construct(m_Town, m_Faction);

                        if (vendor != null)
                        {
                            m_Town.Silver -= vendorList.Definition.Price;

                            vendor.MoveToWorld(m_From.Location, m_From.Map);
                            vendor.Home = vendor.Location;
                        }
                    }
                }

                break;
            }
            }
        }
Esempio n. 2
0
        private static void EventSink_Speech(SpeechEventArgs e)
        {
            Mobile from = e.Mobile;

            int[] keywords = e.Keywords;

            for (int i = 0; i < keywords.Length; ++i)
            {
                switch (keywords[i])
                {
                case 0x00E4:     // *i wish to access the city treasury*
                {
                    Town town = Town.FromRegion(from.Region);

                    if (town == null || !town.IsFinance(from) || !from.Alive)
                    {
                        break;
                    }

                    if (FactionGump.Exists(from))
                    {
                        from.SendLocalizedMessage(1042160);         // You already have a faction menu open.
                    }
                    else if (town.Owner != null && from is PlayerMobile)
                    {
                        from.SendGump(new FinanceGump((PlayerMobile)from, town.Owner, town));
                    }

                    break;
                }

                case 0x0ED:     // *i am sheriff*
                {
                    Town town = Town.FromRegion(from.Region);

                    if (town == null || !town.IsSheriff(from) || !from.Alive)
                    {
                        break;
                    }

                    if (FactionGump.Exists(from))
                    {
                        from.SendLocalizedMessage(1042160);         // You already have a faction menu open.
                    }
                    else if (town.Owner != null)
                    {
                        from.SendGump(new SheriffGump((PlayerMobile)from, town.Owner, town));
                    }

                    break;
                }

                case 0x00EF:     // *you are fired*
                {
                    Town town = Town.FromRegion(from.Region);

                    if (town == null)
                    {
                        break;
                    }

                    if (town.IsFinance(from) || town.IsSheriff(from))
                    {
                        town.BeginOrderFiring(from);
                    }

                    break;
                }

                case 0x00E5:     // *i wish to resign as finance minister*
                {
                    PlayerState pl = PlayerState.Find(from);

                    if (pl != null && pl.Finance != null)
                    {
                        pl.Finance.Finance = null;
                        from.SendLocalizedMessage(1005081);         // You have been fired as Finance Minister
                    }

                    break;
                }

                case 0x00EE:     // *i wish to resign as sheriff*
                {
                    PlayerState pl = PlayerState.Find(from);

                    if (pl != null && pl.Sheriff != null)
                    {
                        pl.Sheriff.Sheriff = null;
                        from.SendLocalizedMessage(1010270);         // You have been fired as Sheriff
                    }

                    break;
                }

                case 0x00E9:     // *what is my faction term status*
                {
                    PlayerState pl = PlayerState.Find(from);

                    if (pl != null && pl.IsLeaving)
                    {
                        if (Faction.CheckLeaveTimer(from))
                        {
                            break;
                        }

                        TimeSpan remaining = (pl.Leaving + Faction.LeavePeriod) - DateTime.UtcNow;

                        if (remaining.TotalDays >= 1)
                        {
                            from.SendLocalizedMessage(1042743, remaining.TotalDays.ToString("N0"));        // Your term of service will come to an end in ~1_DAYS~ days.
                        }
                        else if (remaining.TotalHours >= 1)
                        {
                            from.SendLocalizedMessage(1042741, remaining.TotalHours.ToString("N0"));         // Your term of service will come to an end in ~1_HOURS~ hours.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1042742);         // Your term of service will come to an end in less than one hour.
                        }
                    }
                    else if (pl != null)
                    {
                        from.SendLocalizedMessage(1042233);         // You are not in the process of quitting the faction.
                    }

                    break;
                }

                case 0x00EA:     // *message faction*
                {
                    Faction faction = Faction.Find(from);

                    if (faction == null || !faction.IsCommander(from))
                    {
                        break;
                    }

                    if (from.AccessLevel == AccessLevel.Player && !faction.FactionMessageReady)
                    {
                        from.SendLocalizedMessage(1010264);         // The required time has not yet passed since the last message was sent
                    }
                    else
                    {
                        faction.BeginBroadcast(from);
                    }

                    break;
                }

                case 0x00EC:     // *showscore*
                {
                    PlayerState pl = PlayerState.Find(from);

                    if (pl != null)
                    {
                        Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(ShowScore_Sandbox), pl);
                    }

                    break;
                }

                case 0x0178:     // i honor your leadership
                {
                    Faction faction = Faction.Find(from);

                    if (faction != null)
                    {
                        faction.BeginHonorLeadership(from);
                    }

                    break;
                }
                }
            }
        }