Home   Help Search Login Register  

Author Topic: Random music  (Read 1036 times)

0 Members and 1 Guest are viewing this topic.

USI Rfox7

  • Guest
Random music
« on: 13 Jul 2003, 13:23:00 »
ok guys and gals here is the deal i have a intro to a map with 2 songs.
Now i want ofp to choose a random song at the start of the intro.

here is what i have



 _songs = ["xl_intro1","xl_inro"]
 _rndsong = random (count _songs)
 _rndsong = _rndsong - (_rndsong mod 1)    
 _song = _songs select _rndsong
playmusic _song


now it will play the 1st song in the list when it is choosen (xl_intro1)
but when it chooses to play the 2nd song (xl_inro) i hear nothing.

yes the description.ext is right
b/c if i switch the 2 songs from
_songs = ["xl_intro1","xl_inro"]
to
_songs = ["xl_intro","xl_inro1"]
it does the same thing it will play the 1st song listed and not the 2nd when it is choosen.

hope i have explained it well enough
and plz if you can help it sure would be nice and thx

CrashnBurn

  • Guest
Re:Random music
« Reply #1 on: 14 Jul 2003, 13:57:24 »
Here's a random music script I made and it works just fine. Maybe it'll help ?

_music = ["track3","track5","Rtrack5","track7","Rtrack9","track15","track13","Rtrack2"]
_track = _music select (random 7)
playmusic _track

DeathBringer

  • Guest
Re:Random music
« Reply #2 on: 14 Jul 2003, 15:29:35 »
Hey Bud,

I missed ya. U almost had it right.

---> random.sqs

#start

_songs = ["first", "second", "third", "fourth"]

_rndsong = (random (count _songs)) - 0.5

_song = _songs select _rndsong
   
playSound _song

#exit

----->  description.ext

class CfgSounds
{
   sounds[] =
      {
         first, second, third, fourth
      };
   class first
   
   {
      name = "first";
      sound[] = {"first.ogg", 1, 1.0};
      titles[] = {   };
   };
   class second
   
   {
      name = "second";
      sound[] = {"second.ogg", 1, 1.0};
      titles[] = {   };
   };
   class third
   
   {
      name = "third";
      sound[] = {"third.ogg", 10, 1.0};
      titles[] = {   };
   };
   class fourth
   
   {
      name = "fourth";
      sound[] = {"fourth.ogg", 10, 1.0};
      titles[] = {   };
   };
};


---> then a trigger!

a=0
b=0
trigger for ONCE only
Condition = true
Activation = this exec "random.sqs"
         
works great! remember sound file sizes though. lol   ;D

« Last Edit: 14 Jul 2003, 15:43:28 by DeathBringer »