mIRC Home    About    Download    Register    News    Help

Print Thread
#143950 03/03/06 07:21 PM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
hi all,

Riamus made me this alias that colors the nicks I type in the room.
my question is now how to let the nick come back as a rainbow with every letter its own color.

Code:
 alias colornicks {
  ; Set variables.
  var %c = 1,%text = $1-,%i = $gettok(%text,0,32)
  ; Loop through each "word."
  while (%c <= %i) {
    var %nick = $gettok(%text,%c,32)
    ; Remove certain symbols from the end of the current word.
    ; This allows you to match "Riamus" and "Riamus." for example.
    ; Add/Remove symbols if necessary.  Note that a nick can't end in these or it won't be colored.
    while ($right(%nick,1) == : || $right(%nick,1) == - || $right(%nick,1) == $chr(44) || $right(%nick,1) == . || $right(%nick,1) == ! || $right(%nick,1) == $chr(63)) {
      var %nick = $left(%nick,-1)
    }
    ; Check if the nick is on the channel or you are in a query or chat with the nick.
    if (%nick ison $chan || %nick == $active) {
      ; Replace the nick with a colored version.
      ; If the nick is the first word, it will put brackets around it.  Otherwise, just color it.
      if (%c != 1) {
        var %text = $reptok(%text,$gettok(%text,%c,32),$replacex($gettok($1-,%c,32),%nick,05 $+ $left(%nick,1) $+ 02 $+ $right(%nick,-1) $+ ),32)
      }
      else {
        var %text = $reptok(%text,$gettok(%text,%c,32),$replacex($gettok($1-,%c,32),$gettok($1-,%c,32),05 $+ $left(%nick,1) $+ 02 $+ $right(%nick,-1) $+ :),32)
      }
    }
    inc %c
  }
  ; Return text to calling script.
  return %text
}

#143951 03/03/06 11:29 PM
Joined: Aug 2005
Posts: 525
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Give this a try. It makes the nicks random colors. Also, each instance of the nick in the text will be colored differently.

$_strip will remove any common symbols/punctuation except for those that are allowed in nicks. (e.g: ` [ ] { } etc)

Edit: Fixed case matching.

Code:
alias _strip return $remove($1,$chr(33),$chr(34),$chr(35),$chr(36),$chr(37),$chr(38),$chr(39),$chr(40),$chr(41),$chr(42),$chr(43),$chr(44),$chr(46),$chr(47),$chr(58),$chr(59),$chr(60),$chr(61),$chr(62),$chr(63),$chr(64))

alias getnicks {
  if ($active ischan) {
    var %i = 1, %n = $nick($active,0)
    while (%i <= %n) {
      set %n2 %n2 $nick($active,%i)
      inc %i
    }
  }
}

alias clrnick {
  var %i = 1, %t = $_strip($1-), %n = $numtok($1-,32), %nick
  getnicks
  while (%i <= %n) {
    if ($istok(%n2,$gettok(%t,%i,32),32)) {
      %nick = $gettok(%n2,$findtok(%n2,$gettok(%t,%i,32),32),32)
      %t = $reptok(%t,$gettok(%t,%i,32),$rc(%nick),32))
    }
    inc %i
  }
  unset %n2
  return %t
}

alias rc {
  var %r, %t
  var %t2 = $1, %l = $len($1), %i = 1
  while (%i <= %l) {
    %r = $r(0,15)
    if (%r < 10) { %r = 0 $+ %r }
    %t = $+(%t,,%r,$mid(%t2,%i,1))
    inc %i
  }
  %t = $+(%t,)
  return %t
}

Last edited by schaefer31; 03/03/06 11:55 PM.
#143952 04/03/06 08:07 AM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
works great schaefer31.
to great ... all words are rainbow colors now grin
or could this be because i use it with my acronym maneger ?
the on input looks like this nowwith your code:

Code:
 on *:INPUT:*: { if ($isalias(fcomp.handle)) { if (($nice.cload(en_fcomp)) && (@* !iswm $active)) tokenize 32 $fcomp.handle($1-) } 
  if ($Left($1,1) != /) && (!$Ctrlenter) && ($Active != Status Window) && ($Status == connected) {
    .var %a = $0
    If ($Hget(TempText)) { .hfree TempText }
    .hmake TempText 1
    While (%a) {
      if ($Hget(AcroManager, $Gettok($1-, %a, 32))) { .hadd TempText TempText $Hget(AcroManager, $Gettok($1-, %a, 32)) $Hget(TempText, TempText) }
      Else { .hadd TempText TempText $Gettok($1-, %a, 32) $Hget(TempText, TempText) }
      .dec %a
    }
    msg $active $rc($Hget(TempText, TempText))
    halt         
  }
}
 

oooopppsss never mind found it blush
code should be like this:
Code:
 on *:INPUT:*: { if ($isalias(fcomp.handle)) { if (($nice.cload(en_fcomp)) && (@* !iswm $active)) tokenize 32 $fcomp.handle($1-) } 
  if ($Left($1,1) != /) && (!$Ctrlenter) && ($Active != Status Window) && ($Status == connected) {
    .var %a = $0
    If ($Hget(TempText)) { .hfree TempText }
    .hmake TempText 1
    While (%a) {
      if ($Hget(AcroManager, $Gettok($1-, %a, 32))) { .hadd TempText TempText $Hget(AcroManager, $Gettok($1-, %a, 32)) $Hget(TempText, TempText) }
      Else { .hadd TempText TempText $Gettok($1-, %a, 32) $Hget(TempText, TempText) }
      .dec %a
    }
    msg $active [color:red]$clrnick [/color] ($Hget(TempText, TempText))
    halt         
  }
}
 


and one question why remove all the characters ?

Last edited by Bullseye; 04/03/06 08:48 AM.
#143953 04/03/06 07:12 PM
Joined: Aug 2005
Posts: 525
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Oops, sorry the $_strip was only meant to remove those from the nick and not all of the text, that way it works with 'nick' or 'nick!' or 'nick?'

Here's the correction to it, just replace the clrnick alias. Also I included a simple on input event to show how it works.

Code:
alias clrnick {
  var %i = 1, %t = $1-, %n = $numtok($1-,32), %nick
  getnicks
  while (%i <= %n) {
    if ($istok(%n2,$gettok(%t,%i,32),32)) {
      %nick = $gettok(%n2,$findtok(%n2,$gettok(%t,%i,32),32),32)
      %t = $reptok(%t,$gettok(%t,%i,32),$rc($_strip(%nick)),32))
    }
    inc %i
  }
  unset %n2
  return %t
}

on *:INPUT:#:{
  msg # $clrnick($1-)
  haltdef
}

#143954 05/03/06 10:20 AM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
thank you


Link Copied to Clipboard