OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Resources Beta Testing & Submission => Topic started by: johnnyboy on 17 Dec 2008, 00:39:29

Title: Sound Loop Function (Accepted)
Post by: johnnyboy on 17 Dec 2008, 00:39:29
JBOY_soundLoop is a simple function that will have an object say a sound repeatedly.  This is useful for any object that you want to play a sound continously (say a radio playing a song loop, or a generator playing a generator noise, of flys buzzing around an outhouse, etc.). 

Here's a sample call:

Code: [Select]
dmy=[toilet, "fxFlies4secs", 3.95 , 10000] execvm "JBOY_soundLoop.sqf";   
Parameter 1: Object that will "say" the sound.
Parameter 2: Name of sound in quotes from your description.ext.
Parameter 3: Length of sound in seconds.
Parameter 4: # of times to execute the loop.  For infinite, pass in -1.

Pretty simple, but useful to me, so maybe useful to someone else...

Sorry, Schuler--I know this is bad for my reputation--but this script does not blow anything up! ;)

Script Updated per Wolfrug's suggestions:

- Modified so that -1 in Parameter 4 will cause the loop to run infinitely (if object is alive).
- Modified loop to only Say the sound if player is within 250 meters to save on resources.

Attached file has been updated.

OFPEC Download (http://www.ofpec.com/ed_depot/index.php?action=details&id=592)
Title: Re: Sound Loop Function
Post by: Wolfrug on 17 Dec 2008, 10:19:47
I suggest you, instead of forcing people to put a "very large number" for infinite loops (this kind of script could be useful for looping a very very short sound too, especially in a long, or even infinite, mission - think Dynamic War), you script in that using for instance -1 will make it loop forever.

I suppose you could also put in a "distance check" if you really want to be fancy about it - right now it plays the sound whether you're close to it or not, which is a little unnecessary (eats up resources). A simple distance check to the player (who is the only one who can hear and appreciate the sounds anyway ;)) would solve that issue! Make it a variable for the user to pick, so that e.g. a looping song won't always randomly start from the beginning the moment the player gets close enough. :)

Looks good otherwise!

Wolfrug out.
Title: Re: Sound Loop Function
Post by: johnnyboy on 17 Dec 2008, 17:45:28
Great suggestions Wolfrug.  Will do!

Edit:  I implemented Wolf's suggestions, modified the first post, and attached the modified test mission.