Halo 2 Stat Grabber v2.1

By DarthReven on Jan 20, 2006

I play halo 2 alot and i love checking my stats on www.bungie.net but i'm to lazy to stop chatting w/ friends at times to go and check my stats so i made this little script to get the stats for me.

;
;DarthReven's Halo 2 Stat Graber
;Commands:
;/halo2 -<p/c> -<o/g> <gamer tag/clan name>
;EX1: /halo2 -p -o X24CCity
;;<returns all overall data for the given gamer tag>
;EX2: /halo2 -p -g X24CCity
;;<returns all data pertaining to the given gamer tag's last 22 games>
;EX3: /halo2 -c -o Last Soldier
;;<returns all overall data for the given clan name>
;EX4: /halo2 -c -g Last Soldier
;;<returns all data pertaining to the given clan name's last 22 games>
;
alias halo2 {
  if (!$1) || (!$2) || (!$3) { echo $color(notice) -a Error - Invalid parameters: /halo2 -<p/c> -<o/g> <gamer tag/clan name> }
  else {
    if ($regex(pc,$1,/([pc])/ig)) && ($regex(og,$2,/([og])/ig)) {
      if ($sock($+(halo2.,$3))) { sockclose $+(halo2.,$3) }
      sockopen $+(halo2.,$3) www.bungie.net 80
      sockmark $+(halo2.,$3) $+($me,/,$regml(pc,1),/,$regml(og,1),/,$replace($3-,$chr(32),$+(%,20)))
      echo $color(info) -a [Halo 2] - Retreving Data on $iif($regml(pc,1) == p,player,clan) $3-
    }
    else { echo 4 -a Error - Invalid parameters: /halo2 -<o/g> <gamer tag> }
  }
}
on *:sockopen:halo2.*: {
  sockwrite -n $sockname GET $($halo2router($sock($sockname).mark).url,2) HTTP/1.1 
  sockwrite -n $sockname Host: www.Bungie.net
  sockwrite -n $sockname $crlf
}
on *:sockread:halo2.*: {
  var %tmp
  sockread %tmp
  if ($halo2router($sock($sockname).mark).pc == p) {
    if ($halo2router($sock($sockname).mark).og == o) {
      if (*<span id="dlHopperRanks__ctl*_HopperName">*</span>* iswm %tmp) { hadd -m Halo2Stat TEMP $remove($nohtml(%tmp),$chr(9)) }
      elseif (*<span>*</span></span>* iswm %tmp) { 
        echo $color(info2) -a $+([,$hget(Halo2Stat,TEMP),]) - $remove($nohtml(%tmp),$chr(9))
        hdel Halo2Stat TEMP
      }
      elseif (*<div class="ExpBar" style="width:*"><div class="ExpBarText" style="left:*">*</div></div>* iswm %tmp) { hadd Halo2Stat TEMP $addtok($hget(Halo2Stat,TEMP),$+(L,.,$remove($nohtml(%tmp),$chr(9))),95) }
      elseif ($nohtml(%tmp) isnum) {
        if ($numtok($hget(Halo2Stat,TEMP),95) == 2) { hadd Halo2Stat TEMP $addtok($hget(Halo2Stat,TEMP),$+(GP,.,$remove($nohtml(%tmp),$chr(9))),95) }
        elseif ($v1 == 3) { 
          echo $color(info2) -a $+([,$gettok($hget(Halo2Stat,TEMP),1,95),]) - [Level] $mid($gettok($hget(Halo2Stat,TEMP),2,95),3) [Games Played] $mid($gettok($hget(Halo2Stat,TEMP),3,95),4) [Wins] $nohtml(%tmp) [Winning Percentage] $halo2router($mid($gettok($hget(Halo2Stat,TEMP),3,95),4),$nohtml(%tmp)).percent
          hadd -m Halo2Stat TEMP_2 $iif($hget(Halo2Stat,TEMP_2),$calc($v1 + $mid($gettok($hget(Halo2Stat,TEMP),3,95),4)),$mid($gettok($hget(Halo2Stat,TEMP),3,95),4))
          hadd -m Halo2Stat TEMP_3 $iif($hget(Halo2Stat,TEMP_3),$calc($v1 + $nohtml(%tmp)),$nohtml(%tmp))
          hdel Halo2Stat TEMP
        }
      }
      elseif (*<p class="rightSide"><b>Questions about Stats?</b></p>* iswm %tmp) {
        echo $color(info2) -a [Total Games Played] $hget(Halo2Stat,TEMP_2) [Total Wins] $hget(Halo2Stat,TEMP_3) [Overall Win Percentage] $halo2router($hget(Halo2Stat,TEMP_2),$hget(Halo2Stat,TEMP_3)).percent
        echo $color(info) -a [Halo 2] - END Data Retreval on $iif($gettok($sock($sockname).mark,2,47) == p,player,clan) $halo2router($sock($sockname).mark).query 
        hfree Halo2Stat
        sockclose $sockname
      }
      elseif (*</HTML>* iswm %tmp) {
        echo $color(notice) -a [Error] - Gamertag $gettok($sock($sockname).mark,3,47) was not found
        echo $color(info) -a [Halo 2] - END Data Retreval on $iif($gettok($sock($sockname).mark,2,47) == p,player,clan) $halo2router($sock($sockname).mark).query 
        sockclose $sockname
      }
    }
    else {
      if (*<span><a id="RecentGames__ctl*_GameLink" class="span" href="/Stats/GameStats.aspx?gameID=*">*</a></span></td>* iswm %tmp) { hadd -m Halo2Stat TEMP $nohtml($v2) }
      elseif (*<span id="RecentGames__ctl*_Date" class="span">*</span></td>* iswm %tmp) {  hadd Halo2Stat TEMP $addtok($hget(Halo2Stat,TEMP),$nohtml(%tmp),45) }
      elseif (*<span id="RecentGames__ctl*_Map" class="span">*</span></td>* iswm %tmp) { var %map $nohtml($v2) | hadd Halo2Stat TEMP $addtok($hget(Halo2Stat,TEMP),%map,45) }
      elseif (*<span id="RecentGames__ctl*_HopperName" class="span">*</span></td>* iswm %tmp) { hadd Halo2Stat TEMP $addtok($hget(Halo2Stat,TEMP),$nohtml(%tmp),45) }
      elseif (*<span id="RecentGames__ctl*_Standing" class="span">*</span></td>* iswm %tmp) { 
        echo $color(info2) -a $halo2router($hget(Halo2Stat,TEMP)).pgs $nohtml(%tmp)
        hinc -m Halo2Stat $+(TEMP_,$nohtml(%tmp))
      }
      elseif (*<td><span class="InvalidGame">* indicates that game's stats are unreliable</span></td>* iswm %tmp) {
        echo $color(info2) -a [Game Finishes] - [1st Place] $calc($hget(Halo2Stat,TEMP_1st)) [2nd Place] $calc($hget(Halo2Stat,TEMP_2nd)) [3rd Place] $calc($hget(Halo2Stat,TEMP_3rd)) [4th Place] $calc($hget(Halo2Stat,TEMP_4th)) [5th Place] $calc($hget(Halo2Stat,TEMP_5th)) [6th Place] $calc($hget(Halo2Stat,TEMP_6th))
        echo $color(info) -a [Halo 2] - END Data Retreval on $iif($gettok($sock($sockname).mark,2,47) == p,player,clan) $halo2router($sock($sockname).mark).query
        hfree Halo2Stat
        sockclose $sockname
      }
      elseif (*<SPAN>There are no games available or the stats system is temporarily unavailable.</SPAN>* iswm %tmp) { echo $color(notice) -a [Error] - Gamertag $halo2router($sock($sockname).mark).query was not found }
    }
  }
  else {
    if ($halo2router($sock($sockname).mark).og == o) {
      if (*<span id="dlHopperRanks__ctl1_HopperName">*</span>* iswm %tmp) { hadd -m Halo2Stat TEMP $nohtml(%tmp) }
      elseif (*<span id="dlHopperRanks__ctl1_lblNoLevel"><span>*</span></span>* iswm %tmp) {
        echo 4 -a [Clan] - $halo2router($sock($sockname).mark).query has not played any games.
        echo $color(info) -a [Halo 2] - END Data Retreval on $iif($gettok($sock($sockname).mark,2,47) == p,player,clan) $halo2router($sock($sockname).mark).query
        sockclose $sockname
      }
      elseif (*<div class="ExpBar" style="width:50"><div class="ExpBarText" style="left:20">*</div></div>* iswm %tmp) { hadd -m Halo2Stat TEMP $addtok($hget(Halo2Stat,TEMP),$nohtml(%tmp),45) }
      elseif (*<td align="center"><span>*</span></td>* iswm %tmp) && ($nohtml(%tmp) isnum) {
        if ($numtok($hget(Halo2Stat,TEMP),45) == 3) { 
          echo $color(info2) -a $halo2router($hget(Halo2Stat,TEMP)).cor $nohtml(%tmp) [Winning Percentage] $halo2router($gettok($hget(Halo2Stat,TEMP),3,45),$nohtml(%tmp)).percent
          echo $color(info) -a [Halo 2] - END Data Retreval on $iif($gettok($sock($sockname).mark,2,47) == p,player,clan) $halo2router($sock($sockname).mark).query
          sockclose $sockname
        }
        else { hadd -m Halo2Stat TEMP $addtok($hget(Halo2Stat,TEMP),$nohtml(%tmp),45) }
      }
    }
    else {
      if (*<td><span><a id="dlClanGames__ctl*_GameLink" href="*">*</a></span></td>* iswm %tmp) { hadd -m Halo2Stat TEMP $nohtml(%tmp) }
      elseif (*<td><span id="dlClanGames__ctl*_Date">*</span></td>* iswm %tmp) { hadd -m Halo2Stat TEMP $addtok($hget(Halo2Stat,TEMP),$nohtml(%tmp),45) }
      elseif (*<td><span id="dlClanGames__ctl*_Map">*</span></td>* iswm %tmp) { hadd -m Halo2Stat TEMP $addtok($hget(Halo2Stat,TEMP),$nohtml(%tmp),45) }
      elseif (*<td><span id="dlClanGames__ctl*_lblHopperName" class="span">*</span></td>* iswm %tmp) { 
        echo $color(info2) -a $halo2router($hget(Halo2Stat,TEMP)).cgs $nohtml(%tmp)
      }
      elseif (*<p class="rightSide"><b>Questions about Stats?</b></p>* iswm %tmp) {
        echo $color(info) -a [Halo 2] - END Data Retreval on $iif($gettok($sock($sockname).mark,2,47) == p,player,clan) $halo2router($sock($sockname).mark).query
        sockclose $sockname
      }
      elseif (*<h2>Object moved to* *here</a>.</h2>* iswm %tmp) {
        echo 4 -a [Clan] - $halo2router($sock($sockname).mark).query has not played any games.
        echo $color(info) -a [Halo 2] - END Data Retreval on $iif($gettok($sock($sockname).mark,2,47) == p,player,clan) $halo2router($sock($sockname).mark).query
        sockclose $sockname
      }
    }
  }
}
on *:sockclose:halo2.*: { if ($hget(Halo2Stat)) { hfree Halo2Stat } }
alias halo2router {
  if ($prop) {
    if ($v1 == url) {
      if ($gettok($1,2,47) == p) {       
        if ($gettok($1,3,47) == o) { return $+(/Stats/PlayerStats.aspx?player=,$gettok($1,4,47)) }
        else { return $+(/Stats/PlayerGameList.aspx?player=,$gettok($1,4,47)) }
      }
      else {
        if ($gettok($1,3,47) == o) { return $+(/Stats/ClanStats.aspx?clan=,$gettok($1,4,47)) }
        else { return $+(/Stats/ClanGameList.aspx?clan=,$gettok($1,4,47)) }
      }
    }
    elseif ($v1 == pc) { return $gettok($1,2,47) }
    elseif ($v1 == og) { return $gettok($1,3,47) }
    elseif ($v1 == query) { return $replace($gettok($1,4,47),$+(%,20),$chr(32)) }
    elseif ($v1 == pgs) {
      tokenize 45 $1
      return [Game] $1 [Time] $2 [Map] $3 [Game Type] $4 [Position]
    }
    elseif ($v1 == cor) {
      tokenize 45 $1
      return [Playlist] $1 [Level] $2 [Games Played] $3 [Wins]
    }
    elseif ($v1 == cgs) {
      tokenize 45 $1
      return [Game] $1 [Time] $2 [Map] $3 [Playlist]
    }
    elseif ($v1 == percent) { return $+($round($calc($calc($2 / $1) * 100),1),%) }
  }
}
alias -l nohtml { 
  var %a,%b
  %b = $regsub($1,/[^<]*>|<[^>]*>|<[^>]*/g,$chr(32),%a)
  return $iif($chr(9) isin %a,$remove(%a,$chr(9)),%a)
}

