Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
roguetrooper

Trigger-alarm-sound does not stop when deleting trigger

Recommended Posts

Since the alarm sound of a trigger is heard only across a few houses/blocks within a city like Zargabad, I have placed several "Loudspeakers_EP1" and placed a trigger at the position of each speaker.

The triggers look like this:

* named "speakertrigger1" (2,3, etc) (in the NAME field, not the description field)
* activation condition: west discovered by east
* activation code: play the trigger-internal alarm sound

Beside the triggers that play the alarm sound, I have another trigger to stop that infinite alarm sound loop:

* activation condition: west discovered by east
* timer: 15-30 seconds
* activation code: {deletevehicle _x} forEach [speakertrigger1, speakertrigger2, etc];

When there is only ONE "speakertrigger" on the map, the alarm-sound stops, when that trigger gets deleted.

Problem:

When there are several "speakertriggers" on the map, the alarm-sound is still played (on the position of the according trigger), even when the trigger-delete-code is executed. I have checked this several times. All names etc are spelled correctly. I can't find any mistake. The problem is that the engine does not stop the alarm sound when there are SEVERAL alarm triggers playing that sound (and get deleted).

Share this post


Link to post
Share on other sites

It's working for me in my test. I did it in a slightly different way but it's ending the alarms for me. Instead of multiple detection triggers I have a single detection trigger which sets "alarmOn" value to true. The actual alarm triggers look for that value. There's a fourth trigger which also looks for that value and deletes the other triggers after 10 seconds. I've delayed the 2nd and 3rd triggers so you can clearly hear all three turning on.

Share this post


Link to post
Share on other sites

I've been wondering about this for a while. I love some of the alarm sounds within the triggers, but they never stop!

I'll have to try this version out Kylania because

1) You are a boss and your site is amazing

2) You say you got it to work.

Share this post


Link to post
Share on other sites

You can create a source of sound when the trigger is executed:

_soundOn = createSoundSource ["Sound_Alarm", position Loudspeaker, [], 0];

... and remove when no longer required:

deletevehicle _soundOn;

Greetings.

Share this post


Link to post
Share on other sites

Actually I have a variable in another trigger, too, that is set "true" when west is discovered and the alarm-triggers watch for that variable. My intention was to keep it easy here. But nevertheless only ONE of the alarm-triggers is deleted.

Question: how do I have to handle createSoundSource in multiplayer? The wiki does not say a word about that? Do I have to create it on every client?

There is another strange thing: when I place ALL the speakers and their triggers right in front of me (for testing purposes), they ALL seem to be deleted properly when the alarm is meant to be stopped. But when I distribute them across the town and teleport me to them by mapclick, they still sound on. :confused: (not the faintest little thing else is changed, no variable, no nothing, just the position of the speakers/triggers)

Share this post


Link to post
Share on other sites

createSoundSource doesn't list if it's local or not in the Biki unfortunately, though a talk comment seems to indicate it'll broadcast in MP. However you really don't need to use that command for sound. Trigger effects or say would work fine. createSoundSource seems to be more for ambient type sounds like dogs barking in an area rather than specific sounds.

With regards to the spread out alarms not turning off, is that with createSoundSource or with trigger effects? Because taking my example above even if you spread things out they still turn on and off as expected despite distance. However if I switch it to use createSoundSource and Raven's example above I get really flakey results. Sometimes the alarms turn off, sometimes they don't.

Share this post


Link to post
Share on other sites

Sorry for delay...

CreateSoundSource works perfectly in MP.

This script works always in my missions on dedicated servers.

The script generates a detection area for a specific side. When a unit enters that side, it triggers the alarm and stops the sound only when the unit is folded or left the area.

// *******************************************************************************
// **       Funcion: SetAlarm.sqf
// **   Description: Activate/Deactivate Alarm in zone
// *******************************************************************************
// **         Autor: RAVEN
// **       Example: nul = [side, object/center of the zone, Radius of zone] execVM "SetAlarm.sqf";
// **                 Side is: "WEST", "EAST", etc. (with quotes)
// **                nul = ["WEST", HQ1, 250] execVM "SetAlarm.sqf";
// *******************************************************************************

private ["_obj","_radar","_espera","_lista","_SoundOn","_activa","_esAir","_alarmOn"];

_side = _this select 0;
_obj  = _this select 1;
_dist = _this select 2;

_espera = false;
_activa = false;

_radar = createTrigger ["EmptyDetector", position _obj];
_radar setTriggerActivation [_side, "present", true];
_radar setTriggerArea [_dist, _dist, 0, true];
_radar setTriggerStatements ["this", "", ""];
_radar setTriggerText "zone of detection";
_radar setTriggerTimeout [0, 0, 0, false];
_radar setTriggerType "SWITCH";

while {true} do
{
_espera = true;
while {_espera} do
{
	_lista = list _radar;
	sleep 5.00;

	_alarmOn = false;
	if (count _lista > 0) then {_alarmOn = true};

	if (_alarmOn) then
	{
		if (not _activa) then
		{
			_soundOn = createSoundSource ["Sound_Alarm", getpos _obj, [], 0];
			_activa = true;
		};
	}
	else
	{
		if (_activa) then
		{
			deletevehicle _soundOn;
			_activa = false;
			_espera = false;
		};
	};
};
};

Edited by RAV_RAVEN

Share this post


Link to post
Share on other sites

That's not the issue, that's a single sound source. Everyone agrees that works fine. Nice script though. :)

The problem is the deletion, and stopping of sound, from multiple sound sources created by createSoundSource. Create 3 at a time in different places and try to delete them at the same time and one or more of them will keep playing sound even after they are "deleted" it seems.

Share this post


Link to post
Share on other sites

_null = [] spawn {
_sounds = [];
{
	_sound = createSoundSource ["Sound_Alarm", getpos _x, [], 0];
	_sounds = _sounds + [_sound];
} foreach [obj1,obj2,obj3,obj4,obj5];

sleep 5;
hint "deleting";
{
	player setPos (getPos _x);
	sleep 2;
	deleteVehicle _x;
	sleep 2;
} foreach _sounds;
hint "deleted";
};

it worked fine for me, no issue at all, all deleted fine, in SP editor, official 1.60, no beta.

NOTE: did test with all delete instantly after the "sleep 5" no wait, setpos wait, and it all got quiet when i wanted to.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×