Server.Mobiles.BaseVendor.VendorSell C# (CSharp) Méthode

VendorSell() public méthode

public VendorSell ( Mobile from ) : void
from Mobile
Résultat void
        public virtual void VendorSell( Mobile from )
        {
            if ( !IsActiveBuyer )
                return;

            if ( !from.CheckAlive() )
                return;

            if ( !CheckVendorAccess( from ) )
            {
                Say( 501522 ); // I shall not treat with scum like thee!
                return;
            }

            Container pack = from.Backpack;

            if ( pack != null )
            {
                IShopSellInfo[] info = GetSellInfo();

                Dictionary<Item, SellItemState> table = new Dictionary<Item, SellItemState>();

                foreach ( IShopSellInfo ssi in info )
                {
                    Item[] items = pack.FindItemsByType( ssi.Types );

                    foreach ( Item item in items )
                    {
                        if ( item is Container && ( (Container)item ).Items.Count != 0 )
                            continue;

                        if ( item.IsStandardLoot() && item.Movable && ssi.IsSellable( item ) )
                            table[item] = new SellItemState( item, ssi.GetSellPriceFor( item ), ssi.GetNameFor( item ) );
                    }
                }

                if ( table.Count > 0 )
                {
                    SendPacksTo( from );

                    from.Send( new VendorSellList( this, table.Values ) );
                }
                else
                {
                    Say( true, "You have nothing I would be interested in." );
                }
            }
        }

Usage Example

Exemple #1
0
        // Temporary
        public override void OnSpeech(SpeechEventArgs e)
        {
            base.OnSpeech(e);

            Mobile from = e.Mobile;

            BaseVendor vendor = m_Mobile as BaseVendor;

            if (m_Mobile is BaseVendor && from.InRange(m_Mobile, m_Mobile.EraAOS ? 1 : 4) && !e.Handled)
            {
                if (e.HasKeyword(0x14D))                     // *vendor sell*
                {
                    e.Handled = true;

                    vendor.VendorSell(from);
                    m_Mobile.FocusMob = from;
                }
                else if (e.HasKeyword(0x3C))
                {
                    e.Handled = true;

                    vendor.VendorBuy(from);
                    m_Mobile.FocusMob = from;
                }
                else if (WasNamed(e.Speech))
                {
                    e.Handled = true;

                    if (e.HasKeyword(0x177))                         // *sell*
                    {
                        vendor.VendorSell(from);
                    }
                    else if (e.HasKeyword(0x171))                         // *buy*
                    {
                        vendor.VendorBuy(from);
                    }

                    m_Mobile.FocusMob = from;
                }
            }
        }