Comments

Sign in to comment.
Darkkeeper   -  Feb 07, 2008
  • /return: line too long (line 152, script1.ini)

i keep getting that everytime i try and search for somebody on this :\

 Respond  
Darkkeeper   -  Feb 07, 2008

Yo, make one for halo 3

 Respond  
DarthReven   -  May 13, 2006

Thre has been a slight delay in the updating of this script duer to my preperation for my Beta releace of my new mp3 script so please bare with and i will get version 3.1 out asap

 Respond  
DarthReven   -  May 05, 2006

Due to changes on Bungie.net this script will not work atm i am currently updating it and should be done in a few days

 Respond  
sean   -  Feb 23, 2006

cougH dialog :P

 Respond  
StonedStoner   -  Feb 22, 2006

[Rumble Pit] - [Level] 20 [Games Played] 49 [Wins] 24 [Winning Percentage] 49%
[Double Team] - [Level] 18 [Games Played] 66 [Wins] 33 [Winning Percentage] 50%
[Team Slayer] - [Level] 26 [Games Played] 249 [Wins] 131 [Winning Percentage] 52.6%
[Team Skirmish] - [Level] 17 [Games Played] 46 [Wins] 27 [Winning Percentage] 58.7%
[Team Snipers] - [Level] 23 [Games Played] 209 [Wins] 99 [Winning Percentage] 47.4%
[Team Hardcore] - [Level] 17 [Games Played] 51 [Wins] 31 [Winning Percentage] 60.8%
[6v6 Team Battle] - [Level] 16 [Games Played] 74 [Wins] 30 [Winning Percentage] 40.5%
[Big Team Battle] - [Level] 13 [Games Played] 40 [Wins] 16 [Winning Percentage] 40%
[Total Games Played] 784 [Total Wins] 391 [Overall Win Percentage] 49.9%
[Halo 2] - END Data Retreval on player KaptianStabAHo

 Respond  
redriver   -  Feb 22, 2006

When and if you do. It would be greatly appreciated.

[Halo 2] - Retreving Data on player ivekilled4less
[Rumble Pit] - [Level] 18 [Games Played] 191 [Wins] 7 [Winning Percentage] 3.7%
[Double Team] - [Level] 15 [Games Played] 64 [Wins] 33 [Winning Percentage] 51.6%
[Team Slayer] - [Level] 24 [Games Played] 202 [Wins] 111 [Winning Percentage] 55%
[Team Skirmish] - [Level] 17 [Games Played] 108 [Wins] 45 [Winning Percentage] 41.7%
[Team Snipers] - [Level] 14 [Games Played] 44 [Wins] 20 [Winning Percentage] 45.5%
[Team Hardcore] - [Level] 7 [Games Played] 14 [Wins] 6 [Winning Percentage] 42.9%
[6v6 Team Battle] - [Level] 5 [Games Played] 16 [Wins] 5 [Winning Percentage] 31.3%
[Big Team Battle] - [Level] 13 [Games Played] 38 [Wins] 17 [Winning Percentage] 44.7%
[Total Games Played] 677 [Total Wins] 244 [Overall Win Percentage] 36%

 Respond  
DarthReven   -  Feb 20, 2006

I may have to just rewrite it for use with a mIRC bot

 Respond  
redriver   -  Feb 16, 2006

I really appreciate the time you spent editing your script for me, but it doesn\'t seem to work. I used the corrected intro you sent, but still nothing. The script works GREAT as is. I was just hoping to set it up on my bot, so my friends could use it as well without having to put the script in their client.

 Respond  
DarthReven   -  Feb 12, 2006

-Update- (1) Added Total Wins, Total Games, & Total Winning percentage (2) Counts Game Finish Type <IE 1st,2nd,3rd,etc...>

 Respond  
DarthReven   -  Feb 12, 2006

-Update- The script now has the option to get clan stats aswell

 Respond  
DarthReven   -  Feb 08, 2006

reddiver nothins is sent via notice its all echoed to your active window but it is pretty easy to set up to use it with an on text event if you want me to set that up for you msg me with your email and i\'ll give you a copy of that

 Respond  
redriver   -  Feb 01, 2006

I have two requests.

Is there anyway to get this to respond to an on *:text:!halo2

Is there anyway to make the output a /msg $chan instead of a notice

 Respond  
StonedStoner   -  Jan 30, 2006

Would be wonderful if this was improved upon.

 Respond  
sean   -  Jan 21, 2006

very nice stuff Reven!
Add me sometime, GamerTag: Dymd3z

 Respond  
tank59   -  Jan 21, 2006

