Bazaar Search Conversion
Posted: Mon May 10, 2004 11:58 am
The following is my attempt at converting Driftinsupra's Dumpster dive script. I'm only interested in the bazaar search function using an .ini without the movement so that's all I've included here. I realize my attempt is ridiculously newbie-ish and probably mostly just plain wrong but it's the best I've been able to do given that I really don't know what I'm doing at all. Can I get some hints or examples to assist me in working this out? I wouldn't ask if I hadn't already spent weeks reading and trying to learn how to do this myself.
Old code:
Old code:
Code: Select all
|Driftinsupra's first usefull macro bazarr.mac
|Dumpster diving script. Buy from players and sell to merchants for a profit!
#turbo
sub main
/declare file global
/declare isle global
/declare counter local
/declare l1 local
/declare traderid local
/declare price local
/varset file C:\mq2\ini\bazprice.ini
/varset counter 1
:mainloop
/if "$ini(@file,names,val@counter)"=="NOTFOUND" {
/echo Starting search over
/varset counter 1
/goto :mainloop
}
/echo searching for $ini(@file,names,val@counter)
/bzsrch race any class any $ini(@file,names,val@counter)
| is request done?
:loop
/delay 1
/if "$bazaar()"=="FALSE" /goto :loop
/if n $bazaar(count)==0 {
/echo $ini(@file,names,val@counter) not found, continuing on...
/varadd counter 1
/varset counter $int(@counter)
/goto :mainloop
}
} else {
/echo found $bazaar(count) items
}
/varset price $bazaar(0,price)
/varset traderid $bazaar(0,trader)
/if n $bazaar(count)>1 {
/for l1 1 to $calc($bazaar(count)-1)
/echo @l1 price $bazaar(@l1,price)
/if n @price>$bazaar(@l1,price) {
/varset price $bazaar(@l1,price)
/varset traderid $bazaar(@l1,trader)
}
/next l1
}
/if n @price>=$ini(@file,prices,val@counter) {
/varadd counter 1
/varset counter $int(@counter)
/echo @counter
/goto :mainloop
}
/echo targeting @traderid
/target id @traderid
/face
And my attempt...
[code]#turbo
Sub Main
/declare file global
/declare counter local
/declare l1 local
/declare traderid local
/declare price local
/varset file c:\mq2\ini\bazprice.ini
/varset counter 1
:mainloop
/if (${ini[${File},${Names},${Val},${Counter}]==[NOTFOUND]}) {
/echo Starting search over
/varset counter 1
/goto :mainloop
}
/echo searching for ${ini.file.names.val.counter}
/bzsrch race any class any ${ini.file.names.val.counter}
| is request done?
:loop
/delay 1
/if (${bazaar()==[FALSE]}) /goto :loop
/if (${n{bazaar.count==0}}) {
/echo ${ini{file.names.val.counter}} not found, continuing on…
/varadd counter 1
/varset counter ${int.counter}
/goto :mainloop
}
} else {
/echo found ${bazaar.count} items
}
/varset price ${bazaar.0.price}
/varset traderid ${bazaar.0.trader}
/if (${n{bazaar.count>1}}) {
/for l1 1 to ${calc{bazaar.count-1}}
/echo ${l1} price ${bazaar.l1.price}
/if (${n{price>bazaar.l1.price}}) {
/varset price ${bazaar.l1.price}
/varset traderid ${bazaar.l1.trader}
}
/next l1
}
/if (${n.price>=${ini{file.prices.val.counter}}}) {
/varadd counter 1
/varset counter ${int{counter}}
/echo ${counter}
/goto :mainloop
}
/echo targeting ${traderid}
/target id ${traderid}
/face
I've gotten very good at searching for "null" and targeting "null" as I'm sure you'll see. :)
Thanks,
Semper