Advertisement
sorvani

buy.inc

Apr 11th, 2012
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. |
  2. | buy.inc
  3. | Buy Include File needed for macros
  4. | Version 1.7b
  5. |
  6. | Date: August 20, 2005
  7. | UPDATED BY OUNVME
  8. |
  9. | 14 MAR 2006: Armysoldier refined code to improve speed
  10. |
  11. | Please be sure to get the lastest updates at http://www.soc-music.com/mq2
  12. |
  13. | These file MUST be in the common directory in your macros directory.
  14. |
  15. | Usage: /call Buy (ItemToBuy) (Amount Needed)
  16. |
  17. | Use the Buy function for buying if you need a set total amount, like if you have
  18. | 20 of the item on you already and you need a total of 30, it will only buy 10
  19. | of the item.
  20. |
  21. | Usage: /call PCBuy (ItemToBuy) (Amount to buy off merchant)
  22. |
  23. | Use the PCBuy function if you don't need a set total amount, you just need
  24. | a set amount off that merchant.
  25. |
  26. | Disclaimer:
  27. | Code was used from other programers also from the MQ Forums.
  28. |
  29.  
  30.  
  31. #event Broke "#*#you cannot afford#*#"
  32. #event Broke "#*#you can't afford#*#"
  33.  
  34. Sub Buy(string ItemToBuy, int amount)
  35. /echo Buying ${amount} ${ItemToBuy}(s)!
  36. /declare QTY int local ${Math.Calc[${amount}-${FindItemCount[${ItemToBuy}]}]}
  37. /declare l2 int local
  38. /delay 5s ${Window[MerchantWnd].Child[ItemList].List[=${ItemToBuy},2]}
  39. /if (${FindItemCount[${ItemToBuy}]}>= ${amount}) {
  40. /echo ${amount} ${ItemToBuy} already in inventory.
  41. /return
  42. }
  43. /varset l2 ${Window[MerchantWnd].Child[ItemList].List[=${ItemToBuy},2]}
  44. /if (!${l2}) {
  45. /echo couldn't find ${ItemToBuy}
  46. /endmacro
  47. } else {
  48. /notify MerchantWnd ItemList listselect ${l2}
  49. /notify MerchantWnd ItemList leftmouse ${l2}
  50. /delay 2
  51. }
  52.  
  53. /echo Buying ${ItemToBuy} Till I get ${amount}
  54. :Loop
  55. /if (${QTY}>19 && ${FindItem[=${ItemToBuy}].Stackable} && ${FindItem[=${ItemToBuy}].StackSize}<=${amount} ) {
  56. /nomodkey /shiftkey /notify MerchantWnd MW_Buy_Button leftmouseup
  57. } else {
  58. /nomodkey /ctrlkey /notify MerchantWnd MW_Buy_Button leftmouseup
  59. }
  60. /delay 5
  61. /doevents
  62. /varset QTY ${Math.Calc[${amount}-${FindItemCount[${ItemToBuy}]}]}
  63.  
  64. /if (${QTY}<=0) /return
  65.  
  66. /goto :Loop
  67. /return
  68.  
  69. Sub Event_Broke
  70. /echo Error: You are out of money!
  71. /beep
  72. /endmacro
  73. /return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement