Welcome

User: Pass:   register


NOTE: Anything done on this page will use variables and identifiers with names that begin with %CI. or $CI. (Custom Identifiers dot) to hopefully ensure that nothing done here will break any scripts to which you have added the lines.

Contents

Things you need to know : aliases, parameters, identifiers and variables

Since custom identifiers are a special kind of alias, you need to know about aliases. This page assumes you know what an alias is and what parameters are; it just shows you how to use an alias in new and exciting ways. Remember, an alias can be added to an alias file or to a remote file. We'll use the remote file for consistency and ease of keeping track of them. Just precede the alias declaration with the word alias in a remote file.

In an Alias file:

slap { me slaps $$1 with a large, smelly trout }

In a Remote file:

alias slap { me slaps $$1 with a large, smelly trout } 

You should already know what normal identifiers are and basically how to use them. For example, you should know how to use identifiers such as $ctime, $mircdir, $fulladdress, $nick(channel,number) or even $gettok(string,number,tokenseparator). These are the identifiers that come standard with mIRC. You should understand the use of $read and $readini - we'll be needing both of them!

If you know about all of these, you probably already know how to use variables, so I'll just assume that you do.

Definition : exactly what is a custom identifier?

Simple: they are an alias that returns (or sometimes doesn't return) a value. They fall into several catagories, but they basically just return a value to wherever they were called from and insert it as if that value where put in that spot in the script or command.

New Functions: Write your own $function's, just like mIRC's

A very simple one might be to simply add two numbers and return the answer.

alias CI.add return $calc($1 + $2)

You could call such an identifier from your script, perhaps an alias like this:

alias add if (($1 isnum) && ($2 isnum)) echo $colour(info) -a *** ADD: $1 + $2 = $CI.Add($1,$2)

Now you could just type:

/add 257 354

And it would show in the active window:

*** ADD: 257 + 354 = 611


Labelers: ways to change popups or messages

When you want to make your popup labels dynamic (make them change based on something), you can use a nifty little feature that the return command allows. By having a custom identifier as a label for your popups, you can make the label give you detailed information about the option you are about to select. You can also hide options that don't apply at the moment based on the status of your script or your status in the channel or the status of the nick or channel you want to run the popup on. In fact, you can hide whole sections of popups or make them "magically" appear at runtime.

For instance, if you only want your away configuration popups to show up when you're not marked away, simply have a custom identifier for your label that checks to see if you're marked away or not. (Granted, this is a simple example that might be better implemented using $iif(), but that identifier is much slower and cannot do what a custom identifier label can do.)

Here's one that gives you a top level Away section heading. It will check to see if you are marked away; if you are, it will only allow you to mark yourself back. If you're not marked away, you won't even see this option on the list. The next one checks to see if you are marked away as well; if you are not marked away, it will return a label for the rest of the away script options.

; Groups to hold the logging and paging script
#CI.Logging off
#CI.Logging end
;
#CI.Paging on
#CI.Paging end
;
; Dynamic popup labels
alias CI.Back if ($away) return Mark as Back
alias CI.Away if ($away == $false) return Away
alias CI.Logging {
if ($group(#CI.Logging) == on) return [+] Logging
else return $chr(91) $chr(160) $+ $chr(93) Logging
}
alias CI.Paging {
if ($group(#CI.Paging) == on) return [+] Paging
else return $chr(91) $chr(160) $+ $chr(93) Paging
}
;
; Here are the popups, some of whose labels change!
menu channel {
; these first two will appear to occupy the same place in your channel popups,
; one of them having a sub menu and the other just executing code!
$CI.Back:away
$CI.Away
.Mark as Away:away $$?="Why away?"
.-
.$CI.Logging:{
if ($group(#CI.Logging) == on) .disable #CI.Logging
else .enable #CI.Logging
echo $colour(mode) -a *** Away: Logging is now $group(#CI.Logging)
}
.$CI.Paging:{
if ($group(#CI.Paging) == on) .disable #CI.Paging
else .enable #CI.Paging
echo $colour(mode) -a *** Away: Paging is now $group(#CI.Paging)
}
} 

An interesting feature of popups is that if there's nothing under a menu to show, then nothing does show! This is handy if you want a dividing line to show, but only if you have something underneath it in your popups to show. For instance, if you had set up your mIRC to Cancel away on keypress, then you won't ever need to mark yourself as back, so you could just replace the $CI.Back:away line with a -. If you are not currently away, you'll see your away system with a divider above it; if not, you won't see anything. Tricky, but neat.

Replacers

Many people would like to replace every instance of "lol" with "Laughs Out Loud" anywhere on the line. One way of doing this is by creating replacement identifiers that you can use anywhere as a shorter way of typing out the whole thing, including the special formatting you want with it.

Below are three identifiers, each takes up one line, but on some screen resolutions they may appear to take more.

alias LOL return $chr(2) $+ $chr(3) $+ 12L $+ $chr(15) $+ aughs $chr(2) $+ $chr(3) $+ 12O $+ $chr(15) $+ ut $chr(2) $+ $chr(3) $+ 12L $+ $chr(15) $+ oud
alias WB return $chr(2) $+ $chr(3) $+ 12W $+ $chr(15) $+ elcome $chr(2) $+ $chr(3) $+ 12B $+ $chr(15) $+ ack
alias ROTFL return $chr(2) $+ $chr(3) $+ 12R $+ $chr(15) $+ olling $chr(2) $+ $chr(3) $+ 12O $+ $chr(15) $+ n $chr(2) $+ $chr(3) $+ 12T $+ $chr(15) $+ he $chr(2) $+ $chr(3) $+ 12F $+ $chr(15) $+ loor $chr(2) $+ $chr(3) $+ 12L $+ $chr(15) $+ aughing 

You can even use this when you type by starting the line with //say or //me.

//me $LOL at Pasmal
* Hammer Laughs Out Loud at Pasmal

More to the point, however, it would make an on INPUT $reptok() much easier to read:

on *:INPUT:#:{
if (/* !iswm $1-) {
set %CI.OutputString $1-
if ($findtok(%CI.OutputString,lol,0,32)) $&
set %CI.OutputString $reptok(%CI.OutputString,lol,$LOL,1,32)
if ($findtok(%CI.OutputString,wb,0,32)) $&
set %CI.OutputString $reptok(%CI.OutputString,wb,$WB,1,32)
if ($findtok(%CI.OutputString,rotfl,0,32)) $&
set %CI.OutputString $reptok(%CI.OutputString,rotfl,$ROTFL,1,32)
say %CI.OutputString
unset %CI.OutputString
halt
}
}

Readers: Using custom identifier to make reading easy

$read and $readini are identifiers which tend to give scripters fits until they really understand them, and even then, they'll make mistakes. Here's one way to use a custom identifier to make using $read easier, followed by a way to make $readini easier for script configuration control.

$read

Your script has a file just full of funny kick messages. You want to clean up your script a little, so you've made yourself a custom identifier to return that message for you. Optionally, you can specify a line number you want and it will return that line for you (assuming you know what's on that line). In order to do this, we need an if statement to find out if there is a line number; if there is, then return the requested line from the kickmsgs.txt file, otherwise pick a random one and return that. We will always use the same file for this identifier - that means we won't have to pass in a filename everytime! And finally, we want to check the first parameter to see if there is a dash (ascii 45) in it, indicating a specific range from which to pick. If the first parameter is not a number (a line number you can read from in the kickmsg file) then give out the generic kick message. Assuming that the kickmsg.txt file is in the $mircdir:

alias CI.kickmsg {
if ($1 !isnum) return Have a wonderful day...but not here!
elseif ($1 isnum) {
if ($gettok($1,0,45)) return $read -l $+ $rand($gettok($1,1,45),$gettok($1,2,45)) kickmsg.txt
else return $read -l $+ $1 kickmsg.txt
}
else return $read kickmsg.txt
}

Please note that the above script may appear to have more lines that it actually does due to your current screen resolution.

All we need to do to include a random kick message now is use the $CI.KickMsg identifier we've just created wherever we kick. We can use $CI.KickMsg for a random one, $CI.KickMsg(15) for the 15th line of our file, or $CI.KickMsg(50-65) to have it pick one from the lines 50 through 65; this idea is very useful if you have your file set up with appropriate and known ranges of kick message styles (50-65 might be different flood kick messages).

alias kb {
if ($me isop $chan) {
ban $chan $$1 3
kick $chan $$1 $CI.kickmsg($2)
}
else echo $colour(mode) -a *** Kick/Ban: You are not a channel operator
}

Now we want to see how to use these in a channel as a channel operator:

  • To kick/ban Pasmal with the standard message: /kb Pasmal d
  • To kick/ban Pasmal with a random message: /kb Pasmal
  • To kick/ban Pasmal with the message from line 15: /kb Pasmal 15
  • To kick/ban Pasmal with a random message from the range of lines 50 to 65: /kb Pasmal 50-65

$readini

We are keeping all of our flood kick configuration information in a single file with sections for number of lines per number of seconds for each channel in which we op. We have the same kind of information for repeats stored in its own file. These files are called FloodConf.ini and RepeatConf.ini. One way to approach this is to have a separate identifier for each file and ask for the information you want.

alias CI.FloodSettings return $readini floodconf.ini $chan $1
alias CI.RepeatSettings return $readini repeatconf.ini $chan $1

You could include showing the settings for that channel when you op up in that channel, including the on/off status plus the number of lines in however many seconds for that channel.

Please note that the below script may appear to have more lines that it actually does due to your current screen resolution.

; Groups to hold the flood protect and repeat protect script
#CI.FloodProtect on
#CI.FloodProtect end
;
#CI.RepeatProtect on
#CI.RepeatProtect end

on me:*:OP:#:{
echo $colour(info) -a *** $iif($group(#CI.FloodProtect) == on,[+],[ ]) Flood Protection for $chan: $CI.FloodSettings(lines) lines in $CI.FloodSettings(seconds) seconds
echo $colour(info) -a *** $iif($group(#CI.RepeatProtect) == on,[+],[ ]) Repeat Protection for $chan: $CI.RepeatSettings(lines) lines in $CI.RepeatSettings(seconds) seconds
}

Which will show up like this:

*** ChanServ sets mode: +o Hammer
*** [+] Flood Protection for #HelpDesk: 10 lines in 5 seconds
*** [ ] Repeat Protection for #HelpDesk: 5 lines in 3 seconds

Resolvers : An interesting way to make your script get your current timezone

Here's an idea that's not too far away from a new numeric function, but it deals with time instead. It's easy, with the 5.51 version of mIRC to get at the time in a non-military (24-hour) format. But what if you wanted to add the exact time zone you were in, including the correct Standard/Daylight setting? Well, one way (this is geared for US timezones - the rest of the time zones are left to you as an exercise!) would be to use a custom identifier to return it for you. Like this:

alias CI.TZ.USA {
if ($timezone == 14400) set -u0 %TZ (Atlantic
elseif ($timezone == 18000) set -u0 %TZ (Eastern
elseif ($timezone == 21600) set -u0 %TZ (Central
elseif ($timezone == 25200) set -u0 %TZ (Mountain
elseif ($timezone == 28800) set -u0 %TZ (Pacific
elseif ($timezone == 32400) set -u0 %TZ (Alaskan
elseif ($timezone == 36000) set -u0 %TZ (Hawaii-Aleutian
elseif ($timezone == 39600) set -u0 %TZ (Samoa
if ($daylight) set -u0 %TZ %TZ Daylight Time)
else set -u0%TZ %TZ $+ Standard Time)
return %TZ
}


alias SayTime say It's $asctime(hh:nn:ss tt) $CI.TZ.USA here right now 

By typing /SayTime in a window, you'd get the following in the active window:

It's 11:01:23 pm (Eastern Daylight Time) here right now

Conclusion : What to do now

You've now seen some of the very cool things you can do with custom identifiers. There are many, many more ideas to be discovered than could ever possibly be covered in an entire web site; the only limitation you have is your own imagination. Have fun.

Release 1.0.0 Written by Hammer Latest mIRC version at time of release: 5.51 Copyright © 1998,1999 #HelpDesk, All rights reserved.






© 1996-2010 hdesk.org and dalnethelpdesk.com