Macro to buy item and sell it

shakman

New member
Joined
May 28, 2011
Messages
28
Reaction score
0
Points
1
Looking for a Macro to buy an item from a vendor then sell it back. I thought I had seen one before, but can't seem to find one. Any help finding it or writing one would be appreciated. Thanks.
 
Looking for a Macro to buy an item from a vendor then sell it back. I thought I had seen one before, but can't seem to find one. Any help finding it or writing one would be appreciated. Thanks.

I feel like I'm reading this wrong....perhaps you said it wrong....perhaps there is an item you can buy and then sell right back to the vendor for profit and I'm just unaware of it.

Are you saying you want to Buy an item from a vendor, then sell it right back to the vendor?
 
Could just be a tradeskill macro he's working on.

And that is where I'd look for one. I think AdvNinjaLoot also has some code to deal with selling.

If no one else figures it out I'll go digging.
 
Last edited:
Here are my buy and sell macs.

Buy

Code:
| Usage:
| target the vendor
| /mac buystuff "water flask" 100

#include ninjadvloot.inc

sub main

/declare StuffToBuy string outer
/declare AmountToBuy int outer

    /if (${Defined[Param0]}) {
        /varset StuffToBuy ${Param0} 
    }
    /if (${Defined[Param1]}) {
        /varset AmountToBuy ${Param1} 
    } 
    
/call SetupAdvLootVars
        /call npc "${Taget.CleanName}"
        /call Buy "${StuffToBuy}" ${AmountToBuy}
/return


Sell

Code:
Sub Main 
  /if (!${Window[MerchantWnd].Open}) {
    /echo You need to have a merchant window open!
    /end
  }
  /if (!${Defined[Param0]}) {
    /echo Proper usage: /macro sellitem ItemName
    /end
  }
  /declare OldMoney int Inner    
  /call ClearCursor
  /if (${Param0.Equal[NULL]})  /return
  /delay 2s
  :Finding 
  /if (${FindItemCount[=${Param0}]}) { 
    /nomodkey /itemnotify ${FindItem[=${Param0}].InvSlot} leftmouseup 
    /delay 5 ${SelectedItem.ID}==${FindItem[=${Param0}].ID}
    /if (${SelectedItem.ID}==${FindItem[=${Param0}].ID}) {
      /delay 1s
      /varset OldMoney ${Me.Cash} 
      /nomodkey /shift /notify MerchantWnd MW_Sell_Button leftmouseup 
      /delay 2s (${Me.Cash}!=${OldMoney})
    }
    /goto :Finding 
  }
  /echo No more ${Param0} to sell!!!      
  /return 

Sub ClearCursor 
  /declare x int local 
  :auto_inv 
  /if (${Cursor.ID}) { 
    /if (${Cursor.Container}) { 
      /for x 1 to 8
        /if (!${InvSlot[pack${x}].Item.Container}) /nomodkey /itemnotify pack${x} leftmouseup 
      /next x 
    } else { 
      /timed 5 /autoinventory 
    } 
    /goto :auto_inv 
  } 
  /return
 

Attachments

  • Buystuff.mac
    465 bytes · Views: 10
  • Sellstuff.mac
    1.1 KB · Views: 21
Last edited:
Yes looking for a mac to buy and sell an item back over and over for profit. This isn't on live servers, but on an eqemu server. Thanks for the help!
 
Yes looking for a mac to buy and sell an item back over and over for profit. This isn't on live servers, but on an eqemu server. Thanks for the help!

EQEmu tends to use different files than a live server does. Go to your Everquest directory where the UI files are stored and right click the folder then on the "send to" option select zip file then upload them here if those previously provided macros don't work. Alternately I really only need the UI file for the merchant window and inventory tbh if you know how to track specific windows down.

Since the previously provided macros depend on UI Files on what I presume is live EQ, then it is possible that the UI files have different members for the windows. Then I suppose you want it to run on a loop, which the previously mentioned setup does not. But could be altered to do so for you if it does in fact work. But first I need to know if it works or not. Something like this doesn't sound overly complicated to accomplish, just a matter of checking for the merchant window to be open, finding the item (if it is present) and then buying the item, then finding it in your inventory, clicking it, then hitting the sell button and repeating the process.

Of course you would want to select a vendor with limited stock as items sometimes end up in a vendors pocket if their inventory is full (believe they only show the top 30 items available) which would cause this to function incorrectly.
 
