Not sure what is wrong here...

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Not sure what is wrong here...

Post by wassup » Sun Oct 12, 2003 6:38 pm

If I run this macro 2 times, it works, but when I run it 3 times, I CTD. Can anyone spot anything that might be causing this? Or is there a problem with MQ I don't know about?

Code: Select all

|Character bought something event
#event ItemsBought "You give"

|Expects "merchant name" and "item name" to be passed in
Sub Main
   /declare Selected global
   /varset Selected 0

   |Buy Item
   |Param0 is MerchantName Param1 is item
   /call BuyItem "@Param0" "@Param1"
/return

|Expects two parameters to be passed
|Buys 20 of a stackable <itemname>;
Sub BuyItem
   
   |Target the merchant
   :RetargetMerchant
   /target npc "@Param0"
   /if "$target(name,clean)"!="@Param0" /goto :RetargetMerchant
   
   |Open the merchant   
   :RightClickVendor
   /rclicktarget
   /if $merchant==FALSE /goto :RightClickVendor

   |Select the item from the vendor
   /delay 5
   :WaitForSelection
   /selectitem "@Param1" merchant
   /delay 5
   /if $selecteditem!=@Param1 /goto :WaitForSelection

   /varset Selected 0
   |Buy items
   :Buying
   /buyitem 20
   /delay 5
   
   /doevents ItemsBought
   /delay 3
   /if n @Selected==0 /goto :Buying

   /click left merchant done
   /doevents flush

/return

Sub Event_ItemsBought
   /varset Selected 1
/return

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Sun Oct 12, 2003 8:01 pm

/rclicktarget is new.

if you replace
/rclicktarget
with
/face
/press u

does it still crash?

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Sun Oct 12, 2003 8:09 pm

It's not that, I placed some /mqlogs through the macro, and it seems to be something with /selectitem.

Valerian
a grimling bloodguard
a grimling bloodguard
Posts: 709
Joined: Sun Jul 28, 2002 3:29 am

Post by Valerian » Mon Oct 13, 2003 11:11 pm

check $selecteditem or use events to make sure the merchant window is open AND ready before using /selectitem.