mIRC Homepage
Posted By: Artiiz Question about loading/unloading a script. - 05/10/15 07:16 PM
Hello,

So I've been trying to figure out a while, how to remove a part of a script in my mIRC Remote.

What I want it to do, is to remove this part:
Code:
alias todate {
  var %month = 10
  var %day = 06
  var %year = 2015

  var %todate = $calc($ctime($+(%day,-,%month,-,%year) 14:00:00) - $ctime)
  if (%todate < 0) {
    inc %year
    %todate = $calc($ctime($+(%day,-,%month,-,%year) 14:00:00) - $ctime)
  }
  return %todate
}
on 1:text:*stream*:#artiiz:{
  if ((%floodage) || ($($+(%,floodage.,$nick),2))) { return }
  set -u0 %floodage On
  set -u0 %floodage. $+ $nick On
  msg $chan @ $+ $nick Next stream starts in $replace($duration($todate($2,$3),2),hrs,h,hr,h,mins,m) $+
}


When I type like !unload !stream, in the Twitch chat.
Is this possible?
Yes it is possible if you add this code into an other file and load it you can use this code to !load <filename> and !unload <filename>.

e.g:

!load test.mrc (and inside the test.mrc file put the code that you want to load)

!unload test.mrc

Code:
ON *:TEXT:!*:#: {
  tokenize 32 $strip($1-)
  if ($1 == !load) {
    if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a file! | return }
    var %f = $mircdir $+ $remove($2,.mrc) $+ .mrc
    if (!$isfile(%f)) { .msg $chan ( $+ $nick $+ ): Error, The $qt($2) file does not exist! | return }
    if ($check_load(%f)) { .msg $chan ( $+ $nick $+ ): Error, The $qt($2) file is already loaded! | return }
    .load -rs $qt(%f)
    .msg $chan ( $+ $nick $+ ): The $qt($nopath(%f)) file has been loaded!
  }
  if ($1 == !unload) {
    if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a file! | return }
    var %f = $remove($2,.mrc) $+ .mrc
    if (!$check_load(%f).short) { .msg $chan ( $+ $nick $+ ): Error, The $qt($2) file is NOT loaded! | return }
    .unload -rs $qt(%f)
    .msg $chan ( $+ $nick $+ ): The $qt($nopath(%f)) file has been unloaded!
  }
}

alias check_load {
  if (!$1) { return }
  var %t = $script(0)
  var %i = 1
  while (%i <= %t) {
    var %f = $iif($prop == short,$nopath($script(%i)),$script(%i))
    if (%f == $1-) { return 1 }
    inc %i
  }
  return 0
}


NOTE: The filename must be into .mrc format and must be placed into the mirc.exe direction in order to work.
Hey,

Thanks alot for the help, everything seems to be working.
The only problem though is that, I want to make it say "!unload test.mrc" automatically when "twitchnotify" writes in mIRC chat "viewers resubscribed".

I've been trying on another Twitch account, and just writing "viewers resubscribed", with this script:
Code:
ON *:TEXT:*viewers resubscribed*:#artiiz:{
  msg $chan !unload test.mrc
}


But it doesn't unloads the script, unless I type it in my Twitch chat by my own, and not though mIRC.


Never mind, I managed to fix it smile
Originally Posted By: westor
Yes it is possible if you add this code into an other file and load it you can use this code to !load <filename> and !unload <filename>.

e.g:

!load test.mrc (and inside the test.mrc file put the code that you want to load)

!unload test.mrc

Code:
ON *:TEXT:!*:#: {
  tokenize 32 $strip($1-)
  if ($1 == !load) {
    if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a file! | return }
    var %f = $mircdir $+ $remove($2,.mrc) $+ .mrc
    if (!$isfile(%f)) { .msg $chan ( $+ $nick $+ ): Error, The $qt($2) file does not exist! | return }
    if ($check_load(%f)) { .msg $chan ( $+ $nick $+ ): Error, The $qt($2) file is already loaded! | return }
    .load -rs $qt(%f)
    .msg $chan ( $+ $nick $+ ): The $qt($nopath(%f)) file has been loaded!
  }
  if ($1 == !unload) {
    if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a file! | return }
    var %f = $remove($2,.mrc) $+ .mrc
    if (!$check_load(%f).short) { .msg $chan ( $+ $nick $+ ): Error, The $qt($2) file is NOT loaded! | return }
    .unload -rs $qt(%f)
    .msg $chan ( $+ $nick $+ ): The $qt($nopath(%f)) file has been unloaded!
  }
}

