Jump to content
  • 0

Sensor (trigger) for a sound effect


Anhor

Question

How does a trigger looks like for a sound effect?

Whats my opinion: play a sound if a player enters a defined area, nothing else

What I know, no need of explanation:

need a ogg file

set it to description under sounds

All I wanna know is how looks the trigger in mission.sqf

Thx a lot for help!

Link to comment
Share on other sites

22 answers to this question

Recommended Posts

  • 0

I don't know about sounds that you've defined in your description.ext, but to use a trigger to play one of the default game files is easy.

At the end of your init.sqf

execVM "custom\sounds.sqf";

sounds.sqf

_this = createTrigger ["EmptyDetector", [4745.3726, 9848.3877, 0]];
_this setTriggerActivation ["WEST", "PRESENT", false];
_this setSoundEffect ["$NONE$", "", "", "arabian_market_4"];
_trigger_8 = _this;

_this = createTrigger ["EmptyDetector", [4748.3286, 9843.6758, -3.0517578e-005]];
_this setTriggerActivation ["WEST", "PRESENT", false];
_this setSoundEffect ["$NONE$", "", "", "arabian_market_3"];
_trigger_9 = _this;

_this = createTrigger ["EmptyDetector", [4728.0806, 9877.7363, 0]];
_this setTriggerActivation ["WEST", "PRESENT", false];
_this setSoundEffect ["$NONE$", "", "", "arabian_market_2"];
_trigger_10 = _this;

_this = createTrigger ["EmptyDetector", [4731.271, 9873.1924, 0.00012207031]];
_this setTriggerActivation ["WEST", "PRESENT", false];
_this setSoundEffect ["$NONE$", "", "", "arabian_market_1"];
_trigger_11 = _this;

_this = createTrigger ["EmptyDetector", [4735.2783, 9866.6201, 0]];
_this setTriggerActivation ["WEST", "PRESENT", false];
_this setSoundEffect ["$NONE$", "", "", "Muslim_prayer2"];
_trigger_12 = _this;

That code is just from the test we ran, can't find the final product sorry.

But basically if you get near the defined area you'll hear those noises. Made a pretty cool atmosphere for my mates 'Taki Trader'.

To place the trigger in the editor, just start like you'd normally do for adding buildings, but instead of the F5 key for vehicles use the trigger one instead.

Hope that helps.

Link to comment
Share on other sites

  • 0

Unfortunately, it is not quite what I am looking for. To better explain what I am about:

