Top 5 MapleStory Ranking (Image Downloader)

By Kirby on Apr 08, 2009

I used to play a game called MapleStory. It's kinda a mix of World of Warcraft and Runescape, but anime-like.
Anyhow, quite some time ago, ^Neptune gave me parts of a "Image-Downloader" socket script, originally given through IRC (so I heard) by TheImrac. This inspired me to create an "example" of the powers of Image downloading, all done in mIRC.
On to the script:
Basically, this script gets information from the Top 5 Global MapleStory Rankings Page.

The "information" includes:

  • Avatar (Sprite) of the Character Image of his/her pet (if he/she has one) Name Level Experience Points Class World
    [size=16]Syntax: /maple[/size]

When the dialog opens, click on one of the five buttons on the left portion of the dialog, and it will show all of the information as listed above.
After the dialog is closed, the directory 'MapleStory', along with the images and hashes, are deleted.

[size=14]I apologize if this does not particularly interest you, but again, it's just an example. :P[/size]

[size=14]But, image downloading via mIRC is powerful![/size]

[size=14]Irrelevant to the script:[/size] On the side note, my original intention was to get all rankings, but unfortunately, the rankings page is POST and cannot be achieved through only GET. If you can figure out a way to get any ranking, I would be very pleased. :)

Here's a picture:
Image

Enjoy! :D (if you care)

;BOF

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
;         MapleStory 'Avatar/Sprite'-Getter         ;
;              Made by Kirby (Quakenet)             ;
;*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;

; // Open up the dialog //
alias maple dialog $iif($dialog(maple),-v,-m) maple maple
menu * {
  Top 5 Global MapleStory Rankings : maple
}

