Refresh shop: Difference between revisions
Jump to navigation
Jump to search
imported>Gnocchi masala Revision 12906 add refresh_shop() function. |
imported>Bale r17166: refresh shop |
||
(2 intermediate revisions by one other user not shown) | |||
Line 15: | Line 15: | ||
function_description=Forces mafia to re-check your mall store (useful since it's impossible for mafia to internally track this section of "your" inventory).| | function_description=Forces mafia to re-check your mall store (useful since it's impossible for mafia to internally track this section of "your" inventory).| | ||
code1={{CodeSample| | |||
title=Code Samples| | |||
description=Following example uses refresh_shop to create an auto stocker for your shop that prevents you from flooding the market.| | |||
code= | |||
<syntaxhighlight> | |||
void shop_stocker (item selling, int amount_in_store, float mallprice_factor) { | |||
while (item_amount(selling) > 0) { | |||
int current; | |||
refresh_shop(); | |||
current = shop_amount(selling); | |||
if (current < amount_in_store) { | |||
int amount = amount_in_store - current; | |||
int price = mall_price(selling); | |||
price = round(price * mallprice_factor); | |||
print("Currently have "+current+" "+selling+" in store. Putting "+amount+" more up for "+price+".", "blue"); | |||
put_shop(price, 0, amount, selling); | |||
} | |||
else print("Currently have "+current+" "+selling+" in store. Have not sold any recently.", "red"); | |||
print("Waiting....", "purple"); | |||
waitq(300); //wait 5 mins | |||
} | |||
} | |||
cli_equiv= | shop_stocker ($item[mae west], 5, .99); | ||
</syntaxhighlight>| | |||
}}| | |||
cli_equiv=The CLI command "refresh" with the parameter "shop" has the same function.| | |||
}} | }} | ||
[[Category:Item Management]] | [[Category:Item Management]] |
Latest revision as of 22:03, 3 September 2016
Function Syntax
void refresh_shop()
Forces mafia to re-check your mall store (useful since it's impossible for mafia to internally track this section of "your" inventory).
Code Samples
Following example uses refresh_shop to create an auto stocker for your shop that prevents you from flooding the market.
void shop_stocker (item selling, int amount_in_store, float mallprice_factor) {
while (item_amount(selling) > 0) {
int current;
refresh_shop();
current = shop_amount(selling);
if (current < amount_in_store) {
int amount = amount_in_store - current;
int price = mall_price(selling);
price = round(price * mallprice_factor);
print("Currently have "+current+" "+selling+" in store. Putting "+amount+" more up for "+price+".", "blue");
put_shop(price, 0, amount, selling);
}
else print("Currently have "+current+" "+selling+" in store. Have not sold any recently.", "red");
print("Waiting....", "purple");
waitq(300); //wait 5 mins
}
}
shop_stocker ($item[mae west], 5, .99);
CLI Equivalent
The CLI command "refresh" with the parameter "shop" has the same function.