While I'm not saying I know everything there is to know about Macro's, I've written a few lines of code. But there is always more to learn. Shouldn't the parameters be included as part of the sub main? IE:

Code:
Sub main(param0, param1)
    /declare StuffToBuy string outer
    /declare AmountToBuy int outer

    /if (${Defined[Param0]}) {
        /varset StuffToBuy ${Param0} 
    }
    /if (${Defined[Param1]}) {
        /varset AmountToBuy ${Param1} 
    } 
    
    /call SetupAdvLootVars
    /call npc "${Taget.CleanName}"
    /call Buy "${StuffToBuy}" ${AmountToBuy}
/return

Additionally, based on the changes I've posted in the past. Now all paramaters are automatically considered "defined" even if they weren't supplied. IE: /mac buy
While I didn't supply any parameters they are still technically "defined" as they are automatically defined when the sub is called. Thus I've opted to instead use a boolean wrapper to check for it to have some information inside of the parameter.


Code:
/if (${Defined[Param0]}) {
    /if (${Bool[Param0]}) {
        /dothatthingIwanted
    } else {
        /cechob "No parameters were supplied, usage: /mac buy thingtosell priceMinium"
    }
}

I may be wrong about the parameters needing to be part of the Sub. I'm not really sure as I've never tried it the other way.


Here are my buy and sell macs.

Buy

Code:
| Usage:
| target the vendor
| /mac buystuff "water flask" 100

#include ninjadvloot.inc

sub main

/declare StuffToBuy string outer
/declare AmountToBuy int outer

    /if (${Defined[Param0]}) {
        /varset StuffToBuy ${Param0} 
    }
    /if (${Defined[Param1]}) {
        /varset AmountToBuy ${Param1} 
    } 
    
/call SetupAdvLootVars
        /call npc "${Taget.CleanName}"
        /call Buy "${StuffToBuy}" ${AmountToBuy}
/return


Sell

Code:
Sub Main 
  /if (!${Window[MerchantWnd].Open}) {
    /echo You need to have a merchant window open!
    /end
  }
  /if (!${Defined[Param0]}) {
    /echo Proper usage: /macro sellitem ItemName
    /end
  }
  /declare OldMoney int Inner    
  /call ClearCursor
  /if (${Param0.Equal[NULL]})  /return
  /delay 2s
  :Finding 
  /if (${FindItemCount[=${Param0}]}) { 
    /nomodkey /itemnotify ${FindItem[=${Param0}].InvSlot} leftmouseup 
    /delay 5 ${SelectedItem.ID}==${FindItem[=${Param0}].ID}
    /if (${SelectedItem.ID}==${FindItem[=${Param0}].ID}) {
      /delay 1s
      /varset OldMoney ${Me.Cash} 
      /nomodkey /shift /notify MerchantWnd MW_Sell_Button leftmouseup 
      /delay 2s (${Me.Cash}!=${OldMoney})
    }
    /goto :Finding 
  }
  /echo No more ${Param0} to sell!!!      
  /return 

Sub ClearCursor 
  /declare x int local 
  :auto_inv 
  /if (${Cursor.ID}) { 
    /if (${Cursor.Container}) { 
      /for x 1 to 8
        /if (!${InvSlot[pack${x}].Item.Container}) /nomodkey /itemnotify pack${x} leftmouseup 
      /next x 
    } else { 
      /timed 5 /autoinventory 
    } 
    /goto :auto_inv 
  } 
  /return
 
Last edited:
The macros above do not work for me unfortunately. Here are the ui files. Thanks.
 
I was looking at the code and I know why it isn't working lol. Because it doesn't have any of the subs that are being called. NinjaAdvLoot.inc only has two subs in my macro folder, LootCorpse and LootItem.


Code:
    /call SetupAdvLootVars
    /call npc "${Taget.CleanName}"
    /call Buy "${StuffToBuy}" ${AmountToBuy}

are all invalid calls because Sub npc, sub Buy, and sub SetupAdvLootVars doesn't exist in any of these files.

So I'm not sure how this ever worked.
 
Easy stuff done. So far I have it check to see if you own the item provided as Param0, I have it to check to see if the merchant window is open, if not it targets the nearest merchant and attempts to open them up if you are close enough. Added a sub to open all your bags (that way the notify will work, otherwise you get an error about access violation).

