mIRC Home    About    Download    Register    News    Help

Print Thread
#203313 11/08/08 08:42 PM
Joined: Mar 2008
Posts: 47
N
nok Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Mar 2008
Posts: 47
As should create an alias to give voice to the top 10 nicknames...
The list is updated, the idea is to go by removing those who are no longer part of it
Code:
alias vopnick {
  var %i 1
  while (%i <= 10) { if ( $nick(%channel,%i,v) = $gettok($read(score.txt,%i),1,32)) { .mode # +v $nick } 
    else { .mode %channel -v $nick(%channel,%i,v) }
    inc %i
  } 
  var %i 1
  while (%i <= $nick(%channel,0,r)) { if ( $nick(%channel,%i,r) = $gettok($read(score.txt,%i),1,32)) { .mode # +v $nick } 
    inc %i
  }
}
I have many errors?

nok #203319 11/08/08 11:39 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
If you go to voice a nick that is already voiced, then it won't make any difference.
Here's my suggestion for your alias
Code:
alias vopnick {
  var %a = 1, %b = $nick(%channel,0,v), %vnicks.1, %vnicks.2
  while %a <= %b {
    if %a <= 10 {
      if $gettok($read(score.txt,%i),1,32) !isvoice %channel {
        %vnicks.1 = $addtok(%vnicks.1,$v1,32)
        if $numtok(%vnicks.1,32) == $modespl {
          .mode %channel $+(+,$str(v,$modespl)) %vnicks.1
          var %vnicks.1
        }
        if %vnicks.1 {
          .mode %channel $+(+,$str(v,$modespl)) %vnicks.1
          var %vnicks.1
        }
      }
    }
    else {
      %vnicks.2 = $addtok(%vnicks.2,$nick(%channel,%a,v),32)
      if $numtok(%vnicks.2,32) == $modespl {
        .mode %channel $+(-,$str(v,$modespl)) %vnicks.2
        var %vnicks.2
      }
      if %vnicks.2 {
        .mode %channel $+(-,$str(v,$modespl)) %vnicks.2
        var %vnicks.2
      }
    }
    inc %a
  }
}

While the alias is a fair bit longer, it will keep the number of mode sets to a minimum. Setting too many modes in a short period of time can get you flooded off of the server.

nok #203356 12/08/08 07:22 PM
Joined: Sep 2007
Posts: 109
K
Vogon poet
Offline
Vogon poet
K
Joined: Sep 2007
Posts: 109
Code:
alias vopnick {
  var %a = 1, %b = 1, %c = 1
  while %a <= 10 { 
    var %list = $addtok(%list,$gettok($read(score.txt,%a),1,32),44) 
    inc %a
  }
  while %b <= $nick(%channel,0,r) {
    if $istok(%list,$nick(%channel,%b,r),44) { mode %channel +v $nick(%channel,%b,r) }
    inc %b
  }
  while %c <= $nick(%channel,0,v) {
    if !$istok(%list,$nick(%channel,%c,v),44) { mode %channel -v $nick(%channel,%c,v) }
    inc %c
  }
}


kwell #203364 12/08/08 11:13 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The main point of my code wasn't to have it short, but to minimize the number of mode changes sent to the server. If $modespl was 10, then only one mode change command is sent to the server to voice all 10 of the nicks, as with yours, there would be a mode change command sent for each nick, so 10 nicks means 10 commands.

RusselB #203369 13/08/08 02:36 AM
Joined: Mar 2008
Posts: 47
N
nok Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Mar 2008
Posts: 47
brings problems with nicknames that are listed and not the channel, does not detract from the voice to users who are no longer on the list eek

nok #203370 13/08/08 03:32 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Hmmm.. ok , give this a try. It's hard for me to test as I don't have the text file that you're referencing.
Code:
alias vopnick {
  var %a = 1, %b = $nick(%channel,0,v), %voiced
  while %a <= %b {
    %voiced = $addtok(%voiced,$nick(%channel,%a,v),32)
    inc %a
  }
  %a = 1
  while %a <= 10 {
    var %vnick = $gettok($read(scores.txt,%a),1,32)
    if $istok(%voiced,%vnick,32) {
      %voiced = $remtok(%voiced,%vnick,1,32)
    }
    else {
      %vnicks = $addtok(%vnicks,%vnick,32)
    }
    inc %a
  }
  while %vnick {
    .mode %channel $+(-,$str(v,$modespl)) $gettok(%vnick,1- $+ $modespl,32)
    %vnick = $deltok(%vnick,1- $+ $modespl,32)
  }
  while %vnicks {
    .mode %channel $+(+,$str(v,$modespl)) $gettok(%vnicks,1- $+ $modespl,32)
    %vnicks = $deltok(%vnicks,1- $+ $modespl,32)
  }
}

RusselB #203390 13/08/08 10:28 PM
Joined: Mar 2008
Posts: 47
N
nok Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Mar 2008
Posts: 47
Sorry RusselB blush
Code:
score.txt
nick-01 7687
nick-02 4563
nick-03 453
nick-04 127
nick-05 77
nick-06 77
nick-07 53
nick-08 47
nick-09 46
nick-10 25
nick-11 23
nick-12 4
Kwell your code works but has reason RusselB


Link Copied to Clipboard