mIRC Home    About    Download    Register    News    Help

Print Thread
#187956 15/10/07 06:51 PM
Joined: Feb 2007
Posts: 91
S
spermis Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Feb 2007
Posts: 91
Could someone make a script that will read info and show in channel?

what i need:
when someone type !map mapname it will show info about the map.

In the webpage for each map there is a line like this:

ak_rh_warehouse_ns D3v1L 07:35 99.99 Download

ak_rh_warehouse_ns - mapname
D3v1L - player
07:35 - time
99.99 - fps
Download - link to file

so if someone types !map ak_rh_warehouse_ns it will show :

ak_rh_warehouse_ns was done in 07:35 by D3v1L. FPS - 99.99. Link: http://linktofile

To see live this webpage go here: http://trick-jumps.lv/index.php?site=rekordi

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Originally Posted By: spermis
Could someone make a script that will read info and show in channel?

what i need:
when someone type !map mapname it will show info about the map.

In the webpage for each map there is a line like this:

ak_rh_warehouse_ns D3v1L 07:35 99.99 Download

ak_rh_warehouse_ns - mapname
D3v1L - player
07:35 - time
99.99 - fps
Download - link to file

so if someone types !map ak_rh_warehouse_ns it will show :

ak_rh_warehouse_ns was done in 07:35 by D3v1L. FPS - 99.99. Link: http://linktofile

To see live this webpage go here: http://trick-jumps.lv/index.php?site=rekordi


Here you go, You will first need someone in channel to type !update and wait about 20 seconds, once done !save. Once your done you can !map mapnamehere and it will load map.

Now everytime you want to update from the site type !update it will look online otherwise its whats current on file.

Also change #yourchannel in the On text event.

Code:
alias parses { 
  if (!$hget(parses)) { 
     hmake parses 800 
   sockopen parses trick-jumps.lv 80 
}
}
alias parses_r {
  if ($hget(parses)) {
    var %x = 1
    while (%x <= $hget(parses,0).item) {
      .write parses.txt %x $hget(parses,%x).item $crlf
      inc %x
    }
  }
  else { echo -a FAILED ONLINE CONNECTION/OR FILE WASNT UPDATED! }
}

on 1:sockopen:parses:{
  .sockwrite -n parses GET /index.php?site=rekordi HTTP/1.1
  .sockwrite -n parses HOST: trick-jumps.lv
  .sockwrite -n parses $crlf
}

on 1:sockread:parses:{
  if ($sockerr > 0) return 
  var %x | sockread %x
  if ($sockbr == 0)  return 
  if (%x == $null) { return 2 } 
  if (iframe isin %x) || (% isin %x) || (cellpadding isin %x) { return }
  if ($regex(%x,/\b(40|350|100|nogravity.netgames.lv/records)\b/i) == 1) { 
    if (350 isin %x) { var %i $remove(%x,<td,width=350><b>,</b></td>,$chr(32)) | %parses = %i }
    elseif (100 isin %x) { var %k $remove(%x,<td,width=100>,</td>,$chr(32)) | %parses = %parses by %k } 
    elseif (40 isin %x) && (!%ps) { var %l $remove(%x,<td,width=40>,<b>,</b>,</td>,$chr(32)) | %ps = 1 | %parses = $instok(%parses,was done in %l,2,32) }
    elseif (40 isin %x) && (%ps) { var %m $remove(%x,<td,width=40>,<b>,</b>,</td>,$chr(32)) | unset %ps | %parses = %parses FPS %m }
    elseif (records isin %x) { var %n $remove(%x,<td><a href=","><b>Download</b></a></td>) | .hadd parses $replace(%parses,_,$chr(95)) Link: %n  }
  }
}

on *:TEXT:*:#channel:{ 
  if ($1 == !update) { parses }
  elseif ($1 == !load) {  
    if ($exists(parses.hsh)) { hmake parses 400 | hload parses parses.hsh }
    else { echo -a NOTHING TO LOAD, parses.hsh does not exists }
  }
  elseif ($1 == !map) { .remove parses.txt | parses_r | .timerparses 1 3 /var %b $gettok($read(parses.txt,nw,$+(*,$2,*)),1,32) | .timer 1 4 /msg # $hget(parses,%b).item $hget(parses,%b).data }
  elseif ($1 == !save) { 
    if ($exists(parses.hsh)) { .remove parses.hsh | hsave parses parses.hsh }
  }
}


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Feb 2007
Posts: 91
S
spermis Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Feb 2007
Posts: 91
hmm i type !update, wait 20 seconds, then type !save, then type !map kz_5trees and nothing happens. when typing !load it shows in bot - NOTHING TO LOAD, parses.hsh does not exists

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Very sorry about that I forgot to include else statement in save.

