I have fixed and improved my script code for you. Please check if everything is working properly in it.
It so happens that several installed scripts can conflict with each other and interfere with the correct operation of one of them.
If you encounter problems, then try installing this script on a pure mIRC client (without other scripts) to test the script's functionality.
The script will correctly display all colors only in the most recent versions of the mIRC client, which have a to choose from
98 colors add-on. This code was tested on
mIRC v7.63Updates:Now the script can detect nicknames in messages even when they are followed by such characters: [
.,:=?!()].
Also, now the script can automatically assign a color for a nickname for which there is no color in the address book, as soon as the user join the channel, or change their nickname, or sends a message.
You can independently make the necessary settings for the script through the "
color_nick_message_set" alias:
Variable "
%cnm_ignore_color" – adjusts space-separated color numbers that cannot be used to for coloring nicknames. (You can change this to suit your chat background)
Variable "
%cnm_ignore_chan" – adjusts space-delimited channels on which nicknames in messages cannot be colored. (You can change this channel list)
Variable "
%cnm_auto_color" – controls whether to enable (
true) or disable (
false) to automatically record the color for nickname in address book. (You can change it)
Variable "
%cnm_method_color" – adjusts the method for displayed colors, where
0 = color for nickname will be simultaneously in messages and in the list of nicknames, or separately
1 or
2.
Variable "
%cnm_sort_list" – sorts the nicknames in the address book, where
1 = will be the first line in the address book list.
I am attaching screenshots of how it looks in my chat:
![[Linked Image from i.ibb.co]](https://i.ibb.co/rHpsNty/mIRC-Demo-ColorNickMessage.png)
This code must be inserted into the script editor. To do this, press the key combination "
ALT+R" and replace the old code with this code:
#####################################################################
# Name: ColorNickMessage v1.0
# Description: Colors all the specified nicknames in the text that are present on the same channels where you are.
# Author: Epic
# Email: epicnet@mail.ru
# Site: http://epicnet.ru
#####################################################################
on *:NICK: сolor_nick_message_auto $newnick
on *:JOIN:#: сolor_nick_message_auto $nick
on ^*:TEXT:*:#: сolor_nick_message $nick $chan $1-
on *:INPUT:#: if ($left($strip($1-),1) != /) { .msg $chan $1- | сolor_nick_message $me $chan $1- }
-------------------------------------------
alias -l сolor_nick_message_set {
%cnm_ignore_color = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 36 37 48 60 88 89 90 92 93 94 95 96 97 98
%cnm_ignore_chan = #Services #MyTest
%cnm_auto_color = true
%cnm_method_color = 0
%cnm_sort_list = 1
}
-------------------------------------------
alias -l сolor_nick_message_auto {
if (%cnm_auto_color == true && $cnick($1) == 0) {
var %cnm_key $+(-m,%cnm_method_color,s,%cnm_sort_list)
:next1 | var %cnm_rcol $rand(1,98) | if ($istok(%cnm_ignore_color,%cnm_rcol,32)) goto next1
.cnick %cnm_key $1 %cnm_rcol
}
}
alias -l сolor_nick_message {
сolor_nick_message_set | if ($istok(%cnm_ignore_chan,$2,32)) { halt } | сolor_nick_message_auto $1
var %cnm_text $3- | var %cnm_stext $strip(%cnm_text) | var %cnm_inc 1 | while (%cnm_inc <= $numtok(%cnm_stext,32)) {
var %cnm_tok $gettok(%cnm_stext,%cnm_inc,32) | var %cnm_rtok $remove(%cnm_tok,$chr(40),$chr(41),$chr(44),.,=,:,?,!)
if ($comchan(%cnm_rtok,0) > 0) {
var %cnm_col $cnick(%cnm_rtok).color | var %cnm_ncol $+($chr(3),%cnm_col,%cnm_rtok,$chr(3))
var %cnm_rncol $replace(%cnm_tok,%cnm_rtok,%cnm_ncol) | var %cnm_text $puttok(%cnm_text,%cnm_rncol,%cnm_inc,32)
} | inc %cnm_inc
}
if (%cnm_text) { var %cnm_nick $+(<,$chr(3),$cnick($1,1).color,$1,$chr(3),>) | .echo -t $2 %cnm_nick %cnm_text | halt }
}