mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2014
Posts: 2
H
HoHoes Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
H
Joined: Aug 2014
Posts: 2
Is it possible to Halt a command while running to stop the rest of the commands from being used?

PASTED FROM SCRIPT:

Code:
on *:TEXT:!twitter*:#sho94: {
  if ($nick isop #) { msg $chan /me Thank you moderator for entering command }
  else { msg $chan /me Sorry you must be a mod to use this command } <WHERE I WANT COMMAND TO BE HALTED>
  if ($2 == on) {  timerMessage 0 1200 msg $chan /me Follow Sho on twitter! http://adf.ly/nseve  }
  if ($2 == on) {  msg $chan /me Timer Twitter turned on! }
  if ($2 == off) {  timerMessage off  }
  if ($2 == off) {  msg $chan /me Timer Twitter turned off!  }
}


If this is possible please help.
Also it doesn't seem to work when I take out "if ($nick isop #) { msg $chan /me Thank you moderator for entering command }"'s msg
AKA it doesn't work.

I want it to say this if an OP types the command:
timer twitter turned on!
timer twitter turned off!
What I want said if a non-op types command:
Sorry, you must be a mod to use this command.

Eventually I will be implementing this into a lot more of my commands if this works!


Be careful! I'm not HoHos!
Joined: Apr 2014
Posts: 4
T
Self-satisified door
Offline
Self-satisified door
T
Joined: Apr 2014
Posts: 4
Hope this helps smile
Code:
on *:TEXT:!twitter*:#sho94: {
  if ($nick isop #) { if ($2 == on) {  timerMessage 0 1200 msg $chan /me Follow Sho on twitter! http://adf.ly/nseve  } 
    if ($2 == on) { msg $chan /me Timer Twitter turned on! } 
    if ($2 == off) {  timerMessage off  } 
    if ($2 == off) {  msg $chan /me Timer Twitter turned off!  }
  } else { msg $chan /me Sorry you must be a mod to use this command } return
}


What halts the command?
Return
In fact you don't even need it now, but I'll keep it there for reference.
Its simple and easy to type. Goodluck with your future mIRC coding. smile

Last edited by Toot; 23/08/14 07:17 AM.
Joined: Aug 2013
Posts: 81
I
Babel fish
Offline
Babel fish
I
Joined: Aug 2013
Posts: 81
Toot's got the right idea, but his code is a little malformed (for mSL, anyway).

The primary issue with your code, HoHoes, is the way you've structured it. When dealing with conditions on the same level,the elseif/else statement(s) are checked only when the previously checked condition was false, but the if condition(s) are always checked. So, because the "if ($2 == on)"/"if ($2 == off)" conditions (x2 for some reason) are on the same level as the else statement above them, they are checked regardless.

What you can, and should do, as Toot demonstrated, is nest those conditions within the "if ($nick isop #) { }" block, so that they can only be checked if that precondition is true. You should also note that you can run multiple commands within these blocks, rather than repeatedly checking the condition per command, as you appear to have done:

Code:
on *:TEXT:!twitter*:#sho94: {
  if ($nick isop #) {
    if ($2 == on) {
      timerMessage 0 1200 describe # Follow Sho on twitter! http://adf.ly/nseve
      describe # Timer Twitter turned on!
    }
    elseif ($2 == off) {
      timerMessage off
      describe # Timer Twitter turned off!
    }
  else { describe # Sorry you must be a mod to use this command }
}


I hope you get the idea, but let me know if you need any help understanding what I've said here.


Link Copied to Clipboard