mIRC Home    About    Download    Register    News    Help

Print Thread
#247721 23/08/14 07:54 PM
Joined: Aug 2014
Posts: 32
S
Sparkz Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Aug 2014
Posts: 32
I am currently using a script to load and unload all the scripts and it doesnt seem to work. This is the script:

on $*:text:/^!(un)load$/:#:{
if ($regml(1) == un) {
var %i = 1
while ($script(%i) != $null) {
if ($script(%i) == $script) {
inc %i
continue
}
.unload -rs $qt($script(%i))
}
}
else { noop $findfile(<C:\Users\John John\Desktop\Bot>,*.mrc,0,.load -rs $qt($1-)) }
}

I would appreciate if someone could help me with this or write me another script to unload and load scripts on command. Thank you!

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Try use this code:

Code:
ON !*:TEXT:*:#: {
  if ($1 == !unload) {
    var %t = $script(0)
    while (%t) {
      var %s = $script(%t)
      if (%s !== $script) { .unload -rs $qt(%s) }
      dec %t
    }
  }
  if ($1 == !load) { noop $findfile($mircdir,*.mrc,0,.load -rs $qt($1-)) }
}


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Aug 2014
Posts: 32
S
Sparkz Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Aug 2014
Posts: 32
I'm having one issue with this. Where do I put the file name and does it have to be the full directory or can it just be the file name? Thank you so much for helping me out.

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
This working for all the *.mrc files that are in the $mircdir (mirc.exe directory) also you can try and this code maybe will help you more.

Replace it with the old.

Code:
ON !*:TEXT:*:#: {
  if ($1 == !unload) {
    var %t = $script(0)
    while (%t) {
      var %s = $script(%t)
      if (%s !== $script) { .unload -rs $qt(%s) }
      dec %t
    }
  }
  if ($1 == !load) { noop $findfile($scriptdir,*.mrc,0,.load -rs $qt($1-)) }
}


- Thanks!


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: May 2013
Posts: 140
R
Vogon poet
Offline
Vogon poet
R
Joined: May 2013
Posts: 140
Very helpful. How can this be used to load unload a specific script Ex raffle.mrc in the /scripts directory?

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Try replace it with this code:

Commands: !load [FILENAME] - !Unload [FILENAME] - !Loaded

NOTE: if not any parameter will be given on !load and !unload it will load/unload all the scripts that are in the $scriptdir (EXCEPT THIS CODE FILENAME)

Code:
ON !*:TEXT:*:#: {
  if ($1 == !unload) {
    if (!$2) {
      var %t = $script(0)
      while (%t) {
        var %s = $script(%t)
        if (%s !== $script) { .unload -rs $qt(%s) }
        dec %t
      }
    }
    elseif ($2) {
      var %f = $scriptdir $+ $2
      if (!$isfile(%f)) { .msg $chan [ $+ $nick $+ ]: Error, This file $qt($2) does NOT exist! | return }
      if (%f == $script) { .msg $chan [ $+ $nick $+ ]: Error, You cannot unload this file! | return }
      if (!$chk_script($nopath(%f))) { .msg $chan [ $+ $nick $+ ]: Error, This file $qt($2) is NOT loaded! | return }
      .msg $chan [ $+ $nick $+ ]: The file $qt($2) has been unloaded!
      .unload -rs $qt(%f)
    }
  }
  if ($1 == !load) { 
    if (!$2) {
      noop $findfile($scriptdir,*.mrc,0,.load -rs $qt($1-))
    }
    elseif ($2) { 
      var %f = $scriptdir $+ $2
      if (!$isfile(%f)) { .msg $chan [ $+ $nick $+ ]: Error, This file $qt($2) does NOT exist! | return }
      if ($chk_script($nopath(%f))) { .msg $chan [ $+ $nick $+ ]: Error, This file $qt($2) is already loaded! | return }
      .msg $chan [ $+ $nick $+ ]: The file $qt($2) has been loaded!     
      .load -rs $qt(%f)
    }
  }
  if ($1 == !loaded) {
    if (!$script(0)) { .msg $chan [ $+ $nick $+ ]: Error, There is NOT any files loaded! | return }
    .msg $chan [ $+ $nick $+ ]: Starting the list with loaded scripts, Please wait...
    var %t = $script(0)
    var %i = 1
    while (%i <= %t) {
      var %f = $script(%i)
      var %s = $nopath(%f)
      .msg $chan [# $+ %i $+ ]: -> File:  $+ %s $+  - Path:  $+ %f $+ 
      if (%i == %t) { .msg $chan [ $+ $nick $+ ]: End of loaded scripts list. }
      inc %i
    }
  }
}

alias chk_script {
  if (!$1) { return }
  var %f = $scriptdir $+ $1
  var %t = $script(0)
  var %i = 1
  while (%i <= %t) {
    var %s = $script(%i)
    if (%s == %f) { var %exist = 1 }
    if (%i == %t) { return $iif(%exist,%exist,0) }
    inc %i
  }
}


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-

Link Copied to Clipboard