NPC store item price

Tpj_4000

Member
I need a way to return the value of an npc store item. The reason is, I'd like to be able to calculate how many of an item to buy based on my current meat without relying on Mafia's lookup in 'npcstores.txt'.

For instance, when the anti-antidotes were changed in price (also the change in location from market to galaktik's would have failed the attempt). It would be nice to be able to grab the price directly from the page. Is there a string function that will let me grab a string of n length starting at the end of the string I've just searched for?

I've read all the relevant mallbot/mall_price()/undercut() stuff and realize why this might not be allowable. However, getting a price from an npc store shouldn't upset the balance of things.



Ideally, I'd like to be able to:

(forgive me, I don't know how to make the scroll box for code)

//************************************
int[string] data;
string file = "price.txt";
string source;


source = visit_url("store.php?whichstore=m");
if(contains_text(source, "chewing gum on a string")){
data["chewing gum on a string"]=npc_price($item[chewing gum on a string]);​
map_to_file(data, file);​
}
else{
print("error, item not found in store");​
abort();​
}

This way:
  • If an item moves from a store, I'll know it.
  • I can check against the file and see if the price changed, and abort. Thus alerting me to a change.
  • Every week, month, etc. I can do a price check again and re-update the file.
 

Tpj_4000

Member
I was able to patch it together using index_of() and substring(), if anyone was curious. It's not as elegant though :)
 

Bale

Minion
mall_price(item) will return the price of an item. If it can be bought in an NPC store, then that is the price you'll get.
 
Top