Jump to content
DiaZ35

How I can make this script a loop?

Recommended Posts

As, tite says. How I can easly make this script a loop?

 

playSound3D ["a3\music_f_mark\music\leadtrack01_f_mark.ogg", r1,    false, getPos r1, 10, 1, 50];

 

Share this post


Link to post
Share on other sites
while {true} do
{
	playSound3D ["a3\music_f_mark\music\leadtrack01_f_mark.ogg", r1,    false, getPos r1, 10, 1, 50];
	sleep 30;  // Change this to however many seconds the sound file is.
};

 

  • Like 2

Share this post


Link to post
Share on other sites

duration 2:38

You can see that, running:   utils4   in debug console.

The tracks are ordered by addons, so find music_f_mark then your track.

  • Like 2

Share this post


Link to post
Share on other sites

@johnnyboy When I apply this script to a radio, the music is very loud and plays several songs at once and the music does not loop.

Share this post


Link to post
Share on other sites
50 minutes ago, DiaZ35 said:

@johnnyboy When I apply this script to a radio, the music is very loud and plays several songs at once and the music does not loop.

which code you run exactly?

Share this post


Link to post
Share on other sites

Normal. I'm surprised you didn't crash to desktop.

The init field of an object/unit is unscheduled. The code can't support a sleep or a waitUntil condition. You must spawn or execVM that.

 

You need to write:

0 = [] spawn {
  while {true} do {
     playSound3D ["a3\music_f_mark\music\leadtrack01_f_mark.ogg", r1,    false, getPos r1, 10, 1, 50];
     sleep 158;
  };
};

 

  • Like 5

Share this post


Link to post
Share on other sites

Yes, I actually got a crash to my desktop a few times, but then I managed to start this up to experience this bug. Thanks a lot for your help.

  • Like 1

Share this post


Link to post
Share on other sites

 

I have a new question. Is it possible to set several songs in this script that will loop?

Share this post


Link to post
Share on other sites

Hey man, that's possible! 🙂
You just need to add more "playSound3D" lines into the loop for each track you would like to play and keep in mind to add a "sleep" command after each of them. The number after sleep is the time in seconds the loop should wait before continuing, in this case you should at least let it sleep for the duration of the previous track.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×