mIRC Home    About    Download    Register    News    Help

Print Thread
#155532 07/08/06 12:18 PM
Joined: Jun 2006
Posts: 79
B
Babel fish
OP Offline
Babel fish
B
Joined: Jun 2006
Posts: 79
Code:
 
alias openque { 
  if (!$window(@Que)) { .window -n @que }
  else { halt } 
} 
ON ^*:TEXT:*:#:{
  if ($right($1,4)
  if (@find == $1) {
    .set %theitem $2
    .searchitem
  }
  if (@ $+ $me == $1) {
    .set %iwant $remove($2,.mp3)
    .set %name $nick
    .openque
    .doublecheck
  }
  if ($right($1,4) == -que) {
    .CheckQue
    .set %QueNick $nick
  }
}
alias CheckQue {
  .set %qqq $fline(@que,* $+ %QueNick $+ *) 
  If (%qqq == $null) { halt }
  Else { .msg $nick Your que number is ( $+ %qqq $+ / $+ %MaxQue $+ ) }
  .unset %QueNick
}
alias doublecheck {
  var %:file = item.txt
  if (!$read(%:file,w,* $+ %name $+ * $+ %iwant $+ *)) { .sendto }
  else { .msg %name Your files ( $+ %iwant $+ ) already requested. }
  var %:file2 = mp3.txt
  if (!$read(%:file2,w,* $+ %iwant $+ *)) { .msg $nick Invalid request }
}
alias searchitem { 
  var %n = 1
  while (%n <= $findfile(%mp3dir,* $+ %theitem $+ *.mp3,0)) { msg $nick @ $+ $me $nopath($findfile(%mp3dir,* $+ %theitem $+ *.mp3,%n))
    inc %n
  } 
}
alias sendto {
  var %sendx = 1 
  while (%sendx <= $findfile(%mp3dir,* $+ %iwant $+ *.mp3,0)) { write item.txt %name $findfile(%mp3dir,* $+ %iwant $+ *.mp3,%sendx)
    inc %sendx
    approve
  }
}
alias approve { 
  .aline @Que $nick
  inc %quenum 1
  msg $nick Thx for requesting %iwant $+ .mp3 Que( $+ %quenum $+ / $+ %MaxQue $+ ) Slot( $+ %sendingnow $+ / $+ %myslot $+ ) Available.
  .giveit
}
alias giveit {
  if (%sendingnow == 0) { 
    .sendnow
    inc %sendingnow 1
  }
  if (%sendingnow <= %myslot) { 
    .sendnow
    inc %sendingnow 1
  }
}
alias sendnow { 
  var %n = $read(hantar.txt,1) 
  %name = $gettok(%n,1,32) 
  %item = $gettok(%n,2,32) 
  .set %temp.name $gettok(%n,1,32)
  .set %temp.item $gettok(%n,2,32)
  .dcc send %name %item 
  .write -dl1 hantar.txt
  .inc %sendingnow 1
}
on *:filesent:*:{
  .echo -a 8- Complete sending %temp.item to %temp.name -
  .dec %sendingnow 1
  .dec %quenum 1
  .sendnow
}
on *:sendfail:*:{
  echo -a 8- Sending %temp.item to %temp.name was Incomplete -
}
 


Please comment to make my codes better or easier. Thanks laugh

#155533 07/08/06 05:54 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Starting at the top and working my way down:
1) The else statement in your first alias is irrelevant
2) Your first if statement in the ON TEXT event is missing a brace, a close bracket (aka parantheses) (and possibly a comparator, depending on if you want to actually compare it to something or if you just want to ensure that $1 has 4 or more characters)
3) Your if statement in the CheckQue alias can be re-written as
Code:
if %qqq { .msg $nick Your que number is ( $+ %qqq $+ / $+ %MaxQue $+ ) }  

4) Your Giveit alias can be re-written as
Code:
 alias giveit {
  if !%sendingnow ||  (%sendingnow <= %myslot) {
    .sendnow
    inc %sendingnow 1
  }
} 


That's all that I was able to see that, in my opinion, could/needs to be done to improve the script.

P.S.: If you plan on sharing this script with others, some comments/remarks about what each portion does would be a good idea, as well as something stating your name as the author and a method of getting ahold of you (usually an e-mail address) in case people have trouble with your script.

#155534 08/08/06 11:58 AM
Joined: Jun 2006
Posts: 79
B
Babel fish
OP Offline
Babel fish
B
Joined: Jun 2006
Posts: 79
Thanks to RusselB. Ah anyway this codes written by me (banjirian@ni3). I wanna ask why the else statement in first alias is irrelevant? I think else is useless there right ? Anyway thanks again smile .


Link Copied to Clipboard