zynga games

By niknah Last update Oct 14, 2009 — Installed 41,821 times.

street racing crew races (and other changes)

in
Subscribe to street racing crew races (and other changes) 9 posts, 2 voices



int1 User
FirefoxWindows

Since it wasn't working, I did a quick and ugly hack for crew races in street racing when freshmeat is enabled:

In FightFreshmeat function:

if(ss.snapshotLength<=0) {
  ss=document.evaluate("//a[contains(@onclick,'directAttack')]",document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);	}

and farther down:

if(!button) {
  button = tr;
}

It will likely break other games, but I thought you might want to see it.

It doesn't appear to race quite the same way as the game usually does, but experience seems to be climbing at least.

 
int1 User
FirefoxWindows

Well that seems to be fighting the same targets over and over.... Guess I'll have to look more closely at this unless you have any ideas.

 
int1 User
FirefoxWindows

adding this to the beginning of DoFightOverlay randomly targets crews:

if(!aButton) {
// SR
var aB = document.evaluate("//div[@class='raceCrewBtn']",document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
var aBwhich = Math.floor(Math.random()*(aB.snapshotLength-1));
var aBw = aB.snapshotItem(aBwhich);
aButton=nHtml.FindByAttrXPath(aBw,"a","contains(@onclick,'directAttack')");
}

Super ugly again, but it seems to be working better.

 
int1 User
FirefoxWindows

and adding this to the beginning and middle of DoFight makes it wait until stamina gets above a minimum (in this case 5) before fighting again:

  var waitflag = this.GMGetValue('fightWaitFlag',0);

...
  if(this.stats.stamina.num<=0) {
    this.GMSetValue('fightWaitFlag',1);
    this.SetFightMessage("Waiting for more stamina");
    return null;
  }
  if((this.stats.stamina.num<5)&&(waitflag)) {
    this.SetFightMessage("Waiting for more stamina");
    return null;
  }
  if((this.stats.stamina.num>4)&&(waitflag)) {
    this.GMSetValue('fightWaitFlag',0);
    this.VisitFightPage(true);
    return null;
  }

 
int1 User
FirefoxWindows

well I really need to figure out what your code is doing. This apparently works sometimes, and other times it just attacks the same person repeatedly....

 
int1 User
FirefoxWindows

Commenting out this.Click(button) in the FightFreshmeat function seems to remove some of the duplication. Still keeping an eye out....

 
int1 User
FirefoxWindows

another ugly add-in: return to home page if nothing is going on and click the fuel button if it's there:

Add this function in somewhere

visitHome:function() {
  var homeHref = 'http://apps.facebook.com/streetracinggame/?bookmark';
  if (location.href==homeHref) {
    // find form id app32375531555_retrieve_fuel_crew
    var fuelButton=nHtml.FindByAttrContains(document,'form','id','app32375531555_retrieve_fuel_crew');
    if (fuelButton) {
      var actualFuel=nHtml.FindByAttr(fuelButton,'input','type','image');
      if (actualFuel)
        Zynga.Click(actualFuel);
    }
    return null;
  }
  location.href=homeHref;
  return 'home';
},

then in the main function, add this line at the end of the similar list of 5 lines:

    } else if((ok=this.visitHome())!=null) {

with my other changes the page could need reloading after a while but for now this should work.

 
int1 User
FirefoxWindows

I updated the visitHome function to click the home button rather than go to the url:

visitHome:function() {
  var homeButton=nHtml.FindByAttrXPath(document,"a","contains(@id,'_home') and contains(@onclick,'index.php')");
  var homeActive=nHtml.FindByAttrXPath(homeButton.parentNode,"a","contains(@class,'active')");
  if (homeActive) {
    // find form id app32375531555_retrieve_fuel_crew
    var fuelButton=nHtml.FindByAttrContains(document,'form','id','app32375531555_retrieve_fuel_crew');
    if (fuelButton) {
      var actualFuel=nHtml.FindByAttr(fuelButton,'input','type','image');
      if (actualFuel)
        Zynga.Click(actualFuel);
    }
    return null;
  }
  if (homeButton)
    Zynga.Click(homeButton);
  return 'home';
},

I'm keeping an eye out to see if this affects anything about the way the script runs.

 
niknah Script's Author
FirefoxWindows

If you're afraid something will break you can do what this guy did with castle age and start your own script based on this one...
http://userscripts.org/scripts/show/57917
I haven't tried it but he seems to be making a lot of updates to the script every few days.

It takes a lot of time for me to make each update cause I have to go thru all the games and check that it's working.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel