mIRC Home    About    Download    Register    News    Help

Topic Options
#257384 - 03/04/16 06:11 PM Randomly colorized usernames
eliminat Offline
Mostly harmless

Registered: 03/04/16
Posts: 1
Hello,

I like to have to usernames in chat randomly colored, especially in large chat rooms, as it makes reading and separating lines easier for me. Other IRC clients seem to have this feature, but I always end up returning to mIRC, where I've never found this ability.
I know I can manually color names, but in active rooms with dozens of people or more this isn't practical. So far the only way I've found is by using a script such as:

Code:
on ^*:text:*:#:{
if ($cnick($nick).color == $color(normal text)) { 
  .cnick $nick $gettok(%colors,$calc(%currentcolor),32)
  if (%currentcolor == $gettok(%colors,0,32)) { 
    set %currentcolor 1
  }
  else {
    inc %currentcolor
  }
}
}


The downside is this will add the nickname and its now permanently assigned color to mirc.ini. This is a problem because when mirc.ini gets above a few KB, it greatly increases mIRC's loading speed. I've had the filesize get to 5 MB before, and right now it's back to 2.5 MB. This results in an mIRC loading time of a few minutes instead of a few seconds. Using ProcMon I can see mIRC repeatedly reading from mIRC during this time which further confirms the long load is mIRC trying to fully read the mIRC.ini file.

Does anyone know of a better way of doing this, or an easy button I've missed somewhere?

Top
#257439 - 07/04/16 08:36 AM Re: Randomly colorized usernames [Re: eliminat]
funfare Offline
Ameglian cow

Registered: 26/11/13
Posts: 22
Loc: Texas
would you be OK with only colorizing the nicks the chat.. but not the nick list? something like this could work..

Code:
on ^*:TEXT:*:# { 
  var %col $base($left($md5($nick),1),16,10)
  ; if you are using a white background.. change the below '1' to '0'
  if ( %col = 1 ) inc %col
  echo -t $chan < $+ $chr(3) $+ %col $+ $nick($chan,$nick).pnick $+ $chr(3) $+ > $1- 
  halt
}


Edited by funfare (07/04/16 08:39 AM)

Top
#263188 - 12/06/18 08:55 AM Re: Randomly colorized usernames [Re: funfare]
eahm Offline
Ameglian cow

Registered: 25/05/18
Posts: 41
Posting this for archival purposes, it's a variation of funfare' script but it randomizes colors between 2 and 15, skipping 0 and 1 (white and black).

Modified by maroon for me on ##mirc freenode.

Code:
on ^*:TEXT:*:# { 
  var %col $calc(($base($left($md5($nick),13),16,10) % 14) +2)
  echo -t $chan < $+ $chr(3) $+ %col $+ $nick($chan,$nick).pnick $+ $chr(3) $+ > $1- 
  halt
}

Top
#263279 - 27/06/18 06:15 AM Re: Randomly colorized usernames [Re: eahm]
eahm Offline
Ameglian cow

Registered: 25/05/18
Posts: 41
One more, to make it flash when flashing is enabled, thanks maroon again.

Code:
on ^*:TEXT:*:# { 
  var %col $calc(($base($left($md5($nick),13),16,10) % 14) +2)
  echo -tl $chan < $+ $chr(3) $+ %col $+ $nick($chan,$nick).pnick $+ $chr(3) $+ > $1- 
  halt
}

Top
#264697 - 02/01/19 08:17 AM Re: Randomly colorized usernames [Re: eahm]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1036
This thread came up in channel, and wasn't ready for primetime. The MOD 14 returns 0-13, so adding 2 changes the colors to be color index 2-15. This excludes both white and black, one of which is pretty much guaranteed to be a good color and the other one bad. But it also includes colors that may not contrast well against blackgrounds and whitegrounds unless you edit your color palette. i.e. 8=yellow vs 0-white or 2-navy vs 1-black.

This modified code instead lets you choose a list of colors that work well against the background. With the newer mIRC versions you can use colors 0-98, but for older versions you'd need to stick with the old 0-15 range. However many numbers you list, that's the number you replace the '16' with.

I also changed from MD5 to CRC, which is a faster algorithm, and avoids the need to use $left(). This should be sufficient to diversify similar strings among various colors, and would be slightly quicker, since this is executing for each message in channel.

The 'secret' is optional, and can be changed later if you want to stir the colors so some people no longer share a color.

If you want the color to follow someone as they change nick, replace $nick with $address. The color can change if they reconnect with a different IP address or if their identd state changes. Using $site would put clones as the same color, including all *@staff.network addresses.

Code:
on ^*:TEXT:*:# { 
var %col $gettok(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15,$calc(1+$base($crc(secret $nick,0),16,10) % 16),32)
echo -tl $chan < $+ $chr(3) $+ %col $+ $nick($chan,$nick).pnick $+ $chr(3) $+ > $1- 
  halt
}



To get fancier, you can make the coloring change every 24 hours, using the $randnow2 alias at https://mircscripts.net/j6hi0 to replace the 'var' line with:

Code:
var %col $gettok(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15,$randnow2(1,1,16,16,86400,secret $nick),32)



Both 16's need to change to the count of numbers in your number list. 86400 is the number of seconds in a day, so change it if you want it to change weekly or otherwise.

Top