mIRC Home    About    Download    Register    News    Help

Print Thread
#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.
Joined: Oct 2003
Posts: 3,918
A
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"
Joined: Aug 2004
Posts: 7,252
R
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
  }
}


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.

Link Copied to Clipboard