mIRC Home    About    Download    Register    News    Help

Topic Options
#239155 - 26/09/12 09:33 AM replacing script needs revision
geejeeNL Offline
Nutrimatic drinks dispenser

Registered: 01/04/12
Posts: 9
Hi, im using this script for a long time, but on the latest version(s) of mIRC it doesn't work well anymore:


on *:INPUT:*: {
IF ($left($1,1) != /) {
msg $active $replace($1-,brb,Be Right Back,lol,Laughing Out Loud,jk,Just Kidding)
HALT
}
}

The problem is that the command filter on the beginning gives a faillure. Also i want to add 2 more options to this script:
1. Is it possible to add a ctcp action to another client when a replacing of words has taken place?
2. Is it possible to use an external .txt or .ini file where the replacing words are stored (trigger word v.s. replacing word)?

Top
#239173 - 29/09/12 07:58 AM Re: replacing script needs revision [Re: geejeeNL]
KindOne Offline
Fjord artisan

Registered: 23/02/11
Posts: 307
Load this in a new script under remote tab. Allow it to initiate.

This is designed for your 2nd request, store contents into a .txt file.

Really really crude crash course on how to add words:

/hadd <name> <item> <data>

/hadd words brb Be Right Back

<name> == words
<item> == brb
<data> == Be Right Back

The <item> can't have spaces.

This script basically replaces the <item> with <data>.

See: /help /hadd


Code:
; Syntax to add more words:
;
; /hadd words brb Be Right Back

on *:start:{ 
  if (!$hget(words)) { 
    hmake words 200
  }
  if ($isfile(words.txt)) {
    hload words words.txt  
  }
} 

on *:unload:{ 
  if ($hget(words)) {
    ; Save words..
    hsave words words.txt
    hfree words
  }
}

on *:exit:{ 
  ; Save words..
  hsave words words.txt
}

on *:input:*:{ 
  ; Don't trigger on command that begin with "/" or 
  ; when "CTRL+ENTER" is pressed.  
  if ($left($1,1) != /) && (!$ctrlenter) {
    var %x = 1
    var %y = $numtok($1-,32)
    var %temp = $1-
    while (%y) {
      var %a = $gettok($1-,%y,32)
      if ($hfind(words,%a)) {
        var %b $numtok($hget(words,%a),32) - 1
        var %temp = $puttok(%temp,$hget(words,%a),%y,32)
        inc %b
      }
      dec %y
    }
    msg $active %temp
    halt
  }
}
_________________________
irc.swiftirc.net #msl (mIRC Scripting Language)

Top
#239176 - 29/09/12 05:31 PM Re: replacing script needs revision [Re: KindOne]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
The if condition to check if the hash table exists isn't needed because one has to reopen or restart mIRC for the start event to be activated. A Hash table is merely obliterated upon closing or existing mIRC.

Also, the $hfind() command can do the wildcard searching instead of go the extra mile with $gettok, $puttok and a while loop...

This is my constructive criticism; in no way do I intend to be cynical to comment on your approach in the code provided.

Top