; // Identifiers used in the sockets //
alias -l between { noop $regex($1,/\Q $+ $2 $+ \E(.*?)\Q $+ $3 $+ \E/gi) | return $regml($4) }
alias -l htmlfree { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;) | return $remove($replace(%x,&quot;,",&lt;,<,&gt;,>,$cr,$chr(32),$lf,$chr(32),&amp;,&),$chr(9)) }

; // MapleStory Sockets //
on *:sockopen:maple: {
  sockwrite -n $sockname GET /Modules/Rank/Ranking.aspx?PART=/Controls/Rank/TotRank&ranktype=TotRank HTTP/1.0
  sockwrite -n $sockname Host: maplestory.nexon.net $+ $crlf $+ $crlf
  inc %ms
}
on *:sockread:maple: {
  sockread %maple
  if (</script><br></br> isin %maple) hadd -m $+(maple,%ms) Name: $gettok($htmlfree(%maple),2,59)
  if (<TD WIDTH=102 ALIGN=CENTER BACKGROUND= isin %maple) {
    hadd -m $+(maple,%ms) Char: $gettok(%maple,6,34)
    hadd -m $+(maple,%ms) Pet: $gettok(%maple,2,34)
    hadd -m MapleFiles $gettok(%maple,6,34)
    hadd -m MapleFiles $gettok(%maple,2,34)
    img_download -ok $gettok(%maple,6,34) MapleStory\
    img_download -ok $gettok(%maple,2,34) MapleStory\
  }
  if (CLASS="bbs_table_categoty"><IMG SRC= isin %maple) {
    var %x $between(%maple,world_,.gif,1)
    hadd -m $+(maple,%ms) World: $+($upper($mid(%x,1,1)),$mid(%x,2,$len(%x)))
  }
  if (SRC="http://nxcache.nexon.net/maplestory/ranking/job_ isin %maple) {
    var %x $between(%maple,job_,.gif,1)
    hadd -m $+(maple,%ms) Class: $+($upper($mid(%x,1,1)),$mid(%x,2,$len(%x)))
  }
  if (<TD WIDTH=115 ALIGN=CENTER CLASS="menu"><B> isin %maple) {
    hadd -m $+(maple,%ms) Level: $gettok($htmlfree(%maple),1,40)
    hadd -m $+(maple,%ms) Exp: $between($htmlfree(%maple),$chr(40),$chr(41),1)
  }
  if ($hget($+(maple,%ms),0).item == 7) inc %ms
}

; // Dialogs //
dialog wait {
  title "Please wait... :-)"
  size -1 -1 156 7
  option dbu
  text "Please wait while images and information are being gathered. :-)", 1, 1 0 155 8
}
dialog maple {
  title "Top 5 Global MapleStory Rankings"
  size -1 -1 251 149
  option dbu
  button "Rank #1", 1, 23 23 37 12
  button "Rank #2", 2, 23 45 37 12
  button "Rank #3", 3, 23 68 37 12
  button "Rank #4", 4, 23 91 37 12
  button "Rank #5", 5, 23 114 37 12
  icon 6, 95 14 58 55
  icon 7, 177 20 47 43
  text "Name:", 8, 122 93 16 8
  edit "", 9, 143 92 50 10, read center
  text "Level:", 10, 82 110 15 8
  edit "", 11, 102 109 50 10, read center
  text "Class:", 12, 165 109 15 8
  edit "", 13, 186 109 50 10, read center
  text "Exp:", 14, 84 125 12 8
  edit "", 15, 102 124 50 10, read center
  text "World:", 16, 165 125 16 8
  edit "", 17, 186 124 50 10, read center
  box "Rankings 1 ~ 5:", 18, 16 11 52 122
  box "Character Information:", 19, 78 3 163 140
  text "Character", 20, 113 73 25 8
  text "Pet", 21, 198 73 9 8
  box "", 22, 78 83 163 60
  box "", 23, 16 37 52 26
  box "", 24, 16 82 52 27
  box "", 25, 94 10 61 61
  box "", 26, 176 16 50 49
}

; // Dialog Events //
on *:dialog:maple:*:*: {
  if ($devent == init) {
    if (!$sock(maple)) .sockopen maple maplestory.nexon.net 80
    mkdir MapleStory
    dialog -amv wait wait
    did -b $dname 1-5,8-17
  }
  if ($devent == sclick) {
    if ($did isnum 1-5) {
      did -e $dname 8-17
      did -h $dname 25-26
      did -ra $dname 9 $hget($+(maple,$did),Name:)
      did -ra $dname 11 $hget($+(maple,$did),Level:)
      did -ra $dname 13 $hget($+(maple,$did),Class:)
      did -ra $dname 15 $hget($+(maple,$did),Exp:)
      did -ra $dname 17 $hget($+(maple,$did),World:)
      did -g $dname 6 $+(MapleStory\,$nopath($hget($+(maple,$did),Char:)))
      did -g $dname 7 $+(MapleStory\,$nopath($hget($+(maple,$did),Pet:)))
    }
  }
  if ($devent == close) {
    noop $findfile(MapleStory\,*,0,0,.remove $qt($1-))
    rmdir MapleStory
    hfree -w maple*
    unset %ms %maple*
  }
}

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
;         TheImrac's "Image-Downloader"         ;
;*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;

alias -l bet { var %reg $+(/,$2,(.+?),$3,/i) | %reg = $regex($1,%reg) | return $regml($4) }
alias -l img_download {
  if ($regex(par,$1,/^(-[uakmos]{1,6})/i)) {
    var %flgs = $regml(par,1)
    if (a isin %flgs) && (u isin %flgs) { var %a = $2, %u = $3, %1 = $4, %2- $5- }
    elseif (a isin %flgs) { var %a = $2, %1 = $3, %2- $4- }
    elseif (u isin %flgs) { var %a = $2, %1 = $3, %2- $4- }
    else { var %1 = $2, %2- $3- }
  }
  else { var %1 = $1, %2- = $2- }
  if ($regex(img,%1,/^((?:https?://)((?:www.)?[^/]*)(.*/([^/]*\.(jpg|gif|bmp|png))))$/i)) && (%2-) {
    var %f = $qt(%2-)    
    if (k isin %flgs)  {
      if ($nofile(%f) == $noqt(%f)) { var %f = $qt($noqt(%f) $+ $regml(img,4)) }
      else { echo -qeag * /img_download: Invalid Directory Name. | halt }
    }
    if ($exists(%f)) && (o !isin %flgs) { echo -eqag * /imgfile: %f Already Exists. | halt }
    if (!$exists($nofile(%f))) && (m !isin %flgs) { echo -eqag * /img_download: $qt($nofile(%f)) Directory Does Not Exist. | halt }
    if ($right($noqt(%f),3) != $regml(img,5)) { echo -qeag * /img_download: Invalid File Name. | halt }
    else {
      var %x = imgdl_ $+ $right($nopath($regml(img,1)),50)
      hadd -m %x full $regml(img,1)
      hadd %x host $regml(img,2)
      hadd %x get $regml(img,3)
      hadd %x dlfile $regml(img,4)
      hadd %x file %f
      hadd %x time $ticks
      if (%flgs) { hadd %x flgs %flgs }
      if (%a) hadd %x alias %a
      if (%u) hadd %x update %u
      .sockclose %x
      .sockopen %x $hget(%x,host) 80
    }
  }
  else echo -qeag * /img_download: Invalid Parameters.
}
on *:sockopen:imgdl_*:{
  if ($sockerr) { img_fail $sockname }
  else {
    sockwrite -n $sockname GET $hget($sockname,get) HTTP/1.1 
    sockwrite -n $sockname Host: $hget($sockname,host)
    sockwrite -n $sockname
  } 
}
on *:sockread:imgdl_*:{ 
  if ($sockerr) { img_fail $sockname }
  if (!$sock($sockname).mark) { 
    var %x = $true  
    while (%x) { 
      sockread %x
      if ($regex(%x,/^Content-Length: (\d+)$/i)) { hadd $sockname size $regml(1) }
      if ($regex(%x,/^Content-Type: (.*)$/i)) { if (!$regex($regml(1),/^image/.*$/)) { img_fail $sockname | halt } } 
      sockmark $sockname $true 
    }
  }
  else {
    while ($sock($sockname).rq) {
      sockread &img
      noop $hget($sockname,bvar,&temp) 
      bcopy &temp $calc($bvar(&temp,0) + 1) &img 1 -1
      var %size = $bvar(&temp,0)    
      hadd -b $sockname bvar &temp
      if (%size == $hget($sockname,size)) img_close
      else { if ($hget($sockname,update)) { $v1 %size $hget($sockname,size) $calc($ticks - $hget($sockname,time)) $hget($sockname,full) $hget($sockname,file) } }
    }  
  }
}
alias -l img_close {
  var %mz = $calc($ticks - $hget($sockname,time)), %size = $bvar(&temp,0) 
  if (o isin $hget($sockname,flgs)) .remove $hget($sockname,file)
  if (m isin $hget($sockname,flgs)) .mkdir $nofile($hget($sockname,file)) 
  bwrite $hget($sockname,file) -1 -1 &temp    
  if (s isin $hget($sockname,flgs)) {
    var %s = $calc(($ticks - $hget($sockname,time)) / 1000), %sz = $calc($bvar(&temp,0) / 1024) 
    echo -eag Downloaded $hget($sockname,file) ( $+ $round(%sz,2) kb $+ ) Took %s Seconds at $round($calc(%sz / %s ),2) kbps 
  }
  if (r isin $hget($sockname,flgs)) { run $hget($sockname,file) }
  if ($hget($sockname,alias)) { $v1 $hget($sockname,full) %mz %size $pic($hget($sockname,file)).width $pic($hget($sockname,file)).height $hget($sockname,file) }
  hfree $sockname
  sockclose $sockname
  inc %maplez
  if (%maplez == $hget(MapleFiles,0).item) {
    dialog -x wait wait
    did -e maple 1-5
  }
}
alias -l img_fail {
  if ($sock($1)) sockclose $1
  if ($hget($1,alias)) { $v1 $hget($sockname,full) }
  hfree $1
}

;EOF

Comments

Sign in to comment.
Feety   -  Apr 19, 2009

I use to play MS. I want to kill myself for that.

 Respond  
Kirby   -  Apr 09, 2009

Seems like he used @windows...I had no idea that he actually posted one.

/me slaps ^Neptune around with a large trout

 Respond  
Firstmate   -  Apr 09, 2009

TheImrac actually posted an Image Downloading script
http://www.hawkee.com/snippet/5289/

 Respond  
^Neptune   -  Apr 09, 2009

Might wanna change the intro - it wasn't in a thread, but rather in PM on IRC. :P

 Respond  
FordLawnmower   -  Apr 09, 2009

Cool Kirby. I have a similar script that uses the icons in dialogs to put downloaded pictures in. I think it's the only way, unless you just make your dialogs in a picture window. Something I've also considered ;/

 Respond  
Kirby   -  Apr 08, 2009

94killerz:> >.> I wish I still played. This would be a neat script to have.
You played? Surprising to here that...I thought Blitz and I were the only ones, lol.

 Respond  
94killerz   -  Apr 08, 2009

.> I wish I still played. This would be a neat script to have.

 Respond  
Aucun50   -  Apr 08, 2009

That's crazy! Nice work

 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.