コード例 #1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            bool isOwner = (from.AccessLevel >= AccessLevel.GameMaster || from == m_House.Owner);
            bool isCoOwner;
            bool isFriend;

            if (isOwner)
            {
                isCoOwner = isFriend = true;
            }
            else
            {
                isCoOwner = m_House.IsCoOwner(from);

                if (isCoOwner)
                {
                    isFriend = true;
                }
                else
                {
                    isFriend = m_House.IsFriend(from);
                }
            }

            if (!isFriend)
            {
                return;
            }

            switch (info.ButtonID)
            {
            case 1:                     // Rename sign
            {
                if (isOwner)
                {
                    from.Prompt = new StaticRenamePrompt(m_House);
                    from.SendLocalizedMessage(501302);                       // What dost thou wish the sign to say?
                }
                else
                {
                    from.SendLocalizedMessage(501307);                               // Only the house owner may do this.
                }

                break;
            }

            case 2:                     // List of co-owners
            {
                from.SendGump(new StaticHouseListGump(1011275, m_House.CoOwners, m_House));

                break;
            }

            case 3:                     // Add co-owner
            {
                if (isOwner)
                {
                    from.Target = new StaticCoOwnerTarget(true, m_House);
                    from.SendLocalizedMessage(501328);                               // Target the person you wish to name a co-owner of your household.
                }
                else
                {
                    from.SendLocalizedMessage(501327);                               // Only the house owner may add Co-owners.
                }

                break;
            }

            case 4:                     // Remove co-owner
            {
                if (isOwner)
                {
                    from.SendGump(new StaticHouseRemoveGump(1011274, m_House.CoOwners, m_House));
                }
                else
                {
                    from.SendLocalizedMessage(501329);                               // Only the house owner may remove co-owners.
                }

                break;
            }

            case 5:                     // Clear co-owners
            {
                if (isOwner)
                {
                    if (m_House.CoOwners != null)
                    {
                        m_House.CoOwners.Clear();
                    }

                    from.SendLocalizedMessage(501333);                               // All co-owners have been removed from this house.
                }
                else
                {
                    from.SendLocalizedMessage(501330);                               // Only the house owner may remove co-owners.
                }

                break;
            }

            case 6:                     // List friends
            {
                from.SendGump(new StaticHouseListGump(1011273, m_House.Friends, m_House));

                break;
            }

            case 7:                     // Add friend
            {
                if (isCoOwner)
                {
                    from.Target = new StaticHouseFriendTarget(true, m_House);
                    from.SendLocalizedMessage(501317);                               // Target the person you wish to name a friend of your household.
                }
                else
                {
                    from.SendLocalizedMessage(501316);                               // Only the house owner may add friends.
                }

                break;
            }

            case 8:                     // Remove friend
            {
                if (isCoOwner)
                {
                    from.SendGump(new StaticHouseRemoveGump(1011272, m_House.Friends, m_House));
                }
                else
                {
                    from.SendLocalizedMessage(501318);                               // Only the house owner may remove friends.
                }

                break;
            }

            case 9:                     // Clear friends
            {
                if (isCoOwner)
                {
                    if (m_House.Friends != null)
                    {
                        m_House.Friends.Clear();
                    }

                    from.SendLocalizedMessage(501332);                               // All friends have been removed from this house.
                }
                else
                {
                    from.SendLocalizedMessage(501319);                               // Only the house owner may remove friends.
                }

                break;
            }

            case 10:                     // Ban
            {
                from.Target = new StaticHouseBanTarget(true, m_House);
                from.SendLocalizedMessage(501325);                           // Target the individual to ban from this house.

                break;
            }

            case 11:                     // Eject
            {
                from.Target = new StaticHouseKickTarget(m_House);
                from.SendLocalizedMessage(501326);                           // Target the individual to eject from this house.

                break;
            }

            case 12:                     // List bans
            {
                from.SendGump(new StaticHouseListGump(1011271, m_House.Bans, m_House));

                break;
            }

            case 13:                     // Remove ban
            {
                from.SendGump(new StaticHouseRemoveGump(1011269, m_House.Bans, m_House));

                break;
            }

            case 14:                     // Transfer ownership
            {
                if (isOwner)
                {
                    from.Target = new StaticHouseOwnerTarget(m_House);
                    from.SendLocalizedMessage(501309);                               // Target the person to whom you wish to give this house.
                }
                else
                {
                    from.SendLocalizedMessage(501310);                               // Only the house owner may do this.
                }

                break;
            }

            case 15:                     // Demolish house
            {
                if (isOwner)
                {
                    m_House.Delete();
                }
                else
                {
                    from.SendLocalizedMessage(501320);                               // Only the house owner may do this.
                }
                break;
            }

            case 16:     // Change locks
            {
                if (m_House.Public)
                {
                    from.SendLocalizedMessage(501669);              // Public houses are always unlocked.
                }
                else
                {
                    if (isOwner)
                    {
                        m_House.RemoveKeys(from);
                        m_House.ChangeLocks(from);

                        from.SendLocalizedMessage(501306);                   // The locks on your front door have been changed, and new master keys have been placed in your bank and your backpack.
                    }
                    else
                    {
                        from.SendLocalizedMessage(501303);                   // Only the house owner may change the house locks.
                    }
                }

                break;
            }

            case 17:                     // Declare public
            {
                if (isOwner)
                {
                    if (m_House.Public && m_House.FindPlayerVendor() != null)
                    {
                        from.SendLocalizedMessage(501887);                                   // You have vendors working out of this building. It cannot be declared private until there are no vendors in place.
                        break;
                    }

                    m_House.Public = !m_House.Public;
                    if (!m_House.Public)
                    {
                        m_House.ChangeLocks(from);

                        from.SendLocalizedMessage(501888);                                   // This house is now private.
                        from.SendLocalizedMessage(501306);                                   // The locks on your front door have been changed, and new master keys have been placed in your bank and your backpack.
                    }
                    else
                    {
                        m_House.RemoveKeys(from);
                        m_House.RemoveLocks();
                        from.SendLocalizedMessage(501886);                                  //This house is now public. Friends of the house my now have vendors working out of this building.
                    }
                }
                else
                {
                    from.SendLocalizedMessage(501307);                               // Only the house owner may do this.
                }

                break;
            }

            case 19:                     // Set the house's boundries
            {
                m_House.CreateYard(from);
                break;
            }

            case 20:                     // Creates the house Region and sets the initial values you should set yard first!
            {
                m_House.InitializeHouse(from);
                break;
            }

            case 21:                     // Add a Door to the door array this allows it to be rekeyed
            {
                m_House.addDoor(from);
                break;
            }

            case 22:                     // Set the Max Number of LockDowns
            {
                from.Prompt = new StaticSetLockDownsPrompt(m_House);
                from.SendMessage("Enter the number of lockdowns this house will have:");
                break;
            }

            case 23:                     // Set the Max Secures Amount
            {
                from.Prompt = new StaticSetSecurePrompt(m_House);
                from.SendMessage("Enter the number of secures this house will have:");
                break;
            }

            case 24:                     // Reset this House
            {
                Region.RemoveRegion(m_House.m_Region);

                if (m_House.m_LockDowns != null)
                {
                    for (int i = 0; i < m_House.m_LockDowns.Count; ++i)
                    {
                        Item item = (Item)m_House.m_LockDowns[i];

                        if (item != null)
                        {
                            item.Movable = true;
                        }
                    }
                }
                if (m_House.m_Secures != null)
                {
                    for (int i = 0; i < m_House.m_Secures.Count; ++i)
                    {
                        Item item = (Item)m_House.m_Secures[i];

                        if (item != null)
                        {
                            item.Movable = true;
                        }
                    }
                }

                m_House.houseBoundries   = new ArrayList();
                m_House.m_Owner          = null;
                m_House.m_OrgOwner       = null;
                m_House.Name             = "a house sign";
                m_House.Movable          = false;
                m_House.m_Region         = new StaticHouseRegion(m_House);
                m_House.m_Region.Coords  = new ArrayList();
                m_House.m_Sign           = m_House;
                m_House.m_Doors          = new ArrayList();
                m_House.m_LockDowns      = new ArrayList();
                m_House.m_Secures        = new ArrayList();
                m_House.m_CoOwners       = new ArrayList();
                m_House.m_Friends        = new ArrayList();
                m_House.m_Bans           = new ArrayList();
                m_House.m_Access         = new ArrayList();
                m_House.m_Addons         = new ArrayList();
                m_House.owner            = null;
                m_House.m_Price          = 0;
                m_House.forSale          = false;
                m_House.m_Public         = true;
                m_House.houseSetUp       = false;
                m_House.houseInitialized = false;
                m_House.m_BanLocation.X  = 0;
                m_House.m_BanLocation.Y  = 0;
                m_House.m_BanLocation.Z  = 0;

                from.SendMessage("This house has been reset");
                break;
            }

            case 25:                     // Set the Banning Location
            {
                from.Target = new BanLocationTarget(m_House);
                from.SendMessage("Ban Location is now set!");
                break;
            }

            case 26:                     // Grant Access rights
            {
                from.Target = new StaticHouseAccessTarget(m_House);
                break;
            }

            case 27:                     // Remove Access rights
            {
                from.SendGump(new StaticHouseRemoveGump(1060677, m_House.CanAccess, m_House));
                break;
            }

            case 28:                      // View Access List
            {
                from.SendGump(new StaticHouseListGump(1060677, m_House.CanAccess, m_House));
                break;
            }

            case 29:                      // Wipe Access List
            {
                if (isCoOwner)
                {
                    if (m_House.CanAccess != null)
                    {
                        m_House.CanAccess.Clear();
                    }

                    from.SendMessage("The Access List is Wiped");                               // All friends have been removed from this house.
                }
                else
                {
                    from.SendLocalizedMessage(501319);                               // Only the house owner may remove friends.
                }

                break;
            }

            case 30:                     // Change type
            {
                if (info.Switches.Length > 0)
                {
                    int index = info.Switches[0] - 1;

                    if (index >= 0 && index < 53)
                    {
                        m_House.StaticChangeSignType(2980 + (index * 2));
                    }
                }

                break;
            }
            }
        }