Home   Help Search Login Register  

Author Topic: ambience sound loop. [Solved]  (Read 2562 times)

0 Members and 1 Guest are viewing this topic.

Offline Grimfist

  • Members
  • *
    • Armaholic
ambience sound loop. [Solved]
« on: 28 May 2009, 16:36:26 »
I have got a sound called 'battleambience' in my sound folder of my mission, i want it to play looping constatly everywhere on the map.i have found a script but dont know how to use it.

-this is my description
Code: [Select]
class CfgSounds
{
// List of sounds (.ogg files without the .ogg extension)
sounds[] = {battleambience, battleabience2, Allah, fire, wind};

// Definition for each sound
class battleambience
{
name = "battleambience"; // Name for mission editor
sound[] = {\sound\battleambience.ogg, db + 0, 1.0};
titles[] = {0, ""};
};
class battleabience2
{
name = "battleabience2"; // Name for mission editor
sound[] = {\sound\battleabience2.ogg, db + 0, 1.0};
titles[] = {0, ""};
};
class Allah
{
name = "Allah"; // Name for mission editor
sound[] = {\sound\Allah.ogg, db + 0, 1.0};
titles[] = {0, ""};
};
class fire
{
name = "fire"; // Name for mission editor
sound[] = {\sound\fire.ogg, db + 0, 1.0};
titles[] = {0, ""};
};
class wind
{
name = "wind"; // Name for mission editor
sound[] = {\sound\wind.ogg, db + 0, 1.0};
titles[] = {0, ""};
};
};


-this is the script
Code: [Select]
_i = 0
#loop
_i = _i + 1
playmusic "battleambience"
~15 - the length of the song
? (_i <= 5): goto "end"
goto "loop"

#end
ForceEnd

what do i do? ty
« Last Edit: 28 May 2009, 18:15:19 by Grimfist »

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: ambience sound loop.
« Reply #1 on: 28 May 2009, 16:42:47 »
By the looks of it, I'd dump that script into an .sqs file, and call it from your init.sqf (presuming you want it to begin at mission start), or into a trigger's "On Activation" line.

Do bear in mind, that script will only play the loop 5 times.  For an infinite loop, you'd want:

Code: [Select]
#loop
playmusic "battleambience"
~15
goto "loop"

Possibly including some way to escape the loop if you want to stop the sound (e.g. a global variable):

Code: [Select]
#loop
playmusic "battleambience"
~15
? (stopMusic==1): goto "end"
goto "loop"

#end
ForceEnd

Offline Grimfist

  • Members
  • *
    • Armaholic
Re: ambience sound loop.
« Reply #2 on: 28 May 2009, 16:55:17 »
so would the .ogg need to bee in the music folder? (to hear it everywhere)

and how do i call it from the init?

ty for your fast reply

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: ambience sound loop.
« Reply #3 on: 28 May 2009, 17:00:24 »
It'll need to be in whatever directory (relative to the mission.sqm file) you specified in the config.  So, in your case, that would appear to be the 'sound' folder (though I've not really looked at your config other than that).

To call an SQS script, use the exec command, e.g.:
Code: [Select]
exec "myscript.sqs"
If you already have an init.sqf file, then you can just add an equivalent line to that file.  However, if you don't have one, just make a file called "init.sqf" in the same directory as "mission.sqm", and put the relevant bit in there.

Offline Grimfist

  • Members
  • *
    • Armaholic
Re: ambience sound loop.
« Reply #4 on: 28 May 2009, 17:28:24 »
hi ty but i have an error.

the black box appears in the corner and says
Quote
'exec |#| ''scripts/ambienceloop''
Error missiong ;

do i have to do anything in the mission editor with a trigger?

this is what i have so far:

INIT
Code: [Select]
; ****************************************************************
; Initialization script for Armed Assault
; This is a special INIT script file that runs before the
; mission briefing is displayed.
; ****************************************************************

exec "Scripts\Ambienceloop.sqs"

GRIM_CivKilled = 0;

mando_splash = compile preprocessFileLineNumbers "mando_splash.sqf";

if (Param1 == 1) then {dustoff =true} else {dustoff = false};

[[w1,w2,w3,w4,w5,w6],["w1","w2","w3","w4","w5","w6"]] execVM "HULK_REV\run.sqf";

exit

DESCRIPTION
Code: [Select]
// NOTE: Your sound/radio files must be in the ...\mission\sound
// folder and your music files in the ...\mission\music folder.
class CfgMusic
{
// List of tracks (.ogg files without the .ogg extension)
tracks[] = {Track1, battleabience2, battleambience};

// Definition for each sound
class Track1
{
name = "IntroSong"; // Name for mission editor
sound[] = {\music\Track1.ogg.ogg, db + 0, 1.0};
titles[] = {0, ""};
};
class battleabience2
{
name = "battleabience2"; // Name for mission editor
sound[] = {\music\battleabience2.ogg, db + 0, 1.0};
titles[] = {0, ""};
};
class battleambience
{
name = "battleambience"; // Name for mission editor
sound[] = {\music\battleambience.ogg, db + 0, 1.0};
titles[] = {0, ""};
};
};

AMBIENCELOOP.SQF
Code: [Select]
; ****************************************************************
; Script file for Armed Assault
; Created by: Grimfist
; ****************************************************************

#loop
playmusic "battleambience"
~15
goto "loop"


Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: ambience sound loop.
« Reply #5 on: 28 May 2009, 17:33:19 »
You need a semi-colon at the end of the exec command (sorry, I forgot to include it in my sample).

Try:
Code: [Select]
exec "Scripts\Ambienceloop.sqs";

Offline Grimfist

  • Members
  • *
    • Armaholic
Re: ambience sound loop.
« Reply #6 on: 28 May 2009, 17:35:44 »
no it still does the error.
« Last Edit: 28 May 2009, 17:40:24 by Grimfist »

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: ambience sound loop.
« Reply #7 on: 28 May 2009, 17:46:53 »
I don't really call SQS scripts very often, but you may have to do your call to exec like this, instead:
Code: [Select]
[] exec "Scripts\Ambienceloop.sqs";
Edit: A quick test confirmed this...  Just goes to show how often I call SQS scripts :D
« Last Edit: 28 May 2009, 17:48:28 by JamesF1 »

Offline Grimfist

  • Members
  • *
    • Armaholic
Re: ambience sound loop.
« Reply #8 on: 28 May 2009, 17:54:35 »
ah cool, it works ty. ty m8!