help with mmg_wait_event.

johngnash

Member
Ok so this looks like it should work, and yet it gets hung up on the mmg_wait_event.

The goal: I was curious how many bets it would take to get 10 difference between wins and losses in the MMG. this means if your total win/loss ratio while running the script gets to +/- 10 it stops. Otherwise it will keep betting the minimum of 1k. It only runs 1 chain at a time.

Also I have tried not only looking at but also using mmg.ash and anti-martingale.ash to see where i went wrong, and it would seem that they may be getting hung on the mmg_wait_event also.

So here is the code I have:

int wave=0;
int n=0;
int b=0;
void main()
{
while(wave<10&&wave>-10)
{
mmg_make_bet(1000, true);
while(mmg_wait_event(1000)==0)
{
n=n+1;
print("n="+n);
}
n=0;
if(mmg_bet_winnings()<0)
wave=wave-1;
if(mmg_bet_winnings()>0)
wave=wave+1;
print(wave);
b=b+1;
}
print("Final wave was "+wave+" and it took "+b" bets to get there");
}
 

slyz

Developer
Maybe this has nothing to do with the issue at hand, but is Mafia's chat opened when you run this?
 

mredge73

Member
from a quick wiki look:
int mmg_wait_event( int delay )
delay is the number of milliseconds to wait
Waits for delay milliseconds for KoL to report on an outstanding bet being taken. Returns the bet ID # of the taken bet.

I have never used the function but I am assuming that the bet ID# will never be 0?
I would suggest to increase the delay to more than one second, maybe 5 seconds (5000).
 
Last edited:

johngnash

Member
It seems to be 0 until the event in question is resolved. and I've done delays from 30 (the same delay in Z's script) to 100000. It all comes out the same. It just keeps checking and doing nothing, just like Z's script, which used to work. If it helps I'm using build 8870.

And yes, as soon as the mmg_wait_event is anything but 0 it should exit the while block, and assess if you won or lost based on if your winnings for the event are positive or negative. Than it should go back to the outer while and assess if your wave is at + or - 10 wins total. It just seems to get hung on the wait event, looping forever.
 

Veracity

Developer
Staff member
A few observations:

- mmg_make_bet returns a bet id. If the bet fails, it returns 0.
- mmg_wait_event returns the bet id it matched, or 0 if no bet matched. If you have no outstanding bets, it will always return 0.
- mmg_make_bet's second argument says whether to use meat from inventory or storage. You have "true", which means "storage". Do you have any meat in storage?
- mmg_bet_winnings returns a positive number if you won and 0 if you lost. Subtract your initial bet to see incremental winnings.

Taking all of the above into account, I modified your program into the following - which seems to work for me.

PHP:
int BET = 1000;
int BMAX = 3;
int WMAX = 30;
boolean STORAGE = false;

int wave = 0;
int bets = 0;

void main()
{
  while ( wave < BMAX && wave > -BMAX ) {
    int id = mmg_make_bet( BET, STORAGE );
    if ( id == 0 ) {
      print( "bet failed" );
      break;
    }
    bets += 1;

    int wcount = 0;
    while ( mmg_wait_event( 1000 ) != id && wcount < WMAX ) {
      wcount += 1;
      print( "wait=" + wcount );
    }
    if ( wcount >= WMAX ) {
        print( "waited too long" );
        break;
    }

    int winnings = mmg_bet_winnings() - BET;
    if ( winnings < 0 )
      wave -= 1;
    else if ( mmg_bet_winnings() > 0 )
      wave += 1;
    print( "wave=" + wave );
  }
  print( "Final wave was " + wave + " and it took " + bets + " bets to get there" );
}
 
Last edited:

johngnash

Member
I could only test from storage (in HC) (5m in storage)

Thanks Veracity. I was having a hard time pulling apart the other scripts, but I see where I was having issues. I wasn't really understanding the mmg_wait_event function.

Again thanks.


EDIT: So found the issue i was having. The function has problems when the chat pref aren't default. I think the issue was having the gcli as part of the chat interface.
 
Last edited:
Top