Still working on checking the vendor for the item and getting a count of the item. Then I'll sort out the buy/sell routines to buy from the vendor and then sell to the vendor.

I want a little input from you though. Will you start with the item already in your inventory and sell it first, or will you need to buy it from a vendor first.

I suppose I could code logic to figure it out and do whichever I prefer, but I'd rather get your input.



Code:
#warning

Sub Main(Param0)

    /if (${Defined[Param0]}) {
		/if (${Param0.Length}) {
			/declare thingToBuy string outer ${Param0}
			/cechob "\aoAttempting to Buy and Sell ${thingToBuy}"
		} else {
			/cechob "\arNo parameters were supplied, usage: /mac buysell thingtosell"
			/echo "\apEnding the Macro!"
			/end
		}
	}
	
	/call OpenAllContainers
	/if (!${checkInv[${thingToBuy}]}) {
		/cechob "\ayYou don't own this item"
	} else {
		|/goto :mainLoop
	}
	
	/if (!${checkVend[${thingToBuy}]}) {
		/cechob "\ayThe Vendor doesn't have this item"
	}
	
	
	:mainLoop
	
	
	
/return

|Sub to use as a function to return if you have the item.
Sub checkInv(string buyItem)
/return ${FindItemCount[=${buyItem}]}

Sub checkVend(string buyItem)
	/if (!${Window[MerchantWnd].Open}) {
		/cechob "\ayYou need to open a merchant! Attempting to do that for you."
		/target class Merchant
		/if (${Target.Distance} < 20) {
			/echo Attempting to open merchant!
			/invoke ${Target.RightClick}
			/delay 3s
		} else /if (${Target.Race.Name.Equal[Merchant]}) {
		/echo ${Target.CleanName} is to far away to open the Merchant, get closer!
		} else {
		/echo No Merchant in this Zone!!
		/end
		}
	} else {
		
	}
/return

Sub OpenAllContainers
	|** Done only once declare invslot count (calculation to remove the first 23 slots because those are your worn items.) **|
	/if (!${Defined[InvSlots]}) {
		/declare InvSlots int outer 32
		/cechob "\arAll packs opened, you must leave them open for macro to work. Move them if they are in your way!!"
	}
	
	|** Opening your inventory **|
	/if (!${Window[InventoryWindow].Open}) {
		/windowstate InventoryWindow open
	}
	
	|** Opening all your bags **|
	/declare i int inner
	/for i 23 to ${InvSlots}
		/if (${Me.Inventory[${i}].Container} && !${Me.Inventory[${i}].Open}) {
			/nomodkey /itemnotify pack${Int[${Math.Calc[${i}-22]}]} rightmouseup
		}
	/next i
/return

Sub SellToVendor(ItemToSell)
    /if (${Window[MerchantWnd].Open}) {
    	:sell
        /echo Selling ${ItemToSell}
        /nomodkey /itemnotify ${FindItem[=${ItemToSell}].InvSlot} leftmouseup
        /delay 5
        /nomodkey /shiftkey /notify merchantwnd MW_Sell_Button leftmouseup
        /delay 2s
    	/if (${FindItem[${ItemToSell}].InvSlot}) /goto :sell
    } else {
		/cechob "You need to open a merchant! Attempting to do that for you."
		/target class Merchant
		/if (${Target.Distance} < 20) {
			/echo Attempting to open merchant!
			/invoke ${Target.RightClick}
			/goto :sell
		} else /if (${Target.Race.Name.Equal[Merchant]}) {
			/echo ${Target.CleanName} is to far away to open the Merchant, get closer!
		} else {
			/echo No Merchant in this Zone!!
			/end
		}
	}
/return

is what it looks like so far. Tested and working on live. Obviously the build for EMU and the build for Live are different, recommend testing this bit while standing next to a vendor to verify this much is working. Usage is /mac buysell item

so if I want to do cogs /mac buysell cogs

This code won't actually buy/sell cogs, it only checks for the item in your inventory and returns a count as a function to see if you have it in your inventory, and it checks for the merchant window to be open and then opens it if you are close enough.
 
Last edited:
Ok, so currently I have a version that automatically sells the item for you. Buying is a different story. I've compared the UI elements from the one you sent me for the MerchantWnd and the version I'm using from live and they show as matching. So The UI is the same at this point.

However, tracking down how to get it to target a specific item in the merchant window is a different story. At this point I'm simply attempting to

