Simple On/Off Script

By MaxEvans on Apr 01, 2009

This is just something I thought I'd put on here for those who don't know how to do this. It's a simple script that allows you to turn any command on and off. Like, a game, or a greet script that responds to a word or something. Or anything else you may want to use it for.

You can change the variable and commands to anything you want. It's pretty easy to use.

Just edit your script and put the if and elseif commands in, which will tell the script if it's off, to not do anything, and when it's on, to do what you want it to.

I set it for a simple variable "on.off" but it could be changed to anything. To use just type !onoff on or !onoff off. And you can change the !onoff command to anything you want too.

on *:TEXT:!commandhere:#: {
  if (%on.off == $null) {
    halt
  }
  elseif (%on.off == on) {
    commands here
  }
}

on *:TEXT:!onoff *:#: {
  if ($nick isop $chan) {
    if ($2 == on) {
      set %on.off on | .msg $chan Script is now on.
    }
    elseif ($2 == off) {
      unset %on.off | .msg $chan Script is now off.
    }
  }
}

Comments

Sign in to comment.
twoclipz   -  Sep 13, 2014

Is it possible to have this recognize the channel? That way if one channel turns the script off it doesn't affect the other channels that the bot may be in?

Paper0rPlastic  -  Sep 18, 2014

change all the instances of %on.off to %on.off. [ $+ [ $chan ] ]

twoclipz  -  Sep 18, 2014

Once again paper0rplastic I owe you thanks... THANK YOU!

Sign in to comment

Jonesy44   -  Apr 02, 2009

I think my post was ignore, El you bitch! :P

 Respond  
Tamaki   -  Apr 01, 2009

thanks prelude ^_^
sorry napa182

i'm not a twat...i just don't see it in there :( i didn't delete anything :s

 Respond  
Jonesy44   -  Apr 01, 2009

LoL, yah muppet :P

 Respond  
Prelude   -  Apr 01, 2009

Fooking kiddies gettin butt hurt, he prolly deleted his mirc help(twats do that from time to time;D) file Steve rofl or just misspelled it...For all of those not douche bags, from the mirc help file.

$iif(C,T,F)

Returns T or F depending on whether the evaluation of the Conditional C is true or false.

$iif(1 == 2, yes, no)  returns "no"

$iif() returns F if the conditional returns zero, $false, or $null. For any other value $iif() returns T.

If you don't specify the F parameter, $iif returns a T value if the condition is true, and returns nothing if it's false.

$iif(1 == 2, yes)  returns nothing

You can find out more about conditionals in the if-then-else section.

Or just scroll up and read wat Jonesy44 said. t(-.-t)

 Respond  
napa182   -  Apr 01, 2009

try what again?

hmm no need to be sarcastic.
ok for having the latest version you should have the $iif identifier in ur help files if not get a new help file.

 Respond  
Tamaki   -  Apr 01, 2009

@ napa182 > I bought mIRC, so i have the lastest up-to-date version...wanna try that again please?

 Respond  
napa182   -  Apr 01, 2009

@ The_Almighty_Duelist if you cant find $iif in the help by typing /help $iif then maybe you should update ur mIRC =/

here is just another way to do it. well just 1 of many ways...

on *:TEXT:!commandhere:#: {
  if (%on.off) { code here }
  else { msg # Pissoff }
}
on $@*:TEXT:/^(!on|!off)$/S:#: {
  if ($nick isop $chan) { 
    $iif($regml(1) == !on,set %on.off on,unset %on.off)
    msg # Script is now $iif(%on.off,on.,off.)
  }
}

or like this with flood control

on $@*:TEXT:/^(!on|!off)$/S:#: {
  if ($nick isop $chan && !$($+(%,onoff,.,flood),2)) { 
    set -u3 $+(%,onoff,.,flood) on
    $iif($regml(1) == !on,set,unset) %on.off on
    msg # Script is now $iif(%on.off,on.,off.)
  }
}
 Respond  
Jonesy44   -  Apr 01, 2009

Syntax: $iif(C,T,F)

Returns T or F depending on whether the evaluation of the Conditional C is true or false.

$iif(1 == 2, yes, no) returns "no"

If you don't specify the F parameter, $iif returns a T value if the condition is true, and returns nothing if it's false.

$iif(1 == 2, yes) returns nothing

 Respond  
Tamaki   -  Apr 01, 2009

what is $iif? i can't even find it in the irc help file :(

 Respond  
MaxEvans   -  Apr 01, 2009

I made it so only ops can turn it on/off. I forgot about that. =]

 Respond  
Blitzjager   -  Apr 01, 2009

Doesn't really matter but you might want to look into $iif. And if there was commands you wouldn't want just anyone to be able to enable/disable them so maybe look into user levels too.

 Respond  
Jonesy44   -  Apr 01, 2009

When it's on or off. You can use boolean variables. 1's or 0's. So, set %var 1/0 then you ca use if ([!]%var) {. Rather than using $null's and on :)

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.