Custom event triggers from Chat/Main Page

Alright, so I'm writing what's going to initially be a very simple MMG betting loop script.Basically I know how to do everything I need to do, except determine when a bet goes, and if it won or loss. I was planning on finding this out from chat, I was assuming that since mafia is java ASH would have some kind of string.split method, but I didn't even manage to get that far. What I would like to know is, is there a way to parse incoming messages from chat? I suppose I could periodically check the logs, but this isn't exactly elegant, and the time it would take to do so would continue to grow as time passes.

Code:
void placebet(int currentbet, int meatchoice)
{
	string betfinalize = "bet.php?pwd&action=makebet&howmuch=" + currentbet + "&from=" + meatchoice;
	visit_url(betfinalize);
}

void main(int initialbet, int runfor, int meatchoice)
{
	placebet(initialbet, meatchoice);
}

This is what I've written so far, currently nothing is actually done with runfor, but that will be used for the main loop. So far all it does is place a single bet on the MMG using initial bet and meatchoice(Meat from inventory, or hagnks). I don't want to write the loop yet, until I figure out a means of determining if the previous bet has won or lost then I will move to building the main loop and figuring out if any nested loops are required.

Unfortunately it would seem the language at the moment isn't all that well documented so I decided to see if anyone in the forums could lend me a hand. I don't want the script written for me, because then I will learn nothing. If you could just give me some pointers as to how I could extract the information I need from chat/the main page (Since that's where MMG results go when you're not in chat and it would be nice if you could have the script running without being in chat) and I'm fairly confident I can do the rest myself. Thanks in advance.
 

zarqon

Well-known member
I have never scripted anything involving either the MMG or chat, but I have a few tips for you that may prove helpful.

Typing ashref from the CLI gives you a list of ASH commands, where you can find all of ASH's useful functions, such as:

visit_url(), which returns the html of the page visited. You may want to make your placebet function return the text of the resultant page, instead of just void, because you might want to be parsing it using more functions, like:

index_of(), which returns the position of a needle string within a haystack string.

split_string(), which splits a large string into pieces and returns a map of the pieces.

Those may be useful for you to start extracting information. Good luck.
 

Alphonse Kane

New member
I'm also working on something to extract information from (#1818136)'s chat pane. So far, I've been working with visit_url and getting some results, although it doesn't seem to be working properly 100% of the time.
 
Top