mIRC Home    About    Download    Register    News    Help

Print Thread
Help Reloading Scripts #209577 18/02/09 06:41 AM
Joined: Dec 2007
Posts: 24
T
Tzar469 Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Dec 2007
Posts: 24
Hi. I'm trying to write an alias that will reload all of my bot's scripts. The problem I'm having is that it only reloads the first loaded script.

Code:
alias rehash {
  var %rehash 1
  while (%rehash <= $script(0)) { reload -rs $script(%rehash) | inc %rehash }
}


Any help is appreciated.

Last edited by Tzar469; 18/02/09 06:41 AM.
Re: Help Reloading Scripts [Re: Tzar469] #209578 18/02/09 06:57 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
I'm wondering what you need this behaviour for? /reload does not trigger any special behaviour that would make it useful unless in the special case where you edit your script files outside of mIRC's script editor-- is this the case?


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: Help Reloading Scripts [Re: Tzar469] #209579 18/02/09 06:59 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I think it's only doing the one script because as soon as the current script (with the rehash alias) is reloaded, it starts over from square one.

Try this
Code:
alias rehash {
  var %a = $script(0)
  while $script(%a) && ($script(%a) != $script) {
    .reload -rs $script(%a)
    dec %a
  }
}


Re: Help Reloading Scripts [Re: argv0] #209601 19/02/09 01:11 AM
Joined: Dec 2007
Posts: 24
T
Tzar469 Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Dec 2007
Posts: 24
Originally Posted By: argv0
I'm wondering what you need this behaviour for? /reload does not trigger any special behaviour that would make it useful unless in the special case where you edit your script files outside of mIRC's script editor-- is this the case?


Yes; my bot is currently hosted on a server to which I only have FTP access to. I update the scripts on my own computer then upload it to the bot.

Originally Posted By: RusselB
I think it's only doing the one script because as soon as the current script (with the rehash alias) is reloaded, it starts over from square one.

Try this


Your guess is correct; my own code worked perfectly when I moved it to the aliases.ini file.

The only problem I had with your code was that it reloaded every file except the file where the code was located. :P I fixed it by adding .reload -rs $script after the while loop. It worked while in the remotes section after that so I thank you for it! smile

Last edited by Tzar469; 19/02/09 01:13 AM.