class Sensors
    {
        items=3;
        class Item0
        {
            position[]={9478,0,4458};
            a=100;
            b=100;
            activationBy="WEST";
            repeating=1;
            interruptable=1;
            age="UNKNOWN";
            name="radzone1";
            expCond="(player distance radzone1) < 150;";
            expActiv="TitleText[""The radiation counter starts clicking..."",""PLAIN DOWN""]; DZE_Quarantine = true;";
            expDesactiv="TitleText[""The radiation dose decreas..."",""PLAIN DOWN""]; DZE_Quarantine = false;";
            class Effects
            {
            };
        };

This is a sensor in mission.sqf ......... as you can see he gives a text message to the corresponding client that triggered him.
That is exactly what I want to achieve ....... just with a sound instead of a text message.

Since I have actually no idea of scripting, at any rate I think that, my question to the specialists ........ is this possible?

 

Link to comment
Share on other sites

  • 0
20 minutes ago, Anhor said:

Unfortunately, it is not quite what I am looking for. To better explain what I am about:


class Sensors
    {
        items=3;
        class Item0
        {
            position[]={9478,0,4458};
            a=100;
            b=100;
            activationBy="WEST";
            repeating=1;
            interruptable=1;
            age="UNKNOWN";
            name="radzone1";
            expCond="(player distance radzone1) < 150;";
            expActiv="TitleText[""The radiation counter starts clicking..."",""PLAIN DOWN""]; DZE_Quarantine = true;";
            expDesactiv="TitleText[""The radiation dose decreas..."",""PLAIN DOWN""]; DZE_Quarantine = false;";
            class Effects
            {
            };
        };

This is a sensor in mission.sqf ......... as you can see he gives a text message to the corresponding client that triggered him.
That is exactly what I want to achieve ....... just with a sound instead of a text message.

Since I have actually no idea of scripting, at any rate I think that, my question to the specialists ........ is this possible?

 

so you want to execute a custom sound in a place,  not a existing sound from arma2oa.

Link to comment
Share on other sites

  • 0
1 minute ago, Anhor said:

This is absolutly helpful! Thx juan!

 

i remember some time ago i made an script about a gypsie and for fun i was added a sound trigger , same as you want who sayid : "hey bro can you give me a money"  or something like this.... but i cannot find the code for the sound.

Link to comment
Share on other sites

  • 0

Get the trigger working ........... very nice .......... the reaction of players are priceless *lol*

Another question ....... I hope I do not get on the nerves ......... it is impossible to set more than radzones?

I have three, but only the last is working. Here´s my code from the mission.sqm

class Sensors
	{
		items=3;
		class Item0
		{
			position[]={9478,0,4458};
			activationBy="WEST";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			name="radzone1";
			expCond="(player distance radzone1) < 150;";
			expActiv="TitleText[""The radiation counter starts clicking..."",""PLAIN DOWN""]; DZE_Quarantine = true;";
			expDesactiv="TitleText[""The radiation dose decreas..."",""PLAIN DOWN""]; DZE_Quarantine = false;";
			class Effects
			{
			};
		};
		class Item1
		{
			position[]={6475, 0, 9304};
			activationBy="WEST";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			name="radzone2";
			expCond="(player distance radzone2) < 80;";
			expActiv="TitleText[""The radiation counter starts clicking..."",""PLAIN DOWN""]; DZE_Quarantine = true;";
			expDesactiv="TitleText[""The radiation dose decreas..."",""PLAIN DOWN""]; DZE_Quarantine = false;";
			class Effects
			{
			};
		};
		class Item2
		{
			position[]={3951, 0, 8458};
			activationBy="WEST";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			name="radzone3";
			expCond="(player distance radzone3) < 100;";
			expActiv="TitleText[""Here is a strange radiation!"",""PLAIN DOWN""]; DZE_Quarantine = true;";
			expDesactiv="TitleText[""The strange feeling is gone..."",""PLAIN DOWN""]; DZE_Quarantine = false;";
			class Effects
			{
			};
		};
	};
};

 

Link to comment
Share on other sites

  • 0

@Anhor  you can try this:

sensors:

Spoiler

class Sensors
	{
		items=3;
		class Item0
		{
			position[]={9478,0,4458};
			a=100;
			b=100;
			activationBy="WEST";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			name="radzone1";
			expCond="(vehicle player) in thislist;";
			expActiv="radzone1 = [] execVM ""custom\radzone\radzone_init.sqf"";";
			expDesactiv="terminate radzone1; titleText [""The strange feeling is gone..."", ""PLAIN DOWN""];";
			class Effects
			{
			};
		};
		class Item1
		{
			position[]={6475, 0, 9304};
			a=100;
			b=100;
			activationBy="WEST";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			name="radzone2";
			expCond="(vehicle player) in thislist;";
			expActiv="radzone2 = [] execVM ""custom\radzone\radzone_init.sqf"";";
			expDesactiv="terminate radzone2; titleText [""The strange feeling is gone..."", ""PLAIN DOWN""];";
			class Effects
			{
			};
		};
	class Item2
		{
			position[]={3951, 0, 8458};
			a=100;
			b=100;
			activationBy="WEST";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			name="radzone3";
			expCond="(vehicle player) in thislist;";
			expActiv="radzone3 = [] execVM ""custom\radzone\radzone_init.sqf"";";
            expDesactiv="terminate radzone3; titleText [""The strange feeling is gone..."", ""PLAIN DOWN""];";
			class Effects
			{
			};
		};
	};

 

radzone_init.sqf  (place into mpmissions\your instance\custom\radzone\)

Spoiler

//DZE_Quarantine = true;
//systemChat("The radiation counter starts clicking...");






//add anything you want for example.. u can remove the DZE_quarentine and add:

private ["_timerad"];
_timerad = 30;

systemChat("The radiation counter starts clicking...");

_nul = [objNull, player, rSAY, "radsound"] call RE; //this gonna add a .ogg sound but you need to define it in description.ext and create the ogg radsound

sleep _timerad;

systemChat("Your will die in this place...");


sleep _timerad;


systemChat("You feel sick...");

    [] spawn {
            hint "ahhhh";			
            Remove_Drug_effects =
            {
                    {
                            ppEffectDestroy _x;
                    } forEach (_this select 0);
                    ppEffectDestroy nonapsi_ef;
                    ppEffectDestroy wetdist1;
                    ppEffectDestroy ppe;
                    ppEffectDestroy ppe2;
                    ppEffectDestroy ppe3;
                    setaperture 0;
                    "dynamicBlur" ppEffectAdjust [0];
                    "dynamicBlur" ppEffectCommit 16;
                    "colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, 1],  [1, 1, 1, 0.0]];
                    "colorCorrections" ppEffectCommit 0;
            };
            _time = time;
            _effects = [];			
            while {true} do
            {
                    nonapsi_ef = ppEffectCreate ["colorCorrections", 1555];
                    _effects = _effects + [nonapsi_ef];
                    nonapsi_ef ppEffectEnable true;
                    nonapsi_ef ppEffectAdjust [1.0, 1.0, -0.03, [0.0, 0.0, 0.0, 0.0], [3.0, 5.0, 9.0, 5.0],[0.4,0.0,0.0, 0.7]];
                    nonapsi_ef ppEffectCommit 1;
                    sleep random(1);
                    wetdist1 = ppEffectCreate ["wetDistortion", 2006];
                    _effects = _effects + [wetdist1];
                    wetdist1 ppEffectAdjust [0, 8, 0.8,8,8, 0.2, 1, 0, 0, 0.08, 0.08, 0, 0, 0, 0.77];
                    wetdist1 ppEffectEnable true;
                    wetdist1 ppEffectCommit 0;
                    ppe = ppEffectCreate ["colorCorrections", 1555];
                    _effects = _effects + [ppe];
                    ppe ppEffectAdjust [1, 1, 0, [1.5,6,2.5,0.5], [5,3.5,5,-0.5], [-3,5,-5,-0.5]];
                    ppe ppEffectCommit 1;
                    ppe ppEffectEnable true;
                    ppe2 = ppEffectCreate ["chromAberration", 1555];
                    _effects = _effects + [ppe2];
                    ppe2 ppEffectAdjust [0.01,0.01,true];
                    ppe2 ppEffectCommit 1;
                    ppe2 ppEffectEnable true;
                    ppe3 = ppEffectCreate ["radialBlur", 1555];
                    _effects = _effects + [ppe3];
                    ppe3 ppEffectEnable true;
                    ppe3 ppEffectAdjust [0.02,0.02,0.15,0.15];
                    ppe3 ppEffectCommit 1;
                    sleep random(1);
                    wetdist1 = ppEffectCreate ["wetDistortion", 2006];
                    _effects = _effects + [wetdist1];
                    wetdist1 ppEffectAdjust [1, 1.16, 0.32, 2.56, 0.8, 0.64, 2.64, 0, 0, 1.08, 0.08, 0, 0, 0, 1.77];
                    wetdist1 ppEffectEnable true;
                    wetdist1 ppEffectCommit 0;
                    sleep random(1);
                    nonapsi_ef = ppEffectCreate ["colorCorrections", 1555];
                    _effects = _effects + [nonapsi_ef];
                    nonapsi_ef ppEffectEnable true;
                    nonapsi_ef ppEffectAdjust [1.0, 1.0, -0.02, [9.5, 1.5, 2.5, 0.2], [2.0, 7.0, 6.0, 2.0],[0.4,0.0,0.0, 0.7]];
                    nonapsi_ef ppEffectCommit 1;
                    sleep random(1);
                    if (_time + 10 < time) exitWith {[_effects] call Remove_Drug_effects;};
            };
    };

sleep _timerad;
systemChat("You suffer an attack...");
r_player_unconscious = true; 
sleep 5;
r_player_unconscious = false; 
sleep _timerad;

titleText ["", "WHITE IN"];

systemChat("time to die...");
player setDamage 1;

 

 

Link to comment
Share on other sites

  • 0

Hey guys, I don't think the answer is in here for what I'm looking for.

Is there anyway to make a sensor on an object instead of a location? For example, I'm trying to get a snowman to sing to players. The players can deploy the snowman, so the location could be anywhere. And I have tried to use

if(_cursorTarget isKindOf "MAP_snowman") then 
	{
		_snowman = SNOWMANZ;
		s_player_snowman = player addAction [("<t color=""#00FFFF"">" + ("Do you want to build A SNOWMAN?!?")+"</t>"),"location\etc\snowmanSing.sqf",_snowman, 5, false, true];
	} else {
		player removeAction s_player_snowman;
		s_player_snowman = -1;
	};

But I have noticed that the snowman can not be seen by cursorTarget. So i'm now trying to make it a sound trigger, so whenever you are within 5 meters of a snowman it will sing.

Any idea?

Link to comment
Share on other sites

  • 0
2 hours ago, looter809 said:

Hey guys, I don't think the answer is in here for what I'm looking for.

Is there anyway to make a sensor on an object instead of a location? For example, I'm trying to get a snowman to sing to players. The players can deploy the snowman, so the location could be anywhere. And I have tried to use


if(_cursorTarget isKindOf "MAP_snowman") then 
	{
		_snowman = SNOWMANZ;
		s_player_snowman = player addAction [("<t color=""#00FFFF"">" + ("Do you want to build A SNOWMAN?!?")+"</t>"),"location\etc\snowmanSing.sqf",_snowman, 5, false, true];
	} else {
		player removeAction s_player_snowman;
		s_player_snowman = -1;
	};

But I have noticed that the snowman can not be seen by cursorTarget. So i'm now trying to make it a sound trigger, so whenever you are within 5 meters of a snowman it will sing.

Any idea?

try :

snow_init.sqf

Spoiler

msg = false;

_sleepSongTime = 10; //change by your sound time
while {true} do {
    private ["_pos","_allconditions","_inRange","_trigger"];
    
    
    
    _trigger = ["MAP_snowman"];
    _pos = getPosATL player;
    _allconditions = (nearestObjects [_pos, _trigger, 5]);
    _inRange = count _allconditions > 0;
    
    
    
    if  (_inRange) then {
        if (!msg) then {
            cutText ['singer snowman', 'PLAIN'];
            msg = true;
            
_nul = [objNull, player, rSAY, "snowsing"] call RE;
 sleep _sleepSongTime;  

   };
    } else {
 
    msg = false;
    };
};

go to init.sqf

find:

execFSM "\z\addons\dayz_code\system\player_monitor.fsm";

below add:

//portables clay	
[] execVM 'custom\snow_init.sqf';

in your description.ext  add the class sound  "snowsing" and create snowsing.ogg

 

then if works well,, every snowman in server will play a song if is a player around 5 mts

Link to comment
Share on other sites

  • 0

@looter809if u gonna use deployanything to  deploy the snow man... and you wanna use cursor target in fn_selfaction to start the sound then.

1-set the snowman deploy with deploy anything mod.

2-open your fn_selfactions.sqf and find:

if ((_cursorTarget isKindOf "Plastic_Pole_EP1_DZ") && {speed player <= 1}) then {

above it: paste

if ((_cursorTarget isKindOf "MAP_snowman") && {speed player <= 1}) then {
if (s_player_deploysnowman < 0) then {
    s_player_deploysnowman = player addAction ["<t color='#00FFFF'>Do you want to build A SNOWMAN</t>", "location\etc\snowmanSing.sqf.sqf", [], 5, false];
    };
} else {
    player removeAction s_player_deploysnowman;
    s_player_deploysnowman = -1;
    };	

now again in selfactions find:

} else {
	//Engineering

below paste:

player removeAction s_player_deploysnowman;
    s_player_deploysnowman = -1;

 

snowmanSing.sqf

Spoiler

_nul = [objNull, player, rSAY, "snowsing"] call RE;

in description.ext

if u dont have class sound:

find:

aiKills = 1;
diagRadio = 1;
diagHit = 1;

below paste:

class CfgSounds
{
snowsing[] =
    {
    snsing
    };
    class snsing
    {
    name="snsing";
    sound[]={location\etc\snowsing.ogg,0.9,1};
    titles[] = {};
    };    
};

if u already have a class Cfgsounds  just paste inside:

snowsing[] =
    {
    snsing
    };
    class snsing
    {
    name="snsing";
    sound[]={location\etc\snowsing.ogg,0.9,1};
    titles[] = {};
    };    

create the snowsing.ogg  and drop into location\etc

Link to comment
Share on other sites

  • 0

@juandayz I'll try the first suggestion.

But for the second suggestion, I tried it and the snowman is not seen by the player's cursor. You can visibly see it, just not detect it from cursorTarget. I can test this by pressing "I" with infiSTAR on the snowman and it doesn't do anything, where as pressing "I" on something like a house or a vehicle or even the 

MAP_t_picea1s

from the xmas tree script shows what it is in the systemchat

Link to comment
Share on other sites

  • 0
22 hours ago, looter809 said:

Anyway to make the song only sing to the person triggering it? It's nice to know it possible to have it sing globally, but right now I can hear the snowman song from 800m away when a player triggers it.

try

playSound "snowsing";

or

 [objNull,player,rSAY,"snowsing",30] call RE;

 

Link to comment
Share on other sites

  • 0
3 hours ago, looter809 said:

The 


[objNull,player,rSAY,"snowsing",30] call RE;

did not work, however; the 


playSound "snowsing";

did work. Thank you once again Juan!

yup, i not sure but i think playsound is only local.   so i guess only the player near of the snowman will listen the sound.

for all players maybe u can try: 

_nul = [objNull, player, rSAY, "snowsing",30] call RE;

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...