mIRC Homepage
Posted By: drb Nick in bold - 09/06/11 05:04 PM
i want to make my script so that when i'm replying to "any" nick,, their nick will show in bold. i had this option on a very old script, but it is not compatible with win7.

i know very little about scripting, though i've made a few changes such as adding a pop-up, etc. & can follow simple instructions. so if someone can give me the exact script that i can copy/paste & then tell me where to put it,, i can do that. smile
Posted By: DJ_Sol Re: Nick in bold - 10/06/11 02:00 PM
When you say reply do you mean a query or whisper?
Posted By: Riamus2 Re: Nick in bold - 10/06/11 02:16 PM
I would guess that you're talking about a nick completer? Where if you type a nick with a colon after it at the beginning of a line, that nick will be formatted in some way (color, bold, underline, fancy characters around it, etc). If so, there are a variety on the scripting sites (search for nick completer) or someone here may write one for you.

If you mean that it checks every word in a line of text and if the word is a nick currently in the channel, then it formats it in some way (see above for types of formatting), then that's a slightly more involved script, though still not too difficult to write.

If you mean something else entirely, please clarify how your initial input would appear and how you want it to display afterwards.
Posted By: Tomao Re: Nick in bold - 10/06/11 05:09 PM
Originally Posted By: Riamus2
I would guess that you're talking about a nick completer? Where if you type a nick with a colon after it at the beginning of a line, that nick will be formatted in some way (color, bold, underline, fancy characters around it, etc).
Here is the code:
Code:
on ^*:tabcomp:*:{
  editbox -ap $+($chr(2),$1,:,$chr(2)) 
  haltdef
}
Posted By: drb Re: Nick in bold - 12/06/11 11:46 AM
@Riamus2

Yes, this is exactly what I mean:

<quote>If you mean that it checks every word in a line of text and if the word is a nick currently in the channel, then it formats it in some way (see above for types of formatting), then that's a slightly more involved script, though still not too difficult to write. </quote>

It doesn't require typing a colon or anything (like mentioned above). You just type the nick & it formats it in bold, or even bold with color.
Posted By: Tomao Re: Nick in bold - 12/06/11 07:01 PM
I think this will do what you want:
Code:
alias -l cc {
  var %c = 1
  while ($comchan($me,%c)) {
    return $v1
    inc %c
  }
}
on *:input:*:{
  if ($left($1,1) !isin / $readini($mircini,text,commandchar)) && (!$ctrlenter) && (!$inpaste) {
    var %c = $regsubex($str($chr(32),$nick($cc,0)),//g,$nick($cc,\n)), %x = $numtok(%c,32), %t = $1-
    while (%x) {
      var %r = $gettok(%c,%x,32), %t = $replace(%t,%r,$+($chr(2),%r,$chr(2)))
      dec %x
    }
    say %t
    haltdef
  }
}
There's a chance that the script may run into an issue if you have a big channel with 100+ people. But for a small channel, this should work a treat. I'm not certain how many tokens are allowed in a local variable before it triggers an error or gets cut off.
Posted By: drb Re: Nick in bold - 13/06/11 01:01 PM
could you tell me exactly where to paste the code? does it go in the alias or remote section? or somewhere else?

*my first thought would be the alias section,, but i'm a real newbie to this.

many thanks! smile
Posted By: hixxy Re: Nick in bold - 13/06/11 02:25 PM
That $cc will always return the first common channel.
Posted By: Riamus2 Re: Nick in bold - 13/06/11 02:55 PM
Scripts posted here will always go in Remote unless specifically stated otherwise. You *can* put any aliases in the Aliases tab, but you will need to remove "alias" from the beginning and if it's a local alias (-l is used), then you either need to remove the -l (making it global) or else leave it in the Remote file so it can remain local. In general, most people like to keep all parts of a script together, so they leave the aliases on the Remote tab with the rest of the script.

Regarding local aliases -- The main reason to make an alias local instead of global is to avoid conflicts with other scripts that may use the same alias name. If you always use unique alias names that are not likely to be in any other script, then global is fine.

And, as hixxy pointed out, the $cc alias isn't correct and will need to be fixed.
Posted By: drb Re: Nick in bold - 13/06/11 04:51 PM
RE:
And, as hixxy pointed out, the $cc alias isn't correct and will need to be fixed.

i hate to be such a bother, but i haven't a clue what you're talking about here, therefore i don't know how to change it in the above code. if you can tell me exactly what to change in the above code, then i can change it & then do a copy/paste to add it to my script.

thanks again!
Posted By: Riamus2 Re: Nick in bold - 13/06/11 05:01 PM
I am at work and cannot connect to test something like this, which is why I just added the reminder that it would need fixed so you weren't thinking that it would work as-is. Tomao or hixxy or someone else here should be able to provide a fix to it for you. If not, I'll see if I can look it over tonight.

Personally, I'd just make it easy and drop $comchan altogether. In general, you want the nick to be bold in a channel if the nick is in that channel (not if the nick is in another channel that you're in). In that case, there's no need for $comchan at all as you can just check the active channel (or query). Again, I can't test anything right now and would rather not use regex without being able to test it, so I'll have to leave that for someone else to set up.
Posted By: Wims Re: Nick in bold - 13/06/11 05:32 PM
Just put that code in your remote:
Code:
on *:input:#:{
if (!$istok(/ $readini($mircini,text,commandchar),$left($1,1),32)) && (!$ctrlenter) && (!$inpaste) {
msg $chan $regsubex($1-,/(\S+)/g,$iif(\1 ison $chan,$+($chr(2),\1,$chr(2)),\1))
halt
 }
}