Here's the updated version

Code:
alias parses { 
  if (!$hget(parses)) { 
     hmake parses 800 
   sockopen parses trick-jumps.lv 80 
}
else { hfree parses | hmake parses 800 | sockopen parses trick-jumps.lv 80 }
}
alias parses_r {
  if ($hget(parses)) {
    var %x = 1
    while (%x <= $hget(parses,0).item) {
      .write parses.txt %x $hget(parses,%x).item $crlf
      inc %x
    }
  }
  else { echo -a FAILED ONLINE CONNECTION/OR FILE WASNT UPDATED! }
}

on 1:sockopen:parses:{
  .sockwrite -n parses GET /index.php?site=rekordi HTTP/1.1
  .sockwrite -n parses HOST: trick-jumps.lv
  .sockwrite -n parses $crlf
}

on 1:sockread:parses:{
  if ($sockerr > 0) return 
  var %x | sockread %x
  if ($sockbr == 0)  return 
  if (%x == $null) { return 2 } 
  if (iframe isin %x) || (% isin %x) || (cellpadding isin %x) { return }
  if ($regex(%x,/\b(40|350|100|nogravity.netgames.lv/records)\b/i) == 1) { 
    if (350 isin %x) { var %i $remove(%x,<td,width=350><b>,</b></td>,$chr(32)) | %parses = %i }
    elseif (100 isin %x) { var %k $remove(%x,<td,width=100>,</td>,$chr(32)) | %parses = %parses by %k } 
    elseif (40 isin %x) && (!%ps) { var %l $remove(%x,<td,width=40>,<b>,</b>,</td>,$chr(32)) | %ps = 1 | %parses = $instok(%parses,was done in %l,2,32) }
    elseif (40 isin %x) && (%ps) { var %m $remove(%x,<td,width=40>,<b>,</b>,</td>,$chr(32)) | unset %ps | %parses = %parses FPS %m }
    elseif (records isin %x) { var %n $remove(%x,<td><a href=","><b>Download</b></a></td>) | .hadd parses $replace(%parses,_,$chr(95)) Link: %n  }
  }
}

on *:TEXT:*:#channel:{ 
  if ($1 == !update) { parses }
  elseif ($1 == !load) {  
    if ($exists(parses.hsh)) { hmake parses 400 | hload parses parses.hsh }
    else { echo -a NOTHING TO LOAD, parses.hsh does not exists }
  }
  elseif ($1 == !map) { .remove parses.txt | parses_r | .timerparses 1 3 /var %b $gettok($read(parses.txt,nw,$+(*,$2,*)),1,32) | .timer 1 4 /msg # $hget(parses,%b).item $hget(parses,%b).data }
  elseif ($1 == !save) { 
    if ($exists(parses.hsh)) { .remove parses.hsh | hsave parses parses.hsh }
else { hsave parses parses.hsh }
  }
}


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Feb 2007
Posts: 91
S
spermis Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Feb 2007
Posts: 91
Hm now it creates pareses.hsh in mirc folder, but theres nothing in it, and it doesnt show anything when type !map mapname ..

Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Here's a different way of going about it, the page is auto-downloaded (max once per 30 mins), no need to !update/!load/!save.

