mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2015
Posts: 10
B
Pikka bird
OP Offline
Pikka bird
B
Joined: Mar 2015
Posts: 10
Hey,
really new to mIRC, I'm using it to run a bot for my Twitch.tv Channel.
Current script:
Click to reveal..
Quote:
on *:text:!startuptime:#: {
if ((%floodstartuptime) || ($($+(%,floodstartuptime.,$nick),2))) { return }
set -u600 %floodstartuptime On
set -u600 %floodstartuptime. $+ $nick On
msg # Stopping Downtime. Starting uptime.
set -e %uptime. [ $+ [ # ] ] $ctime
unset %downtime. [ $+ [ # ] ] $+
}

on *:text:!uptime:#: {
if ((%flooduptime) || ($($+(%,flooduptime.,$nick),2))) { return }
set -u300 %flooduptime On
set -u300 %flooduptime. $+ $nick On

msg # /me Uptime: $duration($calc($ctime - %uptime. [ $+ [ # ] ] )) $+
}

on *:text:!stopuptime:#: {
if ((%floodstopuptime) || ($($+(%,floodstopuptime.,$nick),2))) { return }
set -u600 %floodstopuptime On
set -u600 %floodstopuptime. $+ $nick On
msg # Stopping uptime. Starting downtime.
unset %uptime. [ $+ [ # ] ] $+
set -e %downtime. [ $+ [ # ] ] $ctime
}

on *:text:!downtime:#: {
if ((%flooddowntime) || ($($+(%,flooddowntime.,$nick),2))) { return }
set -u300 %flooddowntime On
set -u300 %flooddowntime. $+ $nick On

msg # /me Downtime: $duration($calc($ctime - %downtime. [ $+ [ # ] ] )) $+
}


How can I disable a command (!downtime) after a different command has been activated (!startuptime)?
Is there an alternative way of doing this?
Thank you

Joined: Nov 2014
Posts: 79
N
Babel fish
Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
You can do that by setting a variable which turns on whenever staruptime is used, and turned off when stopuptime is typed.

Code:
on *:TEXT:!startuptime:#: {
  set %uptimeon On 
  REST OF SCRIPT...
}

on *:TEXT:!stoptime:#: {
  unset %uptimeon
  REST OF SCRIPT...
}

on *:TEXT:!downtime:#: {
  if (!%uptimeon) {
     REST OF SCRIPT...
  }
  else {
     msg # I am live so there is no need for downtime. 
  }
}

Last edited by Newbie; 11/03/15 02:09 PM.
Joined: Mar 2015
Posts: 10
B
Pikka bird
OP Offline
Pikka bird
B
Joined: Mar 2015
Posts: 10
Thank you so much for the quick response! It's not working though, can't see why.
Am I missing a bracket somewhere?

Click to reveal..
Code:
on *:text:!startuptime:#: {
  set %uptimeon On 
  unset %downtimeon
  if ((%floodstartuptime) || ($($+(%,floodstartuptime.,$nick),2))) { return }
  set -u600 %floodstartuptime On
  set -u600 %floodstartuptime. $+ $nick On
  msg # Stopping Downtime. Starting uptime.
  set -e %uptime. [ $+ [ # ] ] $ctime
  unset %downtime. [ $+ [ # ] ] $+
}

on *:text:!uptime:#: { 
  if (!%downtimeon) {
    unset %uptimeon
    if ((%flooduptime) || ($($+(%,flooduptime.,$nick),2))) { return }
    set -u300 %flooduptime On
    set -u300 %flooduptime. $+ $nick On
    msg # /me Uptime: $duration($calc($ctime - %uptime. [ $+ [ # ] ] )) $+
  }
  else {
    msg # I am currently offline. Duh
    }
}

on *:text:!stopuptime:#: { 
  set %downtimeon On
  unset %uptimeon
  if ((%floodstopuptime) || ($($+(%,floodstopuptime.,$nick),2))) { return }
  set -u600 %floodstopuptime On
  set -u600 %floodstopuptime. $+ $nick On
  msg # Stopping uptime. Starting downtime.
  unset %uptime. [ $+ [ # ] ] $+
  set -e %downtime. [ $+ [ # ] ] $ctime 
}

on *:text:!downtime:#: { 
  if (!%uptimeon) {
    if ((%flooddowntime) || ($($+(%,flooddowntime.,$nick),2))) { return }
    set -u300 %flooddowntime On
    set -u300 %flooddowntime. $+ $nick On

    msg # /me Downtime: $duration($calc($ctime - %downtime. [ $+ [ # ] ] )) $+
  }
  else {
    msg # I am currently live. Duh  }
}


Last edited by Brolaire; 11/03/15 02:28 PM.
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Alternately, with your style of event triggers, you can simply wrap each one in a #group directive, and use the /.enable and /.disable commands.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Nov 2014
Posts: 79
N
Babel fish
Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
I think your problem comes from the fact that you unset the variable when you type !uptime. Also, is there any particular reason why you also need a downtime variable? Since uptimeon is active only when you're live, I don't think you really need a downtime variable.

Code:
on *:text:!startuptime:#: {
  set %uptimeon On 
  if ((%floodstartuptime) || ($($+(%,floodstartuptime.,$nick),2))) { return }
  set -u600 %floodstartuptime On
  set -u600 %floodstartuptime. $+ $nick On
  msg # Stopping Downtime. Starting uptime.
  set -e %uptime. [ $+ [ # ] ] $ctime
  unset %downtime. [ $+ [ # ] ] $+
}
on *:text:!uptime:#: { 
  if (!%uptime) {
    msg # I am currently offline
  }
  else {
    if ((%flooduptime) || ($($+(%,flooduptime.,$nick),2))) { return }
    set -u300 %flooduptime On
    set -u300 %flooduptime. $+ $nick On
    msg # /me Uptime: $duration($calc($ctime - %uptime. [ $+ [ # ] ] )) $+
  }
    }
}
on *:text:!stopuptime:#: { 
  unset %uptimeon
  if ((%floodstopuptime) || ($($+(%,floodstopuptime.,$nick),2))) { return }
  set -u600 %floodstopuptime On
  set -u600 %floodstopuptime. $+ $nick On
  msg # Stopping uptime. Starting downtime.
  unset %uptime. [ $+ [ # ] ] $+
  set -e %downtime. [ $+ [ # ] ] $ctime 
}
on *:text:!downtime:#: { 
  if (!%uptimeon) {
    if ((%flooddowntime) || ($($+(%,flooddowntime.,$nick),2))) { return }
    set -u300 %flooddowntime On
    set -u300 %flooddowntime. $+ $nick On

    msg # /me Downtime: $duration($calc($ctime - %downtime. [ $+ [ # ] ] )) $+
  }
  else {
    msg # I am currently live. Duh  }
}


I might have accidently added a bracket or two but this in theory should work. Sorry, I'm not on my computer right now so I can't physically test it.

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Or just use /.enable and /.disable like I said. That's exactly what they were added for.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Link Copied to Clipboard