mIRC Homepage
Hi,

This script (also a talker..) colors the nick I'm saying when it is the first word of my sentence. But I want to have it that whenever I say a nick, so not only when I say "Chloe how are you" but also when I say "how are you Chloe" that the nick (ison $active) also then gets colored with the alias 'randc' (included.)

This is the code, I let the first part out because that's the part of the talker. Which isnt needed here. This part is the part of the colored nick.


Code:
  if ($1 ison $active) { 
    if (/* !iswm $1-) && (!$ctrlenter) && (!$inpaste) {
      if ($len($1) == 1) { 
        halt
      }
      else {
        inc %teller
        msg $active 13,1«4»13.4.13|4|13¤ $randc($1) $+ 00 $2- 6¤4|13|4.13.4«13»
        halt
      }
      halt
    }
  }
}

alias randc {
  var %cols = 4 7 8 9 11 12 13
  return $regsubex($strip($$1-),/(\S)/g,$+($chr(3),$base($gettok(%cols,$rand(1,$numtok(%cols,32)),32),10,10,2),\t))
}




Note: %teller is from the other talker. It aint a problem here.
hi
u have to loop all words like
E.G:
Code:
var %x $0
while %x {
  if ($gettok($1-,%x,32) ison #) randc $v1
  dec %x
}
You have to loop through every word.

Code:
  var %c = 1, %t = $0
  while (%c <= %t) {
    if ($gettok($1-,%c,32) ison $active) {
      var %message = %message $randc($gettok($1-,%c,32))
      var %ison.check = 1
    }
    else { var %message = %message $gettok($1-,%c,32) }
    inc %c
  } 
  if (%ison.check == 1) {
    if (/* !iswm $1-) && (!$ctrlenter) && (!$inpaste) {
      if ($len($1) != 1) { 
        inc %teller
        msg $active 13,1«4»13.4.13|4|13¤ %message 6¤4|13|4.13.4«13»
      }
      halt
    }
  }
}


That should do it. As a note, you may want to strip out punctuation before checking if the word is a nick on the channel and then put it back in the message afterwards.
the variable %ison.check is not a good idea because if he have 2 nicks that will not work
and overall, this code has always had a problem
because if a Nickname contain numbers the code will return just the letters
Hi,

Tried it but it still does the same thing. Just colored the nick while its the first word. frown


EDIT: Sorry, my bad. Forgot to remove old script.
Thanks! Works!:D
2 nicks isn't a problem. They will all be colored. The check is because he originally had a check to only do the special output if a nick ison the channel, so it's there for the same reason.

If the nick contains numbers, it will still check the entire nick and include the entire nick in the %message.
replace %var == 1 by only %var

so
Code:
if (%ison.check) {...}

Sure, it can be done, but it doesn't matter.
© mIRC Discussion Forums