Code:
on *:text:!map &:#:map.show $2
on *:sockopen:map.lv:{
  if $sockerr { echo -aecti info * Socket error $+(",$sockname,":) $sock($sockname).wsmsg | return }
  sockwrite -n $sockname GET /index.php?site=rekordi HTTP/1.1
  sockwrite -n $sockname Host: trick-jumps.lv
  sockwrite $sockname Connection: Close $+ $str($crlf,2)
}
on *:sockread:map.lv:sockread &a | bwrite map.lv.tmp -1 -1 &a
on *:sockclose:map.lv:if $file(map.lv.tmp) { .remove map.lv | .rename map.lv.tmp map.lv }
alias get.map {
  var %a,%b
  .fopen lv map.lv
  .fseek -w lv $+(*,$$1,*)
  if $ferr || $feof { .fclose lv | return Error: map $qt($1) not found. }
  while *</tr>* !iswm $fread(lv) { var %b = $v2,%a = %a $iif($htmlconv(%b) == Download,$gettok(%b,2,34),$v1) }
  .fclose lv
  if **:** isin %a { return $1 has not been completed. }
  tokenize 32 %a
  return $1 was done in $3 by $2. FPS: $4. Link: $5
}
alias -l map.show {
  if !$file(map.lv) || $calc($ctime - $file(map.lv).mtime) > 1800 {
    if !$sock(map.lv) { sockopen map.lv trick-jumps.lv 80 }
  }
  set -e %map.lv. $+ $1 # $1
  if !$timer(map.lv) { .timermap.lv 0 1 map.lv # }
}
alias map.lv {
  if $sock(map.lv) { return }
  if $var(map.lv.*,1).value {
    tokenize 32 $v1
    msg $$1 $get.map($2)
    unset $var(map.lv.*,1)
  }
  else .timermap.lv off
}
alias -l htmlconv return $remove($regsubex($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,),&,$chr(9))


To change how often you update from the site, adjust this line...
if !$file(map.lv) || $calc($ctime - $file(map.lv).mtime) > [color:red]1800 {[/color]
(1800 seconds = 30 mins)

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
I forgot to exclude some stuff when I released it to you that I did.. Also by testing it I had to fix a few Issues

Now type !update and wait 20 seconds, type !save and wait 20 seconds

Lets say you shutdown mIRC for whatever reason when you load her up you have the choice of !update for Online, or !load for whats on file already.

Now I did MapChecks if !map cg_w00tblock is typed and as per the site theres no record set, it will msg the channel no record set

But if an exists record is typed for the map it will display...
kz_man_eztemple was done in 99.21 by FoB FPS 08:43 Link: http://nogravity.netgames.lv/records/kz_man_eztemple_FoB

all one line...

here is the updated code

Code:
alias parses { 
  if (!$hget(parses)) { 
    hmake parses 800 
    sockopen parses trick-jumps.lv 80 
  }
  else { hfree parses | hmake parses 800 | sockopen parses trick-jumps.lv 80 }
}
alias parses_r {
  if ($hget(parses)) {
    var %x = 1
    while (%x <= $hget(parses,0).item) {
      .write parses.txt %x $hget(parses,%x).item $crlf
      inc %x
    }
  }
  else { echo -a FAILED ONLINE CONNECTION/OR FILE WASNT UPDATED! }
}

on 1:sockopen:parses:{
  .sockwrite -n parses GET /index.php?site=rekordi HTTP/1.1
  .sockwrite -n parses HOST: trick-jumps.lv
  .sockwrite -n parses $crlf
}

on 1:sockread:parses:{
  if ($sockerr > 0) return 
  var %x | sockread %x
  if ($sockbr == 0)  return 
  if (%x == $null) { return 2 } 
  if (iframe isin %x) || (% isin %x) || (cellpadding isin %x) { return }
  if ($regex(%x,/\b(40|350|100|nogravity.netgames.lv/records)\b/i) == 1) { 
    if (350 isin %x) { var %i $remove(%x,<td,width=350><b>,</b></td>,$chr(32)) | %parses = %i }
    elseif (100 isin %x) { var %k $remove(%x,<td,width=100>,</td>,$chr(32)) | %parses = %parses by %k } 
    elseif (40 isin %x) && (!%ps) { var %l $remove(%x,<td,width=40>,<b>,</b>,</td>,$chr(32)) | %ps = 1 | %parses = $instok(%parses,was done in %l,2,32) }
    elseif (40 isin %x) && (%ps) { var %m $remove(%x,<td,width=40>,<b>,</b>,</td>,$chr(32)) | unset %ps | %parses = %parses FPS %m }
    elseif (records isin %x) { var %n $remove(%x,<td><a href=","><b>Download</b></a></td>) | .hadd parses %parses Link: %n  }
  }
}

on *:TEXT:*:#channel:{ 
  if ($1 == !update) { parses | .remove parses.txt }
  elseif ($1 == !load) {  
    if ($exists(parses.hsh)) { hmake parses 400 | hload parses parses.hsh }
    else { echo -a NOTHING TO LOAD, parses.hsh does not exists }
  }
  elseif ($1 == !map) { 
    var %b2 = $2
    if ($exists(parses.txt)) { 
      var %b = $gettok($read(parses.txt,nw,$+(*,%b2,*)),1,32)
      if (!%b) { /msg #channel Map %b2 has no Record Set }
      else { .timer 1 5 /msg #channel $hget(parses,%b).item $hget(parses,%b).data }
    }
    else { 
      parses_r 
      var %b = $gettok($read(parses.txt,nw,$+(*,%b2,*)),1,32)
      if (!%b) { /msg #channel Map %b2 has no Record Set }
      else { .timer 1 5 /msg #channel $hget(parses,%b).item $hget(parses,%b).data }
    }
  }
  elseif ($1 == !save) { 
    if ($exists(parses.hsh)) { .remove parses.hsh | hsave parses parses.hsh }
    else { hsave parses parses.hsh }
  }
}


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Feb 2007
Posts: 91
S
spermis Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Feb 2007
Posts: 91
somehow it doesnt work Lpfix5.
it shows
[21:30:38] <~spermis> !map cg_w00tblock
[21:30:38] <&TJ-Bot> Map cg_w00tblock has no Record Set

and it shows that for all maps..

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Are you by any chance using Vista with mIRC 6.2? if so then vista wont let you write the file parses.txt to file.

Because I tested the script on 3 computers and it works as it should.


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Feb 2007
Posts: 91
S
spermis Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Feb 2007
Posts: 91
im using windows XP and mirc 6.21,
maybe try cope & paste from your .mrc file one more time?

Last edited by spermis; 16/10/07 07:05 PM.
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Ok, remember to !update and wait 20 seconds before !save then !map mapname

Code:
alias parses { 
  if (!$hget(parses)) { 
    hmake parses 800 
    sockopen parses trick-jumps.lv 80 
  }
  else { hfree parses | hmake parses 800 | sockopen parses trick-jumps.lv 80 }
}
alias parses_r {
  if ($hget(parses)) {
    var %x = 1
    while (%x <= $hget(parses,0).item) {
      .write parses.txt %x $hget(parses,%x).item $crlf
      inc %x
    }
  }
  else { echo -a FAILED ONLINE CONNECTION/OR FILE WASNT UPDATED! }
}

on 1:sockopen:parses:{
  .sockwrite -n parses GET /index.php?site=rekordi HTTP/1.1
  .sockwrite -n parses HOST: trick-jumps.lv
  .sockwrite -n parses $crlf
}

on 1:sockread:parses:{
  if ($sockerr > 0) return 
  var %x | sockread %x
  if ($sockbr == 0)  return 
  if (%x == $null) { return 2 } 
  if (iframe isin %x) || (% isin %x) || (cellpadding isin %x) { return }
  if ($regex(%x,/\b(40|350|100|nogravity.netgames.lv/records)\b/i) == 1) { 
    if (350 isin %x) { var %i $remove(%x,<td,width=350><b>,</b></td>,$chr(32)) | %parses = %i }
    elseif (100 isin %x) { var %k $remove(%x,<td,width=100>,</td>,$chr(32)) | %parses = %parses by %k } 
    elseif (40 isin %x) && (!%ps) { var %l $remove(%x,<td,width=40>,<b>,</b>,</td>,$chr(32)) | %ps = 1 | %parses = %parses FPS %l }
    elseif (40 isin %x) && (%ps) { var %m $remove(%x,<td,width=40>,<b>,</b>,</td>,$chr(32)) | unset %ps | %parses = $instok(%parses,was done in %m,2,32) }
    elseif (records isin %x) { var %n $remove(%x,<td><a href=","><b>Download</b></a></td>) | .hadd parses %parses Link: %n  }
  }
}

on *:TEXT:*:#channel:{ 
  if ($1 == !update) { parses | .remove parses.txt }
  elseif ($1 == !load) {  
    if ($exists(parses.hsh)) { hmake parses 400 | hload parses parses.hsh }
    else { echo -a NOTHING TO LOAD, parses.hsh does not exists }
  }
  elseif ($1 == !map) { 
    var %b2 = $2
    if ($exists(parses.txt)) { 
      var %b = $gettok($read(parses.txt,nw,$+(*,%b2,*)),1,32)
      if (!%b) { /msg #channel Map %b2 has no Record Set }
      else { .timer 1 5 /msg #channel $hget(parses,%b).item $hget(parses,%b).data }
    }
    else { 
      parses_r 
      var %b = $gettok($read(parses.txt,nw,$+(*,%b2,*)),1,32)
      if (!%b) { /msg #channel Map %b2 has no Record Set }
      else { .timer 1 5 /msg #channel $hget(parses,%b).item $hget(parses,%b).data }
    }
  }
  elseif ($1 == !save) { 
    if ($exists(parses.hsh)) { .remove parses.hsh | hsave parses parses.hsh }
    else { hsave parses parses.hsh }
  }
}


I will pm you an address you can come test it on to see it works


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Link Copied to Clipboard