Difference between revisions of "On input"

From Scriptwiki
Jump to: navigation, search
(edit hint because of more than one on input..)
(added some stuff.)
Line 2: Line 2:
 
  on <level>:INPUT:<*#?=!@>:<commands>
 
  on <level>:INPUT:<*#?=!@>:<commands>
  
Read [[Limiting Access]] to get more information about the prefixes and suffixes (*#?=!@).
+
The location of this event can be:
 +
* * is everything
 +
* # is a channel
 +
* ? is a query window
 +
* = is a dcc window
 +
* ! is a fileserver window
 +
* @ is a custom window
 +
You can also specify a specific channel/window name instead of *#?=!@.
 +
 
 +
'''Note''' that if you /halt this event, you can prevent mIRC itself from processing your message.
  
 
'''Note''' that this event has no matchtext-field. You have to use [[if|if-statements]] to make more restrictions.  
 
'''Note''' that this event has no matchtext-field. You have to use [[if|if-statements]] to make more restrictions.  

Revision as of 16:04, 7 December 2005

The on INPUT event triggers when you enter text in an editbox and press enter.

on <level>:INPUT:<*#?=!@>:<commands>

The location of this event can be:

  • * is everything
  • # is a channel
  •  ? is a query window
  • = is a dcc window
  •  ! is a fileserver window
  • @ is a custom window

You can also specify a specific channel/window name instead of *#?=!@.

Note that if you /halt this event, you can prevent mIRC itself from processing your message.

Note that this event has no matchtext-field. You have to use if-statements to make more restrictions.

Note that you should only use one on input event in your remote as having more will make problems because of "double echo"'s.

Example

The following example will connumerate your written characters and words.

; Whenever you say something, this even will trigger.
on *:INPUT:*: {
 ; set variable %allchars to the total amount of characters you have written.
 set %allchars $calc(%allchars + $len($1-))
 ; set variable %allwords to the total amounts of words you have written. 
 set %allwords $calc(%allwords + $numtok($1-,32))
}

The next, more complex, example will replace all "moo"'s with "moo00oo00" in your text.

on *:INPUT:*: {
  ;nothing will change if you press control + enter or the first character is the command prefix     
  ;character you have specified in your mIRC options (usually "/").
  if (($ctrlenter) || ($left($1,1) == $readini(mirc.ini,text,commandchar))) { return }
  else {
   ; send the "new" text to the channel (but hidden)
   .msg $active $replace($1-,moo,moo00oo00)
   ; echo the "new" text in your current window (as it's the window you have just typed it)
   echo -t $active < $+ $me $+ > $replace($1-,moo,moo00oo00)
   ; stop the usual output
   haltdef
  }
} 
   

See Also

To trigger on text from other users, you have to use the On Text Event.