Would need help on this buy.mac i made.. thanks!

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

User avatar
Clone39
a ghoul
a ghoul
Posts: 91
Joined: Mon Jul 07, 2003 7:26 pm
Location: Montreal, Canada

Would need help on this buy.mac i made.. thanks!

Post by Clone39 » Mon Dec 08, 2003 1:05 pm

Hi there,

I know there's a lot of buy item macros out there, but i wanted to make one by myself to see if i really understand all this scripting stuff. In other words.. to learn how to do it.

If anyone of you guys could point me out where i made mistake, it would be appreciated. Thanks

Problem i have at the moment is with the "/varset howmany" command. It won't set the var and return me an error.

Code: Select all

| Buyitem.mac
| By Clone39 (this is my first one)
| 
| Usage: /macro buyitem "how many to buy" "thing you want to buy"
| 12/08/03

#event FullInventory "There was no place to put that"

/declare howmany local
/declare buycount local

/varset howmany 0
/varset buycount 0

Sub Main
   /varset howmany $int(@Param1)
   /if n @howmany>@buycount {
   :Buy
   /selectitem "@Param2" merchant
   /buyitem "@Param1"
   /varadd buycount 1
   /doevents
   /goto :Buy
   } else {
   /endmacro
   }
/return

Sub Event_FullInventory
   /echo Your inventory is full, ending macro.
   /endmacro
/return
Thanks in advance for you help

Clone39

nimblefoot
a lesser mummy
a lesser mummy
Posts: 33
Joined: Sun Jun 29, 2003 11:50 am

Post by nimblefoot » Mon Dec 08, 2003 1:51 pm

You can't declare a local variable outside of a function to my knowledge. =)

User avatar
Clone39
a ghoul
a ghoul
Posts: 91
Joined: Mon Jul 07, 2003 7:26 pm
Location: Montreal, Canada

Post by Clone39 » Mon Dec 08, 2003 5:00 pm

nimblefoot wrote:You can't declare a local variable outside of a function to my knowledge. =)
doh.. think you're right.. thanks!!

EqMule
Developer
Developer
Posts: 2697
Joined: Fri Jan 03, 2003 9:57 pm
Contact:

Post by EqMule » Mon Dec 08, 2003 5:51 pm

and careful with having no kind of check if there actually has been a selection before you issue a /buyitem... you either put in a /delay or use $selecteditem() to check that everything is fine, or you will easily make the client crash you... or even worse, send multiple requests to the server which are not valid... I mean it takes /selectitem a few milliseconds to do its thing... same for buyitem, make sure you let it do its thing, compare $char(cash) before and after or something like that... I know you wanna have a small macro, but its not safe...
My status o/
If you like MQ2 and would like to contribute, please do. My goal is 25 donations per month.
So far I've received Image donations for this month's patches.

Bitcoin: 1Aq8ackjQ4f7AUvbUL7BE6oPfT8PmNP4Zq
Krono: PM me.
I can always use characters for testing, PM me if you can donate one.