Posted By: Tomao Re: Nick in bold - 13/06/11 06:18 PM
My bad. I wasn't aware that the $cc will only return the first common channel. I was trying to address the scenario when you reply to a nickname in your PM. There is no $chan in the PM. I thought by using a loop through the common channels would get that matter resolved.

Well, apparently Wims has provided you with a code using the regsubex method. But be advised that you must use mIRC version 6.17 or above for Wims' code to work.
Posted By: drb Re: Nick in bold - 13/06/11 06:49 PM
thanks guys but that code makes my lines post twice. in the 1st line the nick *does* come out bold, but not in the 2nd line.
Posted By: Wims Re: Nick in bold - 13/06/11 07:15 PM
I tried the code myself, it works fine.
If it sends two messages, it means you have another on input doing basically the same thing.
Did you remove any old on input event taken from here before putting the new one ?
Posted By: Tomao Re: Nick in bold - 13/06/11 07:26 PM
You could try changing
Quote:
halt
to
Code:
haltdef
and see if that makes any difference. Having two identical input events, the one that works is the one on top of another, so you can only have one input event, not two.
Posted By: Riamus2 Re: Nick in bold - 13/06/11 07:34 PM
Originally Posted By: Tomao
My bad. I wasn't aware that the $cc will only return the first common channel. I was trying to address the scenario when you reply to a nickname in your PM. There is no $chan in the PM. I thought by using a loop through the common channels would get that matter resolved.


@Tomao: The loop would be fine except that you use RETURN, which breaks you out of the loop and returns you to the calling script. There isn't a small change to resolve that issue, but you could store the channels in a variable and return the entire list and then work from that in the script. The problem there is variable length and it probably won't be that efficient.

In the case of handling queries, I typically do this: msg $iif($chan,$chan,$nick) some text. That will work as long as your input event is limited to channel and query. In this script, you can put the $iif() into a variable and then use the variable everywhere that you'd need to save space in the script. $active and/or $target may also be valid, but I'd need to double check to make sure as I don't use them too often.

The code Wims posted could easily be adjusted to work with queries by changing the event from # to #,? and replacing \1 ison $chan with \1 ison $chan || $nick and then using the $iif() as mentioned above in the /msg.

As far as input events, he can have 2 if the other is in a separate file. That's probably what happened. Afaik, HALT should be used with input events even though you'd normally use HALTDEF for other events.

@drb: Make sure you don't have the original script still. Check under the View menu in each file to make sure it's not listed there.

Also, if you use any other scripts, they may also be echoing the text. If that's the case, you'd need to either combine this script with what you already have or else remove your other script(s).
Posted By: Tomao Re: Nick in bold - 13/06/11 08:10 PM
Thanks Riamus2 for your timely explanation. I do know the comparison for $iif(#,#,$nick) very well. I failed to notice the return used in conjunction with the loop. I believe everybody has one of those days where we get carried away and forget what we should have know better in a subject. This is when a mentor comes in and reminds us of our oversights. After all, this is what mIRC forum is all about, helping each other. smile
Posted By: drb Re: Nick in bold - 15/06/11 11:03 AM
thanks everyone! smile
© mIRC Discussion Forums