mIRC Home    About    Download    Register    News    Help

Print Thread
'unloadall' scripts #231231 09/04/11 09:52 AM
Joined: Dec 2010
Posts: 89
D
dominic_eddy Offline OP
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

Re: 'unloadall' scripts [Re: dominic_eddy] #231232 09/04/11 10:37 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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)?

Re: 'unloadall' scripts [Re: dominic_eddy] #231237 09/04/11 06:04 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
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"
Re: 'unloadall' scripts [Re: argv0] #231254 10/04/11 01:14 AM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
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 }

Re: 'unloadall' scripts [Re: hixxy] #231257 10/04/11 04:28 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
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"
Re: 'unloadall' scripts [Re: dominic_eddy] #231261 10/04/11 07:29 AM
Joined: Apr 2010
Posts: 924
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 924
/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
Re: 'unloadall' scripts [Re: FroggieDaFrog] #231266 10/04/11 12:13 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
I think you want $v1 (or $qt($v1) ) in your unload command. smile


Invision Support
#Invision on irc.irchighway.net
Re: 'unloadall' scripts [Re: Riamus2] #231268 10/04/11 01:43 PM
Joined: Apr 2010
Posts: 924
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 924
I do believe you are correct!


I am SReject
My Stuff
Re: 'unloadall' scripts [Re: argv0] #231269 10/04/11 02:01 PM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
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.
Re: 'unloadall' scripts [Re: hixxy] #231272 10/04/11 02:20 PM
Joined: Apr 2010
Posts: 924
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 924
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
Re: 'unloadall' scripts [Re: FroggieDaFrog] #231274 10/04/11 04:47 PM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
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