Jump to content
SGT Major Ray Jefferson

Deactivate sound ACE3 in area and play music with radio and trigger ?

Recommended Posts

Hello, for my mission I deactivate the sound and reactivate the sound using 2 triggers:

-Trigger 1 Condition: call{this} Enable: call{ace_hearing_disableVolumeUpdate = false;}

-Trigger 2 Condition: call this Enable: call{ace_hearing_disableVolumeUpdate = true; 0 fadeSound 0;}

In this mission, a radio plays music init radio: _soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString; _soundToPlay = _soundPath + "Sounds\Resonance.ogg"; playSound3D [_soundToPlay, this, false, getPosASL this, 5, 1, 40];

The problem is that my radio no longer plays music, when trigger 2 is activated. I thought of 2 solutions:

-1 I deactivate and reactivate the sound in a given area.

-2 I activate the radio music via a trigger. I searched but I did not find the script or the command I need. Do you have an idea ?

Thank you

Share this post


Link to post
Share on other sites

playSound3D works through the game's sound channel, and since you're deactivating the sound with 0 fadeSound 0, you won't hear anything out of the radio.

 

If you play your sound using say3D instead, you can set the isSpeech parameter to true, where the game will play the sound over the speech channel independently from fadeSound.

 

Make sure your custom sound is defined in description.ext through cfgSounds and then play your sound like this:

 

TAG_myRadio say3D ["resonance", 40, 1, true, 0];

 

Where TAG_myRadio is your radio object, "resonance" is your sound file defined in description.ext, 40 is the max audible distance (might want to increase this), 1 is the pitch, true is the fadeSpeech parameter, and 0 is the sound offset.

  • Like 2

Share this post


Link to post
Share on other sites

Thank you it works, however the music does not restart, once passed, I would like it to restart.
I am also looking to create a hold action on the radio that deactivates the music.
After several tests, it is normal that a soldier on the floor of the radio does not hear the music if he turns his back to the radio ?

Share this post


Link to post
Share on other sites

In order to loop the sound you'll have to execute the Say3D command again once the sound becomes null. I would recommend doing this in another script and not in the radio's init for readability.

 

Make a script called playMusicRadio.sqf and place the following inside:

TAG_radioOn = true;
_TAG_song = _this #0;

if (isServer) then
{
  // adds the action to every client and JIP
  [
      TAG_myRadio,							// Object the action is attached to
      "Turn off radio",							// Title of the action
      "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",	// Idle icon shown on screen
      "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",	// Progress icon shown on screen
      "_this distance _target < 3",					// Condition for the action to be shown
      "_caller distance _target < 3",					// Condition for the action to progress
      {},								// Code executed when action starts
      {},								// Code executed on every progress tick
      { 
        TAG_radioOn = false; 						// Code executed on completion
        publicVariable "TAG_radioOn";
        removeAllActions TAG_myRadio;
      },	
      {},								// Code executed on interrupted
      [],								// Arguments passed to the scripts as _this select 3
      3,								// Action duration in seconds
      999,								// Priority
      true,								// Remove on completion
      false								// Show in unconscious state
  ] remoteExec ["BIS_fnc_holdActionAdd", 0, TAG_myRadio];		// MP compatible implementation
};

while {TAG_radioOn} do
{
  _TAG_soundSource = TAG_myRadio say3D [_TAG_song, 40, 1, true, 0];
  waitUntil {(isNull _TAG_soundSource) || !(TAG_radioOn)};
};

deleteVehicle _TAG_soundSource;


Then, place the following in the radio's init:

nul = ["resonance"] execVM "playMusicRadio.sqf";

 

That should do the trick.

 

_____________________________________

 

6 hours ago, SGT Major Ray Jefferson said:

After several tests, it is normal that a soldier on the floor of the radio does not hear the music if he turns his back to the radio ?

 

This is probably because your song file is stereo. For positional audio to work as intended, you should make sure it's a mono .ogg file.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you, but even in mono the problem is still there, I also get an error on line 36 of the PlayMusicRadio.sqf:

deleteVehicle _TAG_soundSource;

Variable not defined in TAG_soundSource expression
By changing this line I no longer have the sound problem :
_TAG_soundSource = TAG_myRadio say3D [_TAG_song, 60, 1, false, 0];

Share this post


Link to post
Share on other sites
9 hours ago, SGT Major Ray Jefferson said:

I also get an error on line 36 of the PlayMusicRadio.sqf:

