mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2007
Posts: 4
P
Phen Offline OP
Self-satisified door
OP Offline
Self-satisified door
P
Joined: Dec 2007
Posts: 4
I am currently trying to create a script for whenever a certain word is said in a channel (by the on:TEXT command) it will echo a message to a window but instead of just having one word for the script to “keep an eye out” for I want it to have multiple words; but I currently only know how to assign one thing to one variable by /set and =. Is there by chance a way to use an array or someway that I could use the same variable name for multiple things? Here's an example of what I've been trying:

Code:
%textmatch = test
%textmatch = test2

on *:%textmatch:#: {
/window @Text_To_Match
/echo  -te @Text_To_Match Text found: %textmatch
}

But the script will only look for test2 because that is the current thing assigned to %textmatch.
I hope this makes sense and please help.

Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
This should do what you want, although I'm sure there are more efficient ways of doing it.

Code:
on *:START:{
  window @Text_To_Match
}

on *:TEXT:*:#: {
  var %line = $1-
  var %cnt = 1
  var %ttl = $numtok(%line,32)
  var %matches = test,test2,test3,test4

  while (%cnt <= %ttl) {
    var %word = $gettok(%line,%cnt,32)
    if ($istok(%word,%matches,44)) {
      echo -te @Text_To_Match Text found: %word
    }
    inc %cnt
  }
}

Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
Actually, this one is more efficient I think.

Code:
on *:START:{
  window @Word-Matches
}


on *:TEXT:*:#: {
  var %wordlist = word1,word2,word3,word4
  var %cnt = 1
  while (%cnt <= $numtok(%wordlist,44)) {
    if ($gettok(%wordlist,%cnt,44) isin $strip($1-)) {
      echo -te @Word-Matches Word found: $gettok(%wordlist,%cnt,44)
    }
    inc %cnt
  }
}

Joined: Dec 2007
Posts: 4
P
Phen Offline OP
Self-satisified door
OP Offline
Self-satisified door
P
Joined: Dec 2007
Posts: 4
thank you i'll try it grin


Link Copied to Clipboard