Nice, I\'m big on Team Slayer. I\'ll add ya, but I don\'t play that often :(

 Respond  
DarthReven   -  Jan 21, 2006

I only play Team Skirmish:
[Team Skirmish] - [Level] 13 [Games Played] 136 [Wins] 45 [Winning Percentage] 33.1%

 Respond  
tank59   -  Jan 21, 2006

[Halo 2] - Retreving Data on TANKTheReaper
[Rumble Pit] - No Games Played
[Double Team] - [Level] 14 [Games Played] 21 [Wins] 15 [Winning Percentage] 71.4%
[Team Slayer] - [Level] 29 [Games Played] 187 [Wins] 93 [Winning Percentage] 49.7%
[Team Skirmish] - No Games Played
[Team Snipers] - [Level] 9 [Games Played] 24 [Wins] 11 [Winning Percentage] 45.8%
[Team Hardcore] - No Games Played
[6v6 Team Battle] - [Level] 2 [Games Played] 2 [Wins] 1 [Winning Percentage] 50%
[Big Team Battle] - [Level] 1 [Games Played] 2 [Wins] 0 [Winning Percentage] 0%
[Halo 2] - END Data Retreval on TANKTheReaper
Read \'em and weap boys. Lol

 Respond  
RoninWarrior   -  Jan 20, 2006

finally a halo addon swwet this is awsome Darth deffintly going to have to try this out

 Respond  
DarthReven   -  Jan 20, 2006

Thank You tank59

 Respond  
tank59   -  Jan 20, 2006

This is glorious. I play Halo all the time. Nice job Darth.

 Respond  
XpLoiTeR   -  Jan 20, 2006

vry useful for halo players...even though i donno what is hallow :D i need to improve my sockets coding to make such useful things like managing kingsofchaos at www.kingsofchaos.com ... i can make login and logout,attack,training,buying weapons and so on...but i need to read a good tutorial bt sockets

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.