I took out the longer delays and added a event + wait loop to wait until you've bought the item, so it's much much faster
Code:
|Updated by Unity0110 for faster than ever speeds!
|
| buy.inc
| Buy Include File needed for macros
| Version 1.7b
|
| Date: August 20, 2005
| UPDATED BY OUNVME
|
| 14 MAR 2006: Armysoldier refined code to improve speed
|
| Please be sure to get the lastest updates at http://www.soc-music.com/mq2
|
| These file MUST be in the common directory in your macros directory.
|
| Usage: /call Buy (ItemToBuy) (Amount Needed)
|
| Use the Buy function for buying if you need a set total amount, like if you have
| 20 of the item on you already and you need a total of 30, it will only buy 10
| of the item.
|
| Usage: /call PCBuy (ItemToBuy) (Amount to buy off merchant)
|
| Use the PCBuy function if you don't need a set total amount, you just need
| a set amount off that merchant.
|
| Disclaimer:
| Code was used from other programers also from the MQ Forums.
|
#event Broke "#*#you cannot afford#*#"
#event Broke "#*#you can't afford#*#"
#event give "You give #*# to #*#."
Sub Buy(Item ItemToBuy, int amount)
/echo Buying ${ItemToBuy}!
/declare QTY int Inner
/declare l2 local int
/declare readyToBuy bool local 1
|---SMALL delay to allow the MERCHANT Window to populate
/delay ${Math.Calc[${DelayMult}*2]}s
/varset QTY ${Math.Calc[${amount}-${FindItemCount[${ItemToBuy}]}]}
/delay 5
/if (${FindItemCount[${ItemToBuy}]}>= ${amount}) {
/echo Done!
/return
}
/varset l2 ${Window[MerchantWnd].Child[ItemList].List[=${ItemToBuy},2]}
/if (!${l2}) {
/echo couldn't find ${ItemToBuy}
/endmacro
} else {
/notify MerchantWnd ItemList listselect ${l2}
/notify MerchantWnd ItemList leftmouse ${l2}
/delay 2
}
/echo Buying ${ItemToBuy} Till I get ${amount}
:buyLoop
/if (${QTY}>19) {
/buyitem 20
/varset QTY ${Math.Calc[${amount}-${FindItemCount[${ItemToBuy}]}]}
/call waitToBuy
/goto :buyLoop
} ELSE {
/if (${QTY}>0 && ${QTY}<20) {
/buyitem ${QTY}
/varset QTY ${Math.Calc[${amount}-${FindItemCount[${ItemToBuy}]}]}
/call waitToBuy
}
}
/if (${QTY}==0) {
/return
}
/goto :buyLoop
/return
sub waitToBuy
/if (${QTY}==0) /return
/varset readyToBuy 0
:waitToBuyLoop
/doevents
/if (!${readyToBuy}) {
/delay 1
/goto :waitToBuyLoop
}
/return
sub Event_give
/if (${QTY}==0) /return
/varset readyToBuy 1
/return
Sub Event_Broke
/echo Error: You are out of money!
/endmacro
/return