Deleting mailbox items
I'm working on a mod to take money from certain Inbox items, then delete the items. I'm running up against a problem that I imagine has been solved several times before.
The job is to step through the Inbox items, recognize certain special ones, take the money and then delete the item, all without the user doing more than opening the mailbox. My code will succeed at doing that for one or two mails, and then stop.
When I take the inbox money I call TakeInboxMoney() and then wait for the PLAYER_MONEY event. Then I call DeleteInboxItem() on the same mail, and wait for MAIL_INBOX_UPDATE, and check to see whether the item count has changed. Sometimes the money never gets taken, sometimes the item never gets deleted. I'm convinced the code is doing what I intend it to be doing; the problem seems to be the events never fire.
Am I taking the wrong approach here? Should I be watching some other event(s)?
|