What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

[Dev] Opening Mailbox Locks Wow

Narayan

Member
Joined
Oct 26, 2010
Messages
405
Reaction score
2
I'm trying to open a mailbox and get all mail via a plugin however the code im using locks the wow screen until I stop the plugin manually. Does anyone have any suggestions?

PHP:
WoWGameObject mailbox =
                ObjectManager.GetObjectsOfType<WoWGameObject>().Where(o => o.SubType == WoWGameObjectType.Mailbox)
                    .OrderBy(o => o.Distance).FirstOrDefault();
            if (mailbox != null)
            {
                // Interact
                Logging.Write("MILLER: Mailbox found, interacting");
                mailbox.Interact();
            }
            else
            {
                Logging.Write("MILLER: Mailbox not found");
            }
            using (new FrameLock())
            {
                // Open Mail
                Logging.Write("MILLER: Opening All Mail");
                MailFrame.Instance.OpenAllMail();
                Logging.Write("MILLER: Done opening mail");
            }
 
Try not locking the frame while it opens all mail.
 
This is from my AH bot, it empties the whole mailbox it's meant to be used in a bt but i'm sure you can port it if you want.

Code:
        private long _totalCoppers;
        private int index;
        private RunStatus GetMailboxItems(object context)
        {
            MailFrame frame = MailFrame.Instance;
            index++;

            long mailMoney = Lua.GetReturnVal<long>("return GetInboxHeaderInfo(" + index + ")", 4);
            int numMailItems = Lua.GetReturnVal<int>("return GetInboxHeaderInfo(" + index + ")", 7);
            _totalCoppers += mailMoney;

            if (Me.FreeNormalBagSlots > numMailItems)
            {
                if (index > frame.MailCount)
                    index = 1;

                Lua.DoString("AutoLootMailItem({0})", index);
                Thread.Sleep(200);

                if ((long)Me.Copper < (long)Me.Copper + mailMoney)
                {
                    return RunStatus.Running;
                }

                if (Me.FreeNormalBagSlots > 1 && frame.MailCount > 0)
                {
                    return RunStatus.Running;
                }
            }

            if (frame.HasNewMail && Me.FreeNormalBagSlots > 1)
            {
                return RunStatus.Running;
            }

            var totalMailboxProfit = new WoWPrice(_totalCoppers);
            _totalCoppers = 0;
            index = 0;
            Logger.Write("Looted {0} from mailbox", totalMailboxProfit);
            return RunStatus.Success;
        }
 
*duh* So what's the use of a frame lock then?
If you need to do a lot of injections. The dead lock occurs because OpenAllMail waits for the server to respond and the client to handle the mail being opened. When you use a frame lock you lock WoW so it will not handle the mail being taken out.
 
Back
Top