Jump to content
Sign in to follow this  
DutchVidya

addAction that plays sounds on units?

Recommended Posts

Ok, I have a mission for my group that we use for training players on functions of AGM and ACRE2. It's a Zeus enabled mission on the VR terrain so as to let us test and remove as much as we want. My issue is, I want to do something fun for the "Blufor Advisors" (who are units with Zeus access), so that they can mouse wheel to an action that plays one of four or so sound files telling the FNGs to be quiet. I've seen it done in A2, but I don't think the same method works for A3 as I tried a direct port of the SQF files involved there and was told my file did not exist.

There are four files, and they are as, far as I know, all declared properly under cfgSounds in Description.ext.

class CfgSounds
{
 sounds[] = {};
class up
{
 name = "up";
 sound[] = {"sounds\up.ogg", db-1, 1.0};
 titles[] = {};
};
class cunt
{
 name = "stfu";
 sound[] = {"sounds\stfu.ogg", db-1, 1.0};
 titles[] = {};
};
class shutit
{
 name = "shutit";
 sound[] = {"sounds\shutit.ogg", db-1, 1.0};
 titles[] = {};
};
class shutup
{
 name = "shutup";
 sound[] = {"sounds\shutup.ogg", db-1, 1.0};
 titles[] = {};
};
};

In my Init file I have began the steps to create the addaction on these units, but what steps do I need to take to add the sounds, make them play properly, and then make them work in MP?

It's 6 units who need to do this, all of them names man1 through 6. I have the beginning of the addAction, giving them the menu option:

man1 addAction [("<t color=""#C00000"">" + ("Achtung!") + "</t>"),

but obviously it needs to then run another SQF script to set the sounds off. So what the hell should that look like? Apologies if this seems very easy to some, I'm self taught for the most part, and whilst I can make missions that work well and all of that, doing these little side things always escapes me.

Edited by DutchVidya

Share this post


Link to post
Share on other sites

For your purposes I'd probably just use playSound3D as it requires no CfgSounds and has global effect (which removes a load of the hassle!).

man1 addAction ["<t color='#C00000'>Achtung!</t>",{playSound3D ["sounds\stfu.ogg",_this select 1];},[],1,false];

If you want the action to play one of the sound files at random then it'd look something like this (though there are other ways to do it):

man1 addAction ["<t color='#C00000'>Achtung!</t>",{playSound3D [["sounds\up.ogg","sounds\stfu.ogg","sounds\shutit.ogg","sounds\shutup.ogg"] call BIS_fnc_selectRandom,_this select 1];},[],1,false];

Edited by SilentSpike

Share this post


Link to post
Share on other sites

Ok, tested. No Sound, the addAction is there, it remains after it's selected, but I get no sound. I'm testing this in the Editor if that makes any difference, still no audio, and no script errors either.

Edited by DutchVidya

Share this post


Link to post
Share on other sites
Huh, I had no idea that was a thing. I'll test it and if it works you might be my new favourite person. I've sort of found myself the "Arma 3 guy" in my group, and all of our mission makers have more experience with A2 or have dropped the game all together, so it's been a real learning experience.

Question, what about letting them play the other sounds? Just add them after the first one?

EDIT:

Nope, no sound. Not even a script error.

Try using BIS_fnc_MP.

Something like this (untested)

unit1 addAction ["Play sound UP",{[["up",(_this select 0)],"glb_fnc_PlaySound",true] call BIS_fnc_MP]}];

In the init.sqf

glb_fnc_PlaySound = {
_sound = (_this select 0);
_unit = (_this select 1);
_unit say3D _sound;
}

Edited by BangaBob

Share this post


Link to post
Share on other sites

Thanks Banga, I'll give it a shot after work later. For the record, what is it here I need to change if anything? Given that I have 6 units, all of them named man1 through to man6?

Share this post


Link to post
Share on other sites
Thanks Banga, I'll give it a shot after work later. For the record, what is it here I need to change if anything? Given that I have 6 units, all of them named man1 through to man6?

Just change the addaction code. So add it to different units and change the sound names as needed and the Text to whatever.

unit2 addAction ["Play sound UP",{[["up",(_this select 0)],"glb_fnc_PlaySound",true] call BIS_fnc_MP]}]; 
unit4 addAction ["Play sound UP",{[["shutup",(_this select 0)],"glb_fnc_PlaySound",true] call BIS_fnc_MP]}]; 
unit3 addAction ["Play sound UP",{[["shutit",(_this select 0)],"glb_fnc_PlaySound",true] call BIS_fnc_MP]}]; 

Share this post


Link to post
Share on other sites
Ok, tested. No Sound, the addAction is there, it remains after it's selected, but I get no sound. I'm testing this in the Editor if that makes any difference, still no audio, and no script errors either.

My apologies. I know why there's no sound, here's the fixed code. If you have a question let me know:

man1 addAction ["<t color='#C00000'>Achtung!</t>",{    
   _soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString;
   _soundToPlay = _soundPath + "sounds\stfu.ogg";
   playSound3D [_soundToPlay,_this select 1];
},[],1,false];

As long as description.ext is present in your mission it should work fine.

Edit:

Again, this will play one of the 4 at random

man1 addAction ["<t color='#C00000'>Achtung!</t>",{    
   _soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString;
   _soundToPlay = _soundPath + (["sounds\up.ogg","sounds\stfu.ogg","sounds\shutit.ogg","sounds\shutup.ogg"] call BIS_fnc_selectRandom);
   playSound3D [_soundToPlay,_this select 1];
},[],1,false];

Edited by SilentSpike

Share this post


Link to post
Share on other sites

Hey guys, posting from work. One of our other mission makers tested both of these, he reports that now there are no addactions on the menu, and he gets a script error telling him there is a missing ";".

This feels like it should be easier. Maybe I did something wrong on my end.

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  

×