rendered paste bodyon *:text:*:#: {
set %nick $nick
set %secondcommand $2
set %thirdcommand $3
set %fourthcommand $4
tokenize 32 $strip($1-)
if ($left($1,1) !isin @!.) halt
if ($right($1,-1) !isnum) {
if ($right($1,-1) == stats) var %style = astats
elseif ($regex($1,/co?mb(at)?/Si)) var %style = combat
elseif ($setskill($remove($1,@,!,.))) var %style = istat, %skill = $setskill($remove($1,@,!,.))
elseif ($right($1,-1) == defname) && ($2) {
writeini DefRSN.ini RSNs $mask($fulladdress,3) $replace($2-,$chr(32),-)
.notice $nick You're default RSN for the host $mask($fulladdress,3) has been set to $2-
halt
}
else { halt }
inc %ID
if ($len($2-) > 12) {
$($+(%,stats.display.,%ID),2) The nick $2- is too long
cleanup %ID
halt
}
elseif ($2) {
if ($2 != `pc) {
set $+(%,stats.rsn.,%ID) $replace($2,$chr(32),-)
}
else {
if ($3) {
set $+(%,stats.rsn.,%ID) $replace($3-,$chr(32),-)
}
elseif ($readini(DefRSN.ini,RSNs,$mask($fulladdress,3))) set $+(%,stats.rsn.,%ID) $ifmatch
elseif ($readini(DefRSN.ini,RSNs,$nick)) set $+(%,stats.rsn.,%ID) $ifmatch
}
}
elseif ($readini(DefRSN.ini,RSNs,$mask($fulladdress,3))) set $+(%,stats.rsn.,%ID) $ifmatch
elseif ($readini(DefRSN.ini,RSNs,$nick)) set $+(%,stats.rsn.,%ID) $ifmatch
else set $+(%,stats.rsn.,%ID) $nick
set $+(%,stats.style.,%ID) %style
set $+(%,stats.skill.,%ID) %skill
set $+(%,stats.display.,%ID) $iif($left($1,1) == @,msg $chan,notice %nick)
sockopen $+(stats.,%ID) hiscore.runescape.com 80
}
else { halt }
}
on *:sockopen:stats.*: {
var %id = $gettok($sockname,2,46)
sockwrite -n $sockname GET /lang/en/aff/runescape/hiscorepersonal.ws?user1= $+ $($+(%,stats.rsn.,%ID),2) HTTP/1.1
sockwrite -n $sockname Host: hiscore.runescape.com $+ $crlf $+ $crlf
}
on *:sockread:stats.*: {
sockread &Incoming
bwrite $sockname -1 -1 &Incoming
if ($bfind(&Incoming, 1, </html>).text) makehash $sockname
elseif ($bfind(&Incoming, 1, does not feature in the hiscores.).text) {
$($+(%,stats.display.,%ID),2) (The nick) $c2($($+(%,stats.rsn.,%ID),2)) (Does not appear in the hiscores)
cleanup $gettok($sockname,2,46)
}
}
alias -l makehash {
var %file = $1
bread %file 1 $file(%file).size &stats
var %currentstat, %x = 1
while (%x) {
var %x = $bfind(&stats,$calc(%x + 1),<a href="overall.ws?table=)
var %currentstat = $striptags($bvar(&stats,%x,200).text)
tokenize 10 %currentstat
hadd -m %file $1 $2 $3 $4 $xp2next($3,$4)
}
process %file
}
alias process {
var %table = $1, %id = $gettok($1,2,46), %x = 0, $&
%display = $($+(%,stats.display.,%ID),2), $&
%rsn = $($+(%,stats.rsn.,%ID),2), $&
%skill = $($+(%,stats.skill.,%ID),2), $&
%style = $($+(%,stats.style.,%ID),2), $&
%a = 1
;shit;
if (%style == astats) {
while (%x <= 23) {
tokenize 32 $hget(%table,$setskill(%x))
if ($2) var %statline = %statline $setskill(%x) 3 $2
inc %x
}
%display Stats for %rsn $+ :
%display %statline
}
elseif (%style == istat) {
if (!$hget(%table,%skill)) %display The nick %rsn does not appear in the hiscores for %skill
else {
tokenize 32 $hget(%table,%skill)
%display %skill stats for %rsn $+ :
%display Rank: 3 $1 Level:3 $bytes($2,b) Exp:3 $3 $&
$iif(%skill != Overall,(Exp to lvl) $calc($2 + 1) $+ :3 $bytes($4,b))
set %xptolvl $4
set %leveler $2
if ((`pc isin %secondcommand) || (`pc isin %thirdcommand) || (`pc isin %fourthcommand)) {
if ((%skill == attack) || (%skill == defence) || (%skill == strength) || (%skill == Prayer) || (%skill == Magic) || (%skill == Ranged) || (%skill == hitpoints)) {
if (%skill == Prayer) {
set %xpperpoint $calc((%leveler * %leveler) / 12)
}
else {
set %xpperpoint $calc((%leveler * %leveler) / 6)
}
set %pointsneeded $calc(%xptolvl / %xpperpoint)
%display $chr(91) 7PEST CONTROL 1 $+ $chr(93) 5You need $bytes(%pointsneeded,b) single Pest Control Points to gain a level in %skill $+ .
}
else { %display $chr(91) 7PEST CONTROL 1 $+ $chr(93) 5The skill chosen must be a combat stat. }
}
else {
if (notice isin %display) {
if (%skill != Overall) {
unset %permline
set %file txt/ $+ %skill $+ .txt
set %amountoflines $lines(%file)
set %totallines $lines(%file)
set %a 2
if ((%amountoflines > 18) && (%amountoflines < 36)) {
set %amountoflines $calc(%amountoflines / 2)
while (%a <= %amountoflines) {
set %templine $read(%file, %a)
tokenize 61 %templine
set %divider $2
set %permline %permline 1 $1 :3 $bytes($calc(%xptolvl / %divider),b) $chr(124)
unset %templine
inc %a
}
%display %permline
unset %permline
set %amountoflines $calc(%amountoflines * 2)
while (%a <= %amountoflines) {
set %templine $read(%file, %a)
tokenize 61 %templine
set %divider $2
set %permline %permline 1 $1 :3 $bytes($calc(%xptolvl / %divider),b) $chr(124)
unset %templine
inc %a
}
%display %permline
unset %permline
}
elseif (%amountoflines > 37) {
set %amountoflines $calc(%amountoflines / 4)
set %fourthoflines %amountoflines
while (%a <= %amountoflines) {
set %templine $read(%file, %a)
tokenize 61 %templine
set %divider $2
set %permline %permline 1 $1 :3 $bytes($calc(%xptolvl / %divider),b) $chr(124)
unset %templine
inc %a
}
%display %permline
unset %permline
set %amountoflines $calc(%amountoflines + %fourthoflines)
while (%a <= %amountoflines) {
set %templine $read(%file, %a)
tokenize 61 %templine
set %divider $2
set %permline %permline 1 $1 :3 $bytes($calc(%xptolvl / %divider),b) $chr(124)
unset %templine
inc %a
}
%display %permline
unset %permline
set %amountoflines $calc(%amountoflines + %fourthoflines)
while (%a <= %amountoflines) {
set %templine $read(%file, %a)
tokenize 61 %templine
set %divider $2
set %permline %permline 1 $1 :3 $bytes($calc(%xptolvl / %divider),b) $chr(124)
unset %templine
inc %a
}
%display %permline
unset %permline
set %amountoflines $calc(%amountoflines + %fourthoflines)
while (%a <= %amountoflines) {
set %templine $read(%file, %a)
tokenize 61 %templine
set %divider $2
set %permline %permline 1 $1 :3 $bytes($calc(%xptolvl / %divider),b) $chr(124)
unset %templine
inc %a
}
%display %permline
unset %permline
}
else {
while (%a <= %amountoflines) {
set %templine $read(%file, %a)
tokenize 61 %templine
set %divider $2
set %permline %permline 1 $1 :3 $bytes($calc(%xptolvl / %divider),b) $chr(124)
unset %templine
inc %a
}
%display %permline
unset %permline
}
}
}
}
}
}
elseif (%style == combat) {
var %a.mult = .32707, %s.mult = .324, %d.mult = .249, %h.mult = .25, %p.mult = .124, %r.mult = .487, %m.mult = .487
var %a = $iif($gettok($hget(%table,Attack),2,32),$v1,-), $&
%s = $iif($gettok($hget(%table,Strength),2,32),$v1,-), $&
%d = $iif($gettok($hget(%table,Defence),2,32),$v1,-), $&
%h = $iif($gettok($hget(%table,Hitpoints),2,32),$v1,-), $&
%r = $iif($gettok($hget(%table,Ranged),2,32),$v1,-), $&
%m = $iif($gettok($hget(%table,Magic),2,32),$v1,-), $&
%p = $iif($gettok($hget(%table,Prayer),2,32),$v1,-)
var %meleecombat = $calc(%a * %a.mult + %s * %s.mult + %d * %d.mult + %h * %h.mult + %p * %p.mult), $&
%RangedCombat = $calc(%r * %r.mult + %p * %p.mult + %d * %d.mult + %h * %h.mult), $&
%MagicCombat = $calc(%m * %m.mult + %p * %p.mult + %d * %d.mult + %h * %h.mult)
if (%MagicCombat == %RangedCombat) && (%MagicCombat == %RangedCombat) {
var %cmbstyle = Balanced, %combat = %MeleeCombat
}
elseif (%MagicCombat > %RangedCombat) && (%MagicCombat > %MeleeCombat) var %cmbstyle = Magic, %Combat = %MagicCombat
elseif (%RangedCombat > %MeleeCombat) var %cmbstyle = Ranged, %Combat = %RangedCombat
else var %cmbstyle = melee, %combat = %MeleeCombat
var %cmb.temp = $abs($calc($int($calc(%combat +1)) - %combat)), $&
%a.2lvl = $ceil($calc(%cmb.temp / %a.mult)), %s.2lvl = $ceil($calc(%cmb.temp / %s.mult)), $&
%d.2lvl = $ceil($calc(%cmb.temp / %d.mult)), %m.2lvl = $ceil($calc(%cmb.temp / %m.mult)), $&
%r.2lvl = $ceil($calc(%cmb.temp / %r.mult)), %p.2lvl = $ceil($calc(%cmb.temp / %p.mult))
if (%cmbstyle == magic) var %dynamic.2lvl = Magic:3 %m.2lvl
elseif (%cmbstyle == Ranged) var %dynamic.2lvl = Ranged:3 %r.2lvl
else var %dynamic.2lvl = Att:3 %a.2lvl Str:3 %s.2lvl
var %combat = $round(%combat,2), %next = $ceil(%combat)
%display %rsn is %combat %cmbstyle style combat
%display Attack:3 %a Defence:3 %d Strength:3 %s Hits:3 %h $&
Mage:3 %m Range:3 %r Pray:3 %p
if (%combat < 126) {
%display Levels for %next $+ : %dynamic.2lvl $&
Def/Hp:3 %d.2lvl Prayer:3 %p.2lvl
}
}
cleanup %id
}
alias -l cleanup {
unset $+(%,stats.*.,$1)
sockclose $+(Stats.,$1)
.remove $+(Stats.,$1)
}
alias -l xp {
var %x = 1, %level = $calc($1 - 1), %xp = 0
while (%x <= %level) {
var %TempXp = $calc((%x + 300 * 2^(%x / 7)) /4)
inc %xp %TempXp
inc %x
}
return $int(%xp)
}
alias -l xp2Next {
var %xp = $remove($2,$chr(44)), %nextxp = $xp($calc($1 + 1))
return $calc(%nextxp - %xp)
}
alias -l striptags { var %x,%y = $regsub($1-,/(<[^>]+>)/g,$null,%x) | return %x }
alias -l setskill {
if ($1 == 0) || ($regex($1,/^(st|(skill)?total|overall)$/Si)) return Overall
elseif ($1 == 1) || ($regex($1,/^at(t|k|tack)$/Si)) return Attack
elseif ($1 == 2) || ($regex($1,/^def(en[cs]e)?$$/Si)) return Defence
elseif ($1 == 3) || ($regex($1,/^str(ength)?$/Si)) return Strength
elseif ($1 == 4) || ($regex($1,/^hp|hit(s|points?)?$/Si)) return Hitpoints
elseif ($1 == 5) || ($regex($1,/^range(r|d|ing)?$/Si)) return Ranged
elseif ($1 == 6) || ($regex($1,/^Pray(er)?$$/Si)) return Prayer
elseif ($1 == 7) || ($regex($1,/^mag(e|ic)$$/Si)) return Magic
elseif ($1 == 8) || ($regex($1,/^cook(ing)?$/Si)) return Cooking
elseif ($1 == 9) || ($regex($1,/^wc|wood(cut(ting)?)?$/Si)) return Woodcutting
elseif ($1 == 10) || ($regex($1,/^fletch(ing)?$/Si)) return Fletching
elseif ($1 == 11) || ($regex($1,/^fish(ing)?$/Si)) return Fishing
elseif ($1 == 12) || ($regex($1,/^(fire|fm)(make?(ing)?|ing)?$/Si)) return Firemaking
elseif ($1 == 13) || ($regex($1,/^craft(ing)?$/Si)) return Crafting
elseif ($1 == 14) || ($regex($1,/^(smith|smelt)(ing)?$/Si)) return Smithing
elseif ($1 == 15) || ($regex($1,/^min(e|ing)?$/Si)) return Mining
elseif ($1 == 16) || ($regex($1,/^herb(law|lore)?$/Si)) return Herblore
elseif ($1 == 17) || ($regex($1,/^agil(ity)?$/Si)) return Agility
elseif ($1 == 18) || ($regex($1,/^(th(ei|ie)[fv](e|ing)?)$/Si)) return Thieving
elseif ($1 == 19) || ($regex($1,/^slay(er|ing)?$/Si)) return Slayer
elseif ($1 == 20) || ($regex($1,/^rc|runecraft(ing|er)?$/Si)) return Runecraft
elseif ($1 == 21) || ($regex($1,/^farm(er|ing)?$/Si)) return Farming
elseif ($1 == 22) || ($regex($1,/^con(struct|struction)?$/Si)) return Construction
elseif ($1 == 23) || ($regex($1,/^hunt(er|ing)?$/Si)) return Hunter