Code:
        /nomodkey /shiftkey /notify merchantwnd MW_ItemList leftmouseup

Which apparently just clicks on the middle of the window, So I know which one is the correct window to notify. However, I can't at this point find what I would use to click a specific item in that window.

I've tried the name (using corks which buy/sell for the same price of 1c)

Code:
        /nomodkey /shiftkey /notify merchantwnd MW_ItemList cork leftmouseup

As if it were an array.
Code:
        /nomodkey /shiftkey /notify merchantwnd MW_ItemList[cork].ID leftmouseup

Neither of which work. Without this snippet of code the rest of the macro is rather pointless unless you just want to sell things with a command lol.

I'll look more into it with the wiki and see if I can come up with something.
 
Code:
/nomodkey /shiftkey /notify merchantwnd MW_ItemList listselect #

Where # is the location from top to bottom does select specific items. Now to figure out how to get the # of the buyItem :-x
 
Would like to have the macro buy it from vendor first and then sell.
 
I'm done. I didn't see your message until I'd already finished coding, it'll do either. It checks your inventory, and if you don't have one it checks the vendor. It works for me in POK buying/selling Corks from Tinkering merchants.

That'll be $20,000,000 plus tax of course.


usage: /mac buysell ItemName

IE: /mac buysell cork

Guess it's worth mentioning that this sells stacks if they are stackable. While corks stack higher than 100, it buys 100 at a time by holding Shift when hitting the buy button. It then sells the stack using Shift while hitting the sell button.

This doesn't verify that you are earning money, it just buys and sells in a loop. It does have a delay on it. I could probably remove or tweak the delay to go faster, but I figured just automating it was good enough.

Hope you get some use out of it.
 

Attachments

  • buysell.mac
    3.4 KB · Views: 16
Last edited:
Corrections were made. To be specific to EQEMU ROF2
 

Attachments

  • Buystuff.mac
    3.7 KB · Views: 7
Works great! Thanks for all the work on this, very nice.
 
Fixed my mathing issues haha.

Note: This only buys/sells Elegant Defiant Breastplates.

Passing multiple words as a string isn't really a thing and I didn't feel like setting up an INI.
 

Attachments

  • Buystuff.mac
    3.7 KB · Views: 2
Last edited:
Sped up version of it.
 

Attachments

  • Buystuff.mac
    3.7 KB · Views: 19
Last edited:
Thanks Chat. Sorry mine didn't work. They usually work for me and have been in my mac folder forever. When I get back home I'll have to get ingame and see if they are borked or not. Next time I'll check before I post something. Lesson learned.
 
Left it running for 11 hours+ while I slept. The result.... lol (Yes I take really long naps)

Things to note. Opening All of your bags manually is required, opening the merchant manually is required in the RoF2 version as ${Me.Inventory[#].Open} boolean check is not present in RoF2 build, and /invoke is not a command so I cannot /invoke ${Target.RightClick} to open the merchant.

So simply go up to the merchant, open it, and open all your bags, then type /mac buystuff

Since passing multiworded strings as an arguement for a parameter is not a thing you must manually edit the name of the item you want to buy and sell.

Code:
Sub Main
	|Change Elegant Defiant Breastplate to something else to use a different item. Be sure to leave the quotes ""
	/declare thingToBuy string outer "Elegant Defiant Breastplate"

Simply change the words Elegant Defiant Breastplate to the item you want to vendor loop, making sure to leave the quotes "" in place. Without the quotes it will only get the first word, IE: Elegant instead of the 3 words Elegant Defiant Breastplate.

Perhaps I'll create another version of this to use an INI and call it auto vend or something to that effect. Though I feel like it is already a part of another macro. The idea would be to have a macro that you can just type /mac autovend that would target the nearest merchant, open it (live server only), open all bags (live server only), and automatically sell the items listed in the autovend ini. This would be useful for when you're farming plat. It would find all the items you get from farming plat and automatically sell the things you know you want to sell based on the contents of the INI.

If anyone thinks that this would be useful, let me know I'll start a new thread for it and finish the write up. The majority of the code to do that is already here. This would function for both live and RoF2 EMU servers. A different version for each of course. Obviously the live version would do more automatically since it has better access to TLOs.

~Chat
 

Attachments

  • LOL.bmp
    5.9 MB · Views: 32
Last edited: