Store advertising...

Spiny

Member
Is there a CLI command to add to store advertising? I didn't see anything in mafia's store manager utility. Just thought I'd ask :)

-Spiny
 

Bale

Minion
As far as I know, there is not. Though there should be. I'd recommend:

Code:
int x = 1000; // Add 1000 to advertising budget. 
visit_url("managestore.php?howmuch="+x+"&advertising=Add+to+Budget&action=addad&pwd");

parsing the current budget so that you can automate it... Let's see...

Code:
int current_budget;
string store = visit_url("managestore.php");
matcher budget = create_matcher("Current Budget: (\\d+) Meat" , store);
if(budget.find()) current_budget = budget.group(1);
	else abort("Advertising Budget Unknown!");
print("Current Advertising Budget: "+current_budget);

int x = 1000 - current_budget; 
if(x > 0)
	visit_url("managestore.php?howmuch="+x+"&advertising=Add+to+Budget&action=addad&pwd");

Please note that the above code is 100% untested. I just pulled that off the top of my head so please troubleshoot it properly before trusting it.
 

zarqon

Well-known member
This is the function that I have in my Treasurer-bot's routine script. It will check to see that your store's ad budget is set to target, and if not will add the required amount of meat to bring it back up to target. It is tested working, but note that it uses a function from ZLib.

Code:
void handle_store_budget(int target) {
   string bp = excise(visit_url("managestore.php"),"Current Budget: ","<br");
   if (bp == "") {
      print("Error detecting store advertising budget.","red");
      return;
   }
   int currbudg = to_int(bp);
   print("Store advertising budget: "+currbudg);
   boolean increase_ad_budget(int amt) {
      print("Adding "+amt+" meat to ad budget...");
      return contains_text(visit_url("managestore.php?howmuch="+amt+"&action=addad&pwd"),"Advertising budget increased.");
   }
   if (currbudg < target && increase_ad_budget(target - currbudg))
      print("Budget increased to "+target+".");
}
 

Spiny

Member
Thanks you two :) I went with Zarqon's version because it was pre-tested. Already have zlib.ash and my friend added a little pop-up box for me to plug in my target budget and some verboseness for when I screw up and forget lol.

-Spiny
 
Top