Hi all. I'm very new to MQ2 and have never coded before so, yes, this is most likely a stupid question but I have searched and navigated for hours on these forums without finding what I need. I'm trying to get the auto-tradeskill macros to work. I understand that with the changes to the merchant window some new code needs to be used as well as the buy.mac. Specifically,
Code: Select all
/notify MerchantWnd MW_ItemList ${Window[MerchantWnd].Child[ItemList].List[=${Name},2]}
Code: Select all
|
| buy.mac
| /macro buy <name>
|
sub main(string Name)
/declare l2 local int
/varset l2 ${Window[MerchantWnd].Child[ItemList].List[=${Name},2]}
/if (!${l2}) {
/echo couldn't find slot for ${Name}
/endm
} else {
/notify MerchantWnd ItemList listselect ${l2}
/delay 2
/notify MerchantWnd ItemList leftmouse ${l2}
/delay 4
}
/if (!${Window[MerchantWnd].Child[MW_SelectedItemLabel].Text.Equal[${Name}]}) {
/echo bad select
/beep
/beep
/beep
/endm
}
/delay 5
/shift /notify MerchantWnd MW_Buy_Button leftmouseup
/return
Code: Select all
|
| buy.inc
| Buy Include File needed for macros
| Version 1.7
| Date: September 13, 2004
|
| 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#*#"
Sub Buy(item ItemToBuy, int amount)
/echo Buying ${ItemToBuy}!
/declare TotalMItems int Inner
/varset TotalMItems ${Merchant.Items}
/declare x int Inner
/declare ItemSlotNum int Inner
/varset ItemSlotNum 0
/for x 1 to ${TotalMItems}
/if (${ItemToBuy.Equal[${Merchant.Item[${x}]}]}) {
/varset ItemSlotNum ${x}
}
/next x
/if (${ItemSlotNum}==0) {
/echo Not on Merchant
/return
}
/itemnotify merchant${ItemSlotNum} leftmouseup
/delay 1s
:Buy
/if (${FindItemCount[=${SelectedItem}]}>=${amount}) {
/echo Done!
/return
}
:StackLoop
/if (${Math.Calc[${amount}-${FindItemCount[=${SelectedItem}]}]}<=20) /goto :RegLoop
/buyitem ${If[${SelectedItem.Stackable},20,1]}
/delay 5
/doevents
/goto :StackLoop
:RegLoop
/if (${Math.Calc[${amount}-${FindItemCount[=${SelectedItem}]}]}<=0) {
/echo Done!
/return
}
/buyitem ${If[${SelectedItem.Stackable},${Math.Calc[${amount}-${FindItemCount[=${SelectedItem}]}]},1]}
/delay 5
/doevents
/goto :RegLoop
/return
Sub PCBuy(item ItemToBuy, int amount)
/declare TotalMItems int Inner
/varset TotalMItems ${Merchant.Items}
/declare x int Inner
/declare ItemSlotNum int Inner
/varset ItemSlotNum 0
/delay 2s
:BuyPC
/varset ItemSlotNum 0
/if (${amount}<=0) {
/echo Done!
/return
}
/for x 1 to ${TotalMItems}
/if (${ItemToBuy.Equal[${Merchant.Item[${x}]}]}) {
/varset ItemSlotNum ${x}
}
/next x
/if (${ItemSlotNum}==0) {
/echo No More on Merchant, done buying.
/return
}
/itemnotify merchant${ItemSlotNum} leftmouseup
/delay 1s
/if (${SelectedItem.Stackable}) {
/if (${amount}>=20) {
/buyitem 20
/varset amount ${Math.Calc[${amount}-20]}
} else {
/buyitem ${amount}
/varset amount ${Math.Calc[${amount}-${amount}]}
}
} else {
/buyitem 1
/varset amount ${Math.Calc[${amount}-1]}
}
/delay 5
/doevents
/goto :BuyPC
/return
Sub Event_Broke
/echo Error: You are out of money!
/beep
/endmacro
/return



