Botscript / Rank list / ini file / top5

Release your script here.
State:
- Author
- What it does
- Perhaps a little guide.
- Also, if the snippet is of any use to the community, it has a chance of getting posted on the main page, so don't hesitate to submit/ask!

Botscript / Rank list / ini file / top5

Postby Cristian » Wed Mar 19, 2008 10:41 pm

Commando /top5 = return 5 variables, first variable is the highest in rank.
Tested and works on version 6.15

Code: Select all
xx.ini
[points]
*!*@host1.dk=7
*!*@host2.dk=43
*!*@host3.dk=234
*!*@host4.dk=213
*!*@host5.dk=34
*!*@host6.dk=464
*!*@host111.dk=34
*!*@host112.dk=45
*!*@host113.dk=3
*!*@host114.dk=458
*!*@host115.dk=86


Code: Select all
;# 
;# visit http://sp00fed.org for updates or support.
;# script by Sumsar
;#

alias -l source { return xx.ini }

alias top5 {   
  var %topls1 = 0, %topls2 = 0, %topls3 = 0, %topls4 = 0, %topls5 = 0, %z = $var(%topls*,0), %c = 1   
  while (%c <= %z) {     
    var %a = $ini($source,points,0)     
    while (%a) {   

      var %h = $ini($source,points,%a)       
      var %p = $readini($source,points,%h)

      if ($readini($source,points,%h) > $gettok($eval($var(%topls*,%c),2),1,32)) {           
        var %v = 0, %b = 1         
        while (%b <= %z) {           
          if ($gettok($eval($var(%topls*,%b),2),2,32) != %h) { inc %v }           
          inc %b         
        }         
        if (%v >= %z) { set $eval($var(%topls*,%c),1) %p %h }       
      }       
      dec %a     
    }     
    inc %c   
  }   
  echo -at Top5   
  echo -at 1. %topls1   
  echo -at 2. %topls2   
  echo -at 3. %topls3   
  echo -at 4. %topls4   
  echo -at 5. %topls5
}
Cristian
proof of advance
proof of advance
 
Posts: 282
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: Botscript / Rank list / ini file / top5

Postby Blady » Tue May 12, 2009 5:58 pm

Hmm, I think I got something simple (Hello everyone btw)

With the same .ini as you :

Code: Select all
alias top5 {
  var %source = xx.ini
  var %tempfile = xx.txt
  var %rankfile = rank.txt

  ;; make a temp file like :
  ;; pointA hostA
  ;; pointB hostB
  ;; ...
  var %i = 1 | while ($ini(%source,points,%i)) { var %h = $v1, var %points = $readini(%source,points,%h) | write %tempfile %points %h | inc %i }

  ;; Use the /filter command (much more faster)
  ;; The result will be written in the %rankfile
  filter -tffeu 1 32 %tempfile %rankfile
 
  ;; display top5
  var %i = 1 | while (%x <= 5) { echo -ag %x $+ . $read(%rankfile,%x) | inc %i }
}



Have fun! :)
Blady
 


Return to Mirc Scripting Release

Who is online

Users browsing this forum: No registered users and 1 guest

cron