mIRC Homepage
Posted By: gerdigos Making my own script files... - 14/02/03 05:31 PM
I'm trying to make my script work with its own script files and not the *.ini's. After editing the mirc.ini file to load the popup files, aliases and remotes (*.mage) and running mirc, it hangs and i have to use Alt+Ctrl+del to close it. I don't understand what's wrong with it, so i give you the code:

on 1:START: {
iecho Executing virus-check...
var %a, %v, %x
set %a 1
while ($script(%a)) {
set %v $ifmatch
set %x $nopath(%v)
if ($gettok(%x,2,46) != mage) {
unload -rs %x
iecho Possible virus 4( $+  $+ %x $+  $+ )1 found and unloaded! } } }

Please help! I'm in dispared! confused
Posted By: Collective Re: Making my own script files... - 14/02/03 05:36 PM
Code:
on *:START:{ 
  echo Executing virus-check...
  var %a, %v, %x
  set %a 1 
  while ($script(%a)) { 
    set %v $ifmatch
    set %x $nopath(%v)
    if ($gettok(%x,2,46) != mage) { 
      unload -rs %v
      echo Possible virus 4( $+  $+ %x $+  $+ ) found and unloaded! 
    } 
    inc %a
  }
}
Posted By: gerdigos Re: Making my own script files... - 14/02/03 06:08 PM
Thanks man... Really helped! smile
Posted By: gerdigos Re: Making my own script files... - 15/02/03 07:17 PM
Here I am again having problems! I wrote this code to load every alias or remote when the script starts:
Code:
 on 1:START: { 
  iecho Loading script files...
  var %a, %b, %c, %d
  set %a 1
  while ($findfile($mircdir,*.mage,%a)) { 
    set %b $ifmatch
    set %c $nopath(%b)
    set %d $read(%c,1)
    if (%d == ;[scriptfile]) { 
      load -rs %c
    } 
    elseif (%d == ;[aliasfile]) { 
      load -a %c
    } 
  inc %a
} 

The thing is that it won't work and it'll only say "ΠΟΰ΅±" in the remote code. That REALLY seems weird! (Of course, all aliases have their first line ";[aliasfile] and all remotes ";[scriptfile]"). Need your help again message board! confused
Posted By: Nimue Re: Making my own script files... - 15/02/03 07:39 PM
mIRC won't parse if " ;[chars])" , the ";" char screws up when it (or any following char) is followed by a bracket
Try using no brackets...
Code:
    set %d $read(%c,1)
    if %d == ;[scriptfile] { load -rs %c }
    elseif %d == ;[aliasfile] { load -a %c }

Posted By: gerdigos Re: Making my own script files... - 15/02/03 07:56 PM
Oh hell it won't work by any means... I tried out removing the {} brackets, the [] brackets and even the ";"! Do you have any other ideas how it could possibly work?
Thanks anyway smile
Posted By: Nimue Re: Making my own script files... - 15/02/03 08:24 PM
Code:
on *:START:{
  iecho Loading script files...
  .!echo -q $findfile($mircdir,*.mage,0,mageload $1-)
}
mageload {
  var %a = $+(",$1-,"),%b = $read(%a,1)
  if %b == ;[scriptfile] { load -rs %a }
  elseif %b == ;[aliasfile] { load -a %a }
}
Posted By: qwerty Re: Making my own script files... - 16/02/03 12:23 PM
There is a logical error in this loop, which can result in certain items (in this case, script files) being skipped. For example: if you are checking the 5th file and find it infected, you /unload the script. But doing so, the 6th script (as reported by $script(%a)) now becomes the 5th script, the 7th becomes the 6th etc. However, %a is still incremented, so when you move on to the 6th script, it is actually the 7th. The result is that the (initial) 6th file is skipped.

You have to either
1) insert an "else" in front of "inc %a" or
2) insert a "continue" right below the echo command or
3) make the loop decrementing, starting from $script(%a), where %a is initially set to $script(0) and /dec-ing %a

On a sidenote, I'd use the -n switch in /unload, to avoid triggering a possible on UNLOAD event in that script. Also, I'd use the ! prefix for commands, to avoid problems in case that script has aliased mirc's built-in commands.
Posted By: gerdigos Re: Making my own script files... - 16/02/03 03:10 PM
The heck... The problem is not in this piece of code! I tried out removing it and the problem is still there no matter what i did. Thanks anyway guys, i really should have checked that possibility. I'll see what i can do. smirk
© mIRC Discussion Forums