mIRC Home    About    Download    Register    News    Help

Print Thread
#195396 23/02/08 07:06 PM
Joined: Feb 2008
Posts: 5
M
mwhynot Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2008
Posts: 5
new to scripting so any help is appreciated. Looking for a method to display text in a chan using if elseif etc. Have tried many different scenarios but unsuccessful. I have exhausted my abilities (not much) so here I am.

if (Text1 isin $1-) /msg #Chan messagetext
elseif (Text2 isin $1-) /msg #Chan messagetext
elseif (Text3 isin $1-) /msg #Chan messagetext
etc etc

I have also used
.msg #Chan messagetext
{/msg #Chan messagetext}
{.msg #Chan messagetext}

From what I can see the If isin part is ok just the msg line not working. I am betting I am doing something stupid that can be easily corrected.

Thx for any help.

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

I don't see anything wrong with your example, could you paste the whole script/event exactly as you have it so we can look at it? Also, what's the problem with it? What's it doing or not doing?

Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I use your example for this:
Code:
on *:TEXT:*:#:{
 if (Text1 isin $1-) { msg $chan messagetext }
 else if (Text2 isin $1-) { msg $chan messagetext }
 else if (Text3 isin $1-) { msg $chan messagetext }
}

this should work.

You can replace the # in on *:TEXT:*:#:{

* <- it triggers on all text both in chat and channel.
# <- it triggers on text in a channel.
? <- it triggers only on private message.
= <- it triggers on a DCC chat and the text in that one.


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Feb 2008
Posts: 5
M
mwhynot Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2008
Posts: 5
on 1:TEXT:*Test*:#TestRoom: {

if (Test1 isin $1-) /msg #TestRoom MessageText1
else if (Test2 isin $1-) /msg #TestRoom MessageText2
Else Message : $1-
}

This is all I am working with. I have created a room to test/play. I load and type Test, Test1, Test2 and absolutely no response. I had even tried
on 1:TEXT:*Test*:#TestRoom: /msg #TestRoom MessageText : $1- and still no msg appears in Testroom. Is it because someone other than myself is requred to type text?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
What event is that in? on TEXT? Keep in mind that if you're using on TEXT, others can trigger it, but you cannot from the client running the script. That may be your problem?

As for the things you said you also tried... you cannot put {}'s touching anything else... you'd need spaces for those to work. And . before msg or anything else just silences it so you don't see it on the client running the script -- in the case of msg, others in the channel would see it, but not the client running it.

Also, you don't need /'s in scripts. Using them won't cause a problem, but it's unnecessary.


Invision Support
#Invision on irc.irchighway.net
Joined: Feb 2008
Posts: 5
M
mwhynot Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2008
Posts: 5
Thx Riamus2

Was going crazy and as you can see from my post I was starting to think the right way. Maybe there is hope for me yet. lol
So my best bet is to join from 2 diff puters to test stuff. Gonna give that a try. smile

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Doesn't have to be 2 computers. You can use 2 different mIRC clients from the same computer to test.

on TEXT only triggers when others type something (not the client with the script).

If you need it to trigger for the client with the script, use on INPUT instead. If you need it to trigger for both, you have to use both on INPUT *and* on TEXT. Note that it may be best if you need things to trigger for both that you use an alias that is called from both so you're not duplicating the script. Duplicating doesn't really hurt it... it just makes it longer. You can also put stuff in aliases later if you choose. Just remember if you do aliases that certain things aren't going to be the same. For example, $nick is correct in on TEXT, but for on INPUT, you'd need $me. For something like that, you can call the alias with the $nick/$me included so that those become $1 in the alias. /aliasname $nick (for example).


Invision Support
#Invision on irc.irchighway.net
Joined: Feb 2008
Posts: 5
M
mwhynot Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2008
Posts: 5
on 1:TEXT:*Test*:#TestRoom: {

if (Test1 isin $1-) msg #TestRoom Answer 1
elseif (Test2 isin $1-) msg #TestRoom Answer 2
Else /msg #TestRoom Message : $1-
}

OK...now I am stuck. Connected with a 2nd client and now when I use the below lines I receive an unknown command. If I type any text with "Test" in it other than Test1, Test2 the else statement does work which is the main reason for my confusion.


if (Test1 isin $1-) /msg #TestRoom Answer 1
421: Unknown command: /MSG

if (Test1 isin $1-) msg #TestRoom Answer 1
421: Unknown command: MSG

Joined: Aug 2003
Posts: 144
M
Vogon poet
Offline
Vogon poet
M
Joined: Aug 2003
Posts: 144
Hi

Code:
on 1:TEXT:*Test*:#TestRoom: {
  if ( Test1 isin $1-) { 
    msg $chan Answer 1
  }
  ElseIf ( Test2 isin $1-) {
    msg $chan Answer 2
  }
  Else {
    msg $chan Message : $1-
  }
}


This one must work on you.
The code that you had have work on me. Is it very strange that is not working on you.
Try to organize your code using the brackets.
It is not in this case but when working with big codes the brakets are very good, to check any miss spelling or any error.

Joined: Feb 2008
Posts: 5
M
mwhynot Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2008
Posts: 5
on 1:TEXT:*Test*:#TestRoom: {

if (Test1 isin $1-) msg #TestRoom Answer 1
elseif (Test2 isin $1-) msg #TestRoom Answer 2
Else /msg #TestRoom Message : $1-
}

I found my problem. I had tab aligned the 'msg' part of each line for easy reading. Once I removed all the embedded spaces all worked normally. I would not have thought that with {} but oh well. Now I know what not to do. I might learn something yet.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yeah, you cannot use tabs to align text. Use spaces or let it do the aligning for you.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard