Jump to content
Sign in to follow this  
reaper lok

3D sound not looping

Recommended Posts

So after reading many threads and posts regarding sound, say3D, playSound etc etc, I am stumped and even more confused than previously, lol

Here is what I am attempting to achieve;

I would like a 3D sound to play on a loop when a player is close to an object (continuous sound while player is within 8 feet etc).

I have the sound (listed within my description.ext) and I am fully capable of playing the 3D sound from said object (via a trigger), however, I cannot get the sound to play continuously?

Any help is greatly appreciated :)

Regards,

REAPER

Share this post


Link to post
Share on other sites

Forgive my probable not correct usages of commands, however, I'm just doing this in a directional sense, not a syntactically correct sense :p.

Couldn't you have your trigger with the condition of your 8ft distance and then in the onAct have a call to a script that looks like this:

//script call argument comes in as true

_playSoundVar = (_this select 0);

while (_playSoundVar) do {

playsound "blah"; //<<Like I said, whatever it is that plays the sound, don't know the exact syntax.
waitUntil {//code for "sound completed"};

};

//and then have the script call argument false in the onDeact of the trigger 

/*  Insert Code for stopping sound play here for when the while loop is not true  */

Like I said, sorry for the lack of actual script, but it's just an idea of structure to play off of.

EDIT: Was ninja'd by Dread :p, but if you want the sound to completely stop playing after the unit is out of range of it, meld the two ideas together :).

Share this post


Link to post
Share on other sites

No sense in having the sound being played by trigger activation or distance-based, this will cause duplicate sounds if a player runs in and out of the activation area. The absolute simplest way to do this is to have the sound playing constantly. Also, if you only want the sound heard within 8 meters, you should use playSound3D. Something like this would work nicely:

while {true} do
{
_distance = 8;
_volume = 50;
playSound3D ["mySound.ogg", _myUnit, false, getPos _myUnit, _volume, 1, _distance];
sleep (length of sound);
}; //you need to test _volume, because the smaller the distance the higher the volume needs to be for you to hear it.

Share this post


Link to post
Share on other sites
No sense in having the sound being played by trigger activation or distance-based, this will cause duplicate sounds if a player runs in and out of the activation area. The absolute simplest way to do this is to have the sound playing constantly. Also, if you only want the sound heard within 8 meters, you should use playSound3D. Something like this would work nicely:

while {true} do
{
_distance = 8;
_volume = 50;
playSound3D ["mySound.ogg", _myUnit, false, getPos _myUnit, _volume, 1, _distance];
sleep (length of sound);
}; //you need to test _volume, because the smaller the distance the higher the volume needs to be for you to hear it.

Would I be putting this code directly into the mission init.sqf file?

my .ogg file is called radio_9

the object I want to omit the sound is called gen_1

I will give this a try today - most appreciate the time you took to reply :) I will update this thread with my results!

Share this post


Link to post
Share on other sites

You can put this into the init.sqf, but make sure you are spawning ([] spawn {}) the code or else you're going to have a bad time.

Share this post


Link to post
Share on other sites
Plus read up on the mission root path - you'll need it or the sound can't be found:

http://killzonekid.com/arma-scripting-tutorials-mission-root/

I read Killzone Kids blog and have read many of his posts - he is the scripting kiddie for sure....however, I now feel even dumber for reading it, lol It is so complex for an amateur scripter like myself that I get lost after three words.

Mission maker = yes

Scripter = no

;)

Share this post


Link to post
Share on other sites

Hope you don't have special characters in your windows username aswell. Mission root path will screw up if you have special characters in your username. Use a custom path (arguably just putting the sound in C:\ or whatever your drive is is best) in that case.

Share this post


Link to post
Share on other sites
:butbut: And I was just gonna suggest you to look at createSoundSource, which would naturally loop the sound...

This is really funny. @REAPER "script kiddie" is a negative term so being called one is quite an insult. :p

Share this post


Link to post
Share on other sites
:butbut: And I was just gonna suggest you to look at createSoundSource, which would naturally loop the sound...

doesn't allow for anything outside cfgvehicles does it? haven't really used it, but OP has his sound in the description.ext so that wouldn't work, I assume.

Share this post


Link to post
Share on other sites
This is really funny. @REAPER "script kiddie" is a negative term so being called one is quite an insult. :p

lol, might have been lost in translation. Where I come from being called the kiddie at something means you are the man! I was attempting to suggest that Killzone Kid is the authority on script issues, however, I am not at that level as to implement some of these suggestions. I am operating at more of a drag and drop level ;)

Sorry if I inadvertently offended.

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
Sign in to follow this  

×