mIRC Home    About    Download    Register    News    Help

Print Thread
if elseif msg help #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.

Re: if elseif msg help [Re: mwhynot] #195397 23/02/08 07:22 PM
Joined: Dec 2002
Posts: 2,016
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,016

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?

Re: if elseif msg help [Re: mwhynot] #195398 23/02/08 07:23 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline
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,.) }
Re: if elseif msg help [Re: mwhynot] #195406 23/02/08 11:15 PM
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?

Re: if elseif msg help [Re: mwhynot] #195407 23/02/08 11:16 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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
Re: if elseif msg help [Re: mwhynot] #195408 23/02/08 11:20 PM
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

Re: if elseif msg help [Re: mwhynot] #195412 23/02/08 11:33 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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
Re: if elseif msg help [Re: mwhynot] #195413 24/02/08 12:54 AM
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

Re: if elseif msg help [Re: mwhynot] #195415 24/02/08 01:20 AM
Joined: Aug 2003
Posts: 144
M
Miguel_A Offline
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.

Re: if elseif msg help [Re: mwhynot] #195417 24/02/08 04:55 AM
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.

Re: if elseif msg help [Re: mwhynot] #195427 24/02/08 01:17 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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