mIRC Home    About    Download    Register    News    Help

Print Thread
#231231 09/04/11 09:52 AM
Joined: Dec 2010
Posts: 89
D
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2010
Posts: 89
im suggesting something for the remote.
well, i have alot of scripts for my bot smile and when i join irc with both him and me, i always have to unload the scripts for me (i only want the scripts loaded on my bot) so i was wondering as well as an 'unload' option also an 'unloadall' to save me and probably others from having to take ages unloading all the scripts we have. and maybe a loadall command too would be useful smile

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
It seems to me that /remote on|off would suffice in your case?

But why not set up two "different" mIRC so you don't have to toggle at all (Either: two distinct installation folders containing a distinct mirc.ini file each, or: one mirc installation but two distinct shortcuts that use the "-i" command line option to point to different ini files)?

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
/unloadall is a very easy script that you can place in your aliases:

Code:
/unloadall var %i = 1 | while ($script(%i)) { unload -rs $v1 | inc %i }


How would a /loadall work? Once unloaded, mIRC doesn't know what "all" is. The only thing I could think of would be to pass "all" scripts in as arguments to the command, but that wouldn't make loading scripts all that much easier.

However, you could similarly write an alias /loadall that works for you:

Code:
/loadall {
  load -rs scriptX.mrc
  load -rs scriptY.mrc
  load -rs foobar.mrc
  ...
}


Note that this could support loading aliases and popups too, something a simple "/loadall <script> <script> <script>" syntax wouldn't be able to capture.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
There is a logical bug in your script.

Your script:

Code:
/unloadall var %i = 1 | while ($script(%i)) { unload -rs $v1 | inc %i }


If you have 5 scripts loaded, it will do this:

%i = 1
unload script 1
increase %i to 2
script 2 becomes script 1, script 3 becomes script 2, and so forth...
unload script 2, leaving script 1 loaded
..etc

You need to go backwards instead:

Code:
alias unloadall var %i = $script(0) | while (%i) { unload -rs $script(%i) | dec %i }

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Good catch, or you could not inc/dec at all and do:

Code:
/unloadall while ($script(1)) unload -rs $v1


Note that there's a logical bug in your script. Since it's a remote alias (alias prefix), it will be unloaded smile


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
/UnloadAll - Unloads all remote files, and saves the names to a file

/ReloadAll - Loads all scripts that were unloaded with /Unloadall and removes the file.

Place the following in the aliases section:
Code:
UnloadAll {
  if (!$script(0)) return
  if ($isfile(MyUnloadedScripts.txt)) .remove MyUnloadedScripts.txt
  while ($script(1)) {
    write MyUnloadScripts.txt $v1
    .unload -rs
  }
}
ReloadAll {
  if ($isfile(MyUnloadedScripts.txt)) {
    var %i = 1
    while ($read(MyUnloadedScripts.txt,n,%i)) {
      .load -rs $qt($v1)
      inc %i
    }
    .remove MyUnloadedScripts.txt
  }
}


There was a logical bug in my script that would attempt to remove MyUnloadedScripts.ini instead of .txt

Last edited by FroggieDaFrog; 10/04/11 07:31 AM.

I am SReject
My Stuff
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I think you want $v1 (or $qt($v1) ) in your unload command. smile


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
I do believe you are correct!


I am SReject
My Stuff
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
That script goes into an infinite loop. mIRC never has 0 scripts loaded. If you unload your final named script, it will automatically add a script with a generic name like "Script1.mrc." This is the reason I use a "while (%i)" loop instead of "while ($script(%i))"

Nice catch on the fact I've added a remote alias.. we need to combine your and my efforts:

Code:
unloadall var %i = $script(0) | while (%i) { unload -rs $script(%i) | dec %i }


To place in aliases.

Edit:

Froggie, your script has the same problem. while ($script(1)) { } will go into an infinite loop because mIRC never has 0 scripts loaded. Try it out yourself.

Last edited by hixxy; 10/04/11 02:03 PM.
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Fixed (I think):
Code:
UnloadAll {
  if (!$script(0)) return
  if ($isfile(MyUnloadedScripts.txt)) .remove MyUnloadedScripts.txt
  var %i = $script(0)
  while (%i) {
    write MyUnloadScripts.txt $script(%i)
    .unload -rs $qt($script(%i))
    dec %i
  }
}
ReloadAll {
  if ($isfile(MyUnloadedScripts.txt)) {
    var %i = 1
    while ($read(MyUnloadedScripts.txt,n,%i)) {
      .load -rs $qt($v1)
      inc %i
    }
    .remove MyUnloadedScripts.txt
  }
}


I am SReject
My Stuff
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Looks good to me, but you should use the 't' switch with $read() in case one of the scripts was just named as a number.

As you can see a script can be called just a number:

Code:
//write 1 | load -rs 1 | unload -rs 1 | remove 1


Link Copied to Clipboard