mIRC Home    About    Download    Register    News    Help

Print Thread
#162414 17/10/06 07:17 PM
Joined: Oct 2006
Posts: 9
V
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
V
Joined: Oct 2006
Posts: 9
I made this script to play random songs or random songs by a keyword... I got confused while making it.
any help would be nice, or if theres a better way to do it would be nice.
(cant get it to play by keyword, dunno what I did wrong)

Code:
on *:text:.random*:#:{
  if (!$2) {
    timers off
    randsong1
  }
  elseif ($2) {
    timers off
    randsong2
  }
}
alias randsong1 {
  set %play.num $rand(1,$findfile(C:\My\Music\File, * ,*))
  set %song.loc $findfile(C:\My\Music\File, * ,%play.num)
  set %song $remove(%song.loc,C:\My\Music\File,.mp3)
  splay %song.loc
  msg $chan 12[14 Playing  $+ %song 12][14 $asctime($round($calc( $insong.length / 1000),0),nn:ss) 12]
  timerRAND 1 $round($calc( $insong.length / 1000),0) randsong1
}
alias randsong2 {
  set %part $2-
  set %play.num $rand(1,$findfile(C:\My\Music\File, * $+ $replace(%part,$chr(32),$chr(42)) $+ * ,*))
  set %song.loc $findfile(C:\My\Music\File, * %part * ,%play.num)
  set %song $remove(%song.loc,C:\My\Music\File,.mp3)
  splay %song.loc
  msg $chan 12[14 Playing  $+ %song 12][14 $asctime($round($calc( $insong.length / 1000),0),nn:ss) 12]
  timerRAND 1 $round($calc( $insong.length / 1000),0) randsong2
}

Joined: Oct 2006
Posts: 9
V
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
V
Joined: Oct 2006
Posts: 9
not sure if this is the best way but I
fixed it or atleast keywords work now.

Code:
on *:text:.random*:#:{
  if (!$2) {
    timers off
    randsong1
  }
  elseif ($2) {
    timers off
    set %part $replace($2-,$chr(32),$chr(42))
    randsong2
  }
}
alias randsong1 {
  set %play.num $rand(1,$findfile(C:\My\Music\File\, * ,*))
  set %song.loc $findfile(C:\My\Music\File\, * ,%play.num)
  set %song $remove(%song.loc,C:\My\Music\File\,.mp3)
  splay %song.loc
  msg $chan 12[14 Playing  $+ %song 12][14 $asctime($round($calc( $insong.length / 1000),0),nn:ss) 12]
  timerRAND 1 $round($calc( $insong.length / 1000),0) randsong1
}
alias randsong2 {
  set %play.num $rand(1,$findfile(C:\My\Music\File\, * $+ $replace(%part,$chr(32),$chr(42)) $+ * ,*))
  set %song.loc $findfile(C:\My\Music\File\, * $+ %part $+ * ,%play.num)
  set %song $remove(%song.loc,C:\My\Music\File\,.mp3)
  splay %song.loc
  msg $chan 12[14 Playing  $+ %song 12][14 $asctime($round($calc( $insong.length / 1000),0),nn:ss) 12]
  timerRAND 1 $round($calc( $insong.length / 1000),0) randsong2
}

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Glad to hear you got it working by yourself.

Here's an alternative suggestion
Code:
 on *:text:.random*:#:{
  .timers off
  randsong $+ $iif(!$2,1,2)
}
alias randsong1 {
  set %song.loc $findfile(C:\My\Music\File,*.mp3,$r(1,$findfile(C:\My\Music\File,*.mp3 ,0)))
  set %song $nopath(%song.loc)
  splay %song.loc
  msg $chan 12[14 Playing  $+ %song 12][14 $asctime($round($calc( $insong.length / 1000),0),nn:ss) 12]
  timerRAND 1 $round($calc( $insong.length / 1000),0) randsong1
}
alias randsong2 {
  set %part $replace($2-,$chr(32),$chr(42))
  set %play.num $r(1,$findfile(C:\My\Music\File, $+(*,%part,*.mp3),0))
  set %song.loc $findfile(C:\My\Music\File, * %part * ,%play.num)
  set %song $nopath(%song.loc)
  splay %song.loc
  msg $chan 12[14 Playing  $+ %song 12][14 $asctime($round($calc( $insong.length / 1000),0),nn:ss) 12]
  timerRAND 1 $round($calc( $insong.length / 1000),0) randsong2
}
 

Joined: Oct 2006
Posts: 9
V
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
V
Joined: Oct 2006
Posts: 9
yikes, tried that one and it went crazy lol
dont know if i pasted or edited it right.

**edited it again and it works good :tongue:
just need to add a $remove to get rid of .mp3 or is there another way to do that too :tongue:

Last edited by Vengeance; 18/10/06 02:25 PM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
If there is another way, then I'm not aware of it. Sorry I forgot about removing the file extension.

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
theres several methods...

1 of the 2 is

$left($nopath(path/filename.mp3),-4)

$left command or $right command either only shows you the Nth requested or erases the Nth requested.

Then $remove($nopath(Path/Filename.mp3),.mp3)

:P Theres even about 7 more ways to do it $regex being another method.


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Also im not sure if you want a new song to start all the time everytime someone types .random so I created a small if $insong return statement else play a random song + I added a menu to the channel where you right click in a channel and select your MP3 Dir for more flexibility

smile

Code:
menu Channel {
  Rand Set:{ %r.dir = $sdir($mircdir,Select Mp3 Dir) | %r.xam = $findfile(%r.dir,*.mp3,0)  }
}

On *:TEXT:.random*:#:{
  if ($insong) { return }
  else { %r.play = $findfile(%r.dir,*.mp3,$rand(1,%r.xam)) | splay %r.play  | msg $chan I am currently playing $left($nopath(%r.play),-4) - $+(Lenght:,$asctime($round($calc($insong.length /1000),0),n:ss)) }
}


try that.


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Link Copied to Clipboard