mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2014
Posts: 4
B
Self-satisified door
OP Offline
Self-satisified door
B
Joined: Mar 2014
Posts: 4
So I'm very new to mIRC scripting, literally started 4 hours ago. I have found another thread whereby I learned you cannot have multiple on TEXT events in the same script. Is there anyway I can do this, perhaps with a file or something? A different message for different keywords.
e.g look for a keyword in a file and if so, send out a message to the channel... or even better send a message in the channel but only the person who said the keyword can see it?

Quote:
on *:TEXT:!bighorner:#:{ /msg $chan Looks like meat's back on the menu, boys! }
on *:TEXT:!Gman:#:{ /msg $chan Wake up Mr.Freeman, Wake up and smell the ashes. }
on *:TEXT:!Peach:#:{ /msg $chan It’s-a me, Mario! }


Appreciate all replies, but as said I am incredibly new so just wondering if it can be done.

EDIT:
Apparently the new version of mIRC does support multiple onTEXT... at least in my script it does.

EDIT 2:
New problem, am I able to do an
if on text? such as the below?

Quote:
if on *:TEXT:bighorner:#:{ /msg $chan Looks like meat's back on the menu, boys! }
on *:TEXT:Gman:#:{ /msg $chan Wake up Mr Freeman, Wake up and smell the ashes. }
on *:TEXT:Peach:#:{ /msg $chan It’s-a me, Mario! }
on *:TEXT:freebie:#:{ /msg $chan It's dangerous to go alone! Take this. }
on *:TEXT:overused:#:{ /msg $chan All your base are belong to us. }
on *:TEXT:nogum:#:{ /msg $chan I'm here to kick ass and chew bubble gum, and I'm all out of gum.}
{
inc %count
writeini cookies.ini $chan $nick %count
}


It says I am missing a bracket on the last onTEXT. So far all of the onTEXTs run, but the %count doesn't

Last edited by bugmenot; 07/03/14 08:50 PM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
The limitation for events is that only topmost event that matches the text is run. You last attempt is nonsense and I have no idea what your intention was.

Joined: Mar 2014
Posts: 4
B
Self-satisified door
OP Offline
Self-satisified door
B
Joined: Mar 2014
Posts: 4
Ok so I am trying to match see if the text keyword is matched the message is shown to the channel, IF a keyword is matched then this also updates a file called cookies.ini, with the persons $nick and increments the count stored against the persons $nick.

I have looked into doing this with /goto and variables, except the if isn't picking up the matchtext variable and then comparing it in the if. As the above post suggested, I literally picked up mIRC scripting yesterday evening, so everything I've written and learned so far if from wiki and googling.

Quote:
on *:TEXT:%keyword:#:{
if ($1 == bighorner) { /goto bighorner }
:bighorner
/msg $chan Looks like meat's back on the menu, boys!
/goto count
return
:count
inc %count
writeini cookies.ini $chan $nick %count
return
}

Last edited by bugmenot; 08/03/14 12:00 PM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
You should not be using the goto statement for anything.

Code:
on *:text:&:#:{
  var %msg

  if ($1 == text1) { %msg = msg1 }
  elseif ($1 == text2) { %msg = msg2 }
  elseif ($1 == text3) { %msg = msg3 }
  else { return }

  var %count = $readini(cookies.ini,#,$nick) + 1
  writeini cookies.ini # $nick %count
  msg # %msg 
}

Joined: Mar 2014
Posts: 4
B
Self-satisified door
OP Offline
Self-satisified door
B
Joined: Mar 2014
Posts: 4
thanks, that really helps, appreciate it. As I said, I'm new so all help is appreciated.

I am now attempting to check whether the person has already said a keyword. (text1, text2, text3 in your example) by writing it to a file and then re-checking it if they say it again, if it's already been said, do not increment the %count.

This works as what I've got, but the flaw is, someone could say 'text1' 'text2' 'text1' and increment the count that way, I need to store all said keywords into a file and then check them all everytime a new keyword is said.
does mIRC have arrays?

What I currently have is the text file keywords.ini populated with nickname=text1,text2

Is there anyway to search this line for the keyword using the comma as a delimiter.

Code:
on *:TEXT:&:#:{
  var %msg

  if ($1 == text1) { %msg = msg1 }
  elseif ($1 == text2) { %msg = msg2 }
  elseif ($1 == text3) { %msg = msg3 }
  else { return }
  msg # %msg 

  var %keyword = $readini(keyword.ini,#,$nick)
  msg # %keyword
  if (%keyword == $1) {
    msg # you already have this keyword! :(
  }
  else {
    var %count = $readini(cookies.ini,#,$nick)
    inc %count
    writeini cookies.ini # $nick %count
    writeini keyword.ini # $nick %keyword $+ , $+ $1
  }
}

Last edited by bugmenot; 09/03/14 03:13 PM.
Joined: Mar 2014
Posts: 4
B
Self-satisified door
OP Offline
Self-satisified door
B
Joined: Mar 2014
Posts: 4
further looking at the code, I removed the %keyword and $! as this made it all not work. It now puts in 'text' into the keywords.ini and further use of 'text1' in chat doesnt increase the count. However this can still be bypassed by typing something in between e.g 'text1' 'text2' 'text1' to trick the count.

Is there a way to add all the keywords to the ini file with a comma in between (already done) but then single step through the words to check them using the comma as a delimiter?


Link Copied to Clipboard