Hello,
I would prevent players from opening a vendor's buy or sell panel if another player's already buying or selling from the same NPC... which file/function I've to edit?

Thank You in advance!
 
You would probably have to new field in BaseVendor.cs. (take the big file one)
Code:
private bool m_inUse;
public bool InUse { get { return m_inUse; } set { m_inUse = value; } }
You don't have to serialize it, since you want it to reset on startup anyways.

For the access to buy, see:
VendorBuy(Mobile from)

and betwwen the 2 ifs:
Code:
            if (!CheckVendorAccess(from))
            {
                Say(501522); // I shall not treat with scum like thee!
                return;
            }

            if (DateTime.UtcNow - m_LastRestock > RestockDelay)
            {
                Restock();
            }

Add this:
Code:
            if (m_inUse)
            {
                Say("I'm busy, go shop somewhere else.");
                return;
            }

For the sell, go in:
public virtual void VendorSell(Mobile from)

Between those two things:
Code:
            if (!CheckVendorAccess(from))
            {
                Say(501522); // I shall not treat with scum like thee!
                return;
            }

            Container pack = from.Backpack;

Add this:
Code:
            if (m_inUse)
            {
                Say("I'm busy, go sell your stuff somewhere else.");
                return;
            }

Tell me if this works as expected.
Also mind about bulk orders, and skill training if you plan on keeping your vendors busy :p
 
Yes, it should work, but if i put the m_inUse = true Just After these new ifs.. where do I have to write the m_inUse = false?
I presume this bool should be reset after a successfully completed buy/sell action and when a player simply closes the buy/sell gumps wihout buying or selling anything (mouse right click).
Right?
[doublepost=1479221002][/doublepost]I tried adding this PacketHandler inside the BaseVendor.cs, but nothing happens and the boolean doesn't reset after trading or if panel closes

Code:
        #region busyVendor
        private bool m_isBusy = false;
        public bool IsBusy { get { return m_isBusy; } set { m_isBusy = value; } }

        public static void Initialize()
        {
            PacketHandlers.Register( 0x3B, 0, true, new OnPacketReceive( OnCloseVendorGumps ) );
        }

        private static void OnCloseVendorGumps( NetState state, PacketReader pvSrc )
        {         
            Serial serial = pvSrc.ReadInt32();
            Mobile vendor = World.FindMobile( serial );

            if ( vendor == null )
            {
                return;
            }
            else
            {
                ((BaseVendor)vendor).IsBusy = false;
                return;
            }
        }
        #endregion
 
Last edited:
Yes, you're right.
I managed to reset the IsBusy boolean via PacketHandlers.Register() in case of players finish trading with the vendor (correctly).
I can't figure out how to manage the right-click closing action over buy/sell gumps (Any ideas?) so I've just added an IsBusyTimer( 30 seconds ) which starts when a player opens the buy/sell gump and resets the IsBusy boolean after 30 secs, even if the trade's not finished yet (in this way the AFK issue should be solved).

The optimum should be manage the "right-click" and the "move far off the vendor" closing actions properly and increase the IsBusyTimer() to 60-120 seconds, just to prevent the AFK issue.
 
Last edited:
Back