mIRC Homepage
Posted By: Bestpeff (Twitch) Turning commands on and off - 22/05/16 10:40 PM
Is there anyway to make certain commands to be turned on and off instead of completely removing them from the remotes section. Reason I ask this is because in a certain partnered streamers chat they have certain days where the command is needed any other days where's it's not necessary. Like the command be turned on and off with !(commandname) on/ !(commandname) off....is this a possible thing with mIRC? Any help is greatly appreciated smile
Yes it is, this is probably not the best solution but it should atleast make you aware of how you could do it wink

Code:
;%commandoutput is what the command should output
;%commandname would be the variable for the command name
;%commandname.switch is the variable we turn on/off to toggle the %commandname
;You can replace these variables with static text, if you do not wish to use variables

on *:TEXT:$(%commandname *):#: {
if ($2 == on) {
 if (%commandname.switch == $null) {
  var -g %commandname.switch = 1
  msg # %commandname is now turned ON
 }
  else {
  msg # %commandname is already turned ON
  }
}

if ($2 == off) {
 if (%commandname.switch != $null) {
  unset -g %commandname.switch
  msg # %commandname is now turned OFF
 }
  else {
  msg # %commandname is already turned OFF
  }
}
}

on *:TEXT:%commandname:#: {
 if (%commandname.switch == 1) { 
  msg # %commandoutput
 } 
  else {
  msg # Sorry but %commandname is currently turned OFF
  }
}

Posted By: Fonic_Artes Re: (Twitch) Turning commands on and off - 23/05/16 01:28 AM
Pulling from my greetings thing since I have it in a on/off state as well.

This should give a general idea.
Code:
on *:notice:*:#: {
  var %file = data\Greetings\greetings_ [ $+ [ $mid(#,2) ] ] $+ .ini
  var %check = $ini(%file,$nick)
  var %greeting = $readini(%file,n,$nick,greeting)
  if (!%check) { halt }
  if (%greeting_ [ $+ [ $mid(#,2) ] $+ _ [ $+ [ $nick ] ] ]) { halt }
  if ((%check) && (!%global. [ $+ [ $mid(#,2) ] ])) {
    var %greet = $replace(%greeting, @game, $followGame($nick))
    set %greeting_ $+ $mid(#,2) $+ _ $+ $nick On
    msg # /me %greet
  }
}

This shows the on/off switch implemented. I also have the same with an ON TEXT event since /me is considered a NOTICE.

This is my on/off code.
Code:
on *:text:!greet*:#: {
  if (!$2) { msg # /me - To enable greetings use <!greet on>. To disable greetings use <!greet off>. }
  if (($nick != $mid(#,2)) && ($nick != fonic_artes)) { halt }
  if ($2 == on) { 
    msg # /me - Greetings are enabled.
    unset %global. $+ $mid(#,2) 
  }
  if ($2 == off) {
    msg # /me - Greetings are disabled, un-used greetings won't trigger.
    set %global. $+ $mid(#,2) On
  } 

This sets a global on/off for greetings. (This is just from something I made a while back.)
© mIRC Discussion Forums