deleteVehicle _TAG_soundSource;


My mistake. If you remove the underscore before all three instances of _TAG_soundSource it should correct the issue. (The error happens because the sound source is a local variable due to the underscore, and it is defined inside the while loop, but is undefined outside the loop's scope. Without the underscore, it becomes a global variable that is defined in all scopes. See here for more info if you're interested.)
 

Spoiler

TAG_radioOn = true;
_TAG_song = _this #0;

if (isServer) then
{
  // adds the action to every client and JIP
  [
      TAG_myRadio,							// Object the action is attached to
      "Turn off radio",							// Title of the action
      "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",	// Idle icon shown on screen
      "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",	// Progress icon shown on screen
      "_this distance _target < 3",					// Condition for the action to be shown
      "_caller distance _target < 3",					// Condition for the action to progress
      {},								// Code executed when action starts
      {},								// Code executed on every progress tick
      { 
        TAG_radioOn = false; 						// Code executed on completion
        publicVariable "TAG_radioOn";
        removeAllActions TAG_myRadio;
      },	
      {},								// Code executed on interrupted
      [],								// Arguments passed to the scripts as _this select 3
      3,								// Action duration in seconds
      999,								// Priority
      true,								// Remove on completion
      false								// Show in unconscious state
  ] remoteExec ["BIS_fnc_holdActionAdd", 0, TAG_myRadio];		// MP compatible implementation
};

while {TAG_radioOn} do
{
  TAG_soundSource = TAG_myRadio say3D [_TAG_song, 40, 1, true, 0];
  waitUntil {(isNull TAG_soundSource) || !(TAG_radioOn)};
};

deleteVehicle TAG_soundSource;

 

 

9 hours ago, SGT Major Ray Jefferson said:

Thank you, but even in mono the problem is still there


Unfortunately it seems to be a common problem with the game, especially if you have any kind of surround sound.

Share this post


Link to post
Share on other sites

The music should already restart itself automatically. Unless you mean starting the radio back up after you've turned it off.

In that case, change your PlayMusicRadio.sqf file to this:
 

TAG_radioOn = true;
_TAG_song = _this #0;

if (isServer) then
{
  // adds the action to every client and JIP
  [
      TAG_Radio,							// Object the action is attached to
      "Turn off radio",							// Title of the action
      "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",	// Idle icon shown on screen
      "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",	// Progress icon shown on screen
      "_this distance _target < 3",					// Condition for the action to be shown
      "_caller distance _target < 3",					// Condition for the action to progress
      {},								// Code executed when action starts
      {},								// Code executed on every progress tick
      { 
        TAG_radioOn = false; 						// Code executed on completion
        publicVariable "TAG_radioOn";
        [TAG_Radio] remoteExec ["removeAllActions", 0];
      },	
      {},								// Code executed on interrupted
      [],								// Arguments passed to the scripts as _this select 3
      3,								// Action duration in seconds
      999,								// Priority
      true,								// Remove on completion
      false								// Show in unconscious state
  ] remoteExec ["BIS_fnc_holdActionAdd", 0, TAG_Radio];		// MP compatible implementation
};

while {TAG_radioOn} do
{
  TAG_soundSource = TAG_Radio say3D [_TAG_song, 50, 1, false, 0];
  waitUntil {(isNull TAG_soundSource) || !(TAG_radioOn)};
};

deleteVehicle TAG_soundSource;

if (isServer) then
{
  // adds the action to every client and JIP
  [
      TAG_Radio,							// Object the action is attached to
      "Turn on radio",							// Title of the action
      "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",	// Idle icon shown on screen
      "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",	// Progress icon shown on screen
      "_this distance _target < 3",					// Condition for the action to be shown
      "_caller distance _target < 3",					// Condition for the action to progress
      {},								// Code executed when action starts
      {},								// Code executed on every progress tick
      { 
        [TAG_Radio] remoteExec ["removeAllActions", 0];
        nul = ["resonance", "playMusicRadio.sqf"] remoteExec ["execVM", 0];
      },	
      {},								// Code executed on interrupted
      [],								// Arguments passed to the scripts as _this select 3
      3,								// Action duration in seconds
      999,								// Priority
      true,								// Remove on completion
      false								// Show in unconscious state
  ] remoteExec ["BIS_fnc_holdActionAdd", 0, TAG_Radio];		// MP compatible implementation
};

 

Now you'll have an action to turn the radio back on after turning it off.

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

×