alias check_load {
  if (!$1) { return }
  var %t = $script(0)
  var %i = 1
  while (%i <= %t) {
    var %f = $iif($prop == short,$nopath($script(%i)),$script(%i))
    if (%f == $1-) { return 1 }
    inc %i
  }
  return 0
}


NOTE: The filename must be into .mrc format and must be placed into the mirc.exe direction in order to work.



Hey,

Thanks alot for the help, everything seems to be working.
The only problem though is that, I want to make it say "!unload test.mrc" automatically when "twitchnotify" writes in mIRC chat "viewers resubscribed".

I've been trying on another Twitch account, and just writing "viewers resubscribed", with this script:
Code:
ON *:TEXT:*viewers resubscribed*:#artiiz:{
  msg $chan !unload test.mrc
}


But it doesn't unloads the script, unless I type it in my Twitch chat by my own, and not though mIRC.
Sorry i don't own any Twitch account and i cant help you with this, probably anyone who has can help you with this, but try give me the full message that you receive from.
Originally Posted By: westor
Sorry i don't own any Twitch account and i cant help you with this, probably anyone who has can help you with this, but try give me the full message that you receive from.


Ahh okey smirk

I accidentaly removed the last script where I managed to fix it yesterday, and now I can't seem to remember how i did frown
Try to find it out and come back to help you.
Originally Posted By: westor
Try to find it out and come back to help you.


I've managed to come this far:
Code:
ON 1:TEXT:viewers:#artiiz:{
  tokenize 32 $strip($1-)
  if ($1 == viewers) {
    if ($2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a file! | return }
    var %f = $remove(test,.mrc) $+ .mrc
    if (!$check_load(%f).short) { .msg $chan ( $+ $nick $+ ): Error, The $qt($2) file is NOT loaded! | return }
    .unload -rs $qt(%f)
    .msg $chan ( $+ $nick $+ ): The $qt($nopath(%f)) file has been unloaded!
  }
}

alias check_load {
  if (!$1) { return }
  var %t = $script(0)
  var %i = 1
  while (%i <= %t) {
    var %f = $iif($prop == short,$nopath($script(%i)),$script(%i))
    if (%f == $1-) { return 1 }
    inc %i
  }
  return 0
}


The only problem now though is that I can't change the "viewers" to "*viewers resubscribed*".
I want it to be *viewers resubscribed* since the sentence "viewers resusbscribed" is not always the same.
But it doesn't work to put both *viewers resubscribed* into:
Code:
ON 1:TEXT:*viewers resubscribed*:#artiiz:{

And into:
Code:
  if ($1 == *viewers resubscribed*) {
I am going to the blind but give a try this code:

Place it in an new file from script editor in "Remotes" tab (File -> New)

Code:
ON *:TEXT:*:#artiiz:{
  tokenize 32 $strip($1-)
  if (viewers resubscribed isin $1-) {
    var %f = $remove(test,.mrc) $+ .mrc
    if (!$check_load(%f).short) { return }
    .unload -rs $qt(%f)
    echo -a The $qt($nopath(%f)) file has been unloaded!
  }
}

alias check_load {
  if (!$1) { return }
  var %t = $script(0)
  var %i = 1
  while (%i <= %t) {
    var %f = $iif($prop == short,$nopath($script(%i)),$script(%i))
    if (%f == $1-) { return 1 }
    inc %i
  }
  return 0
}
Originally Posted By: westor
I am going to the blind but give a try this code:

Place it in an new file from script editor in "Remotes" tab (File -> New)

Code:
ON *:TEXT:*:#artiiz:{
  tokenize 32 $strip($1-)
  if (viewers resubscribed isin $1-) {
    var %f = $remove(test,.mrc) $+ .mrc
    if (!$check_load(%f).short) { return }
    .unload -rs $qt(%f)
    echo -a The $qt($nopath(%f)) file has been unloaded!
  }
}

alias check_load {
  if (!$1) { return }
  var %t = $script(0)
  var %i = 1
  while (%i <= %t) {
    var %f = $iif($prop == short,$nopath($script(%i)),$script(%i))
    if (%f == $1-) { return 1 }
    inc %i
  }
  return 0
}


It did worked.
I am so grateful for your help and for you spending time trying to help out smile
Thanks alot <3
© mIRC Discussion Forums