mIRC Homepage

Help Reloading Scripts

Posted By: Tzar469

Help Reloading Scripts - 18/02/09 06:41 AM

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.
Posted By: argv0

Re: Help Reloading Scripts - 18/02/09 06:57 AM

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?
Posted By: RusselB

Re: Help Reloading Scripts - 18/02/09 06:59 AM

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
  }
}

Posted By: Tzar469

Re: Help Reloading Scripts - 19/02/09 01:11 AM

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
© 2022 mIRC Discussion Forums