PrizraK11 0 Posted February 3 When creating a function to play a sound when a person enters the trigger, I was faced with the question: what if a person constantly leaves and enters back into the trigger, continuously? Accordingly, the sound will also be produced anew each time and the result will be complete nonsense Question: how can I first check that the sound has played to the end, and then play the same sound again? Share this post Link to post Share on other sites
Joe98 92 Posted February 3 When you create a trigger, you have the option: : the trigger is fired once only or : the trigger is fired every time the conditions are met . Share this post Link to post Share on other sites
Harzach 2517 Posted February 3 Create a boolean variable at mission start, for example: soundPlayable = true; In your trigger, add this variable as a condition: this && soundPlayable In the code where you play the sound, set the variable to false, and add a timer that waits for the the amount of time that it takes the sound to play. When the timer finishes, set the variable to true again. soundPlayable = false; <play sound> nul = [] spawn { sleep 10; // time in seconds to wait soundPlayable = true; }; If your mission is for multiplayer, there may be some locality issues to work out. 2 1 Share this post Link to post Share on other sites
pierremgi 4890 Posted February 3 5 hours ago, PrizraK11 said: When creating a function to play a sound when a person enters the trigger, I was faced with the question: what if a person constantly leaves and enters back into the trigger, continuously? Accordingly, the sound will also be produced anew each time and the result will be complete nonsense Question: how can I first check that the sound has played to the end, and then play the same sound again? Welcome to forum. Which sound? How do you run it (playSound or else)? Share this post Link to post Share on other sites
PrizraK11 0 Posted February 3 9 hours ago, pierremgi said: Welcome to forum. Which sound? How do you run it (playSound or else)? Yea, playSound3d My code: // init.sqf execVM "bluforBase.sqf"; // bluforBase.sqf Sirens = [a1,a2,a3,a4,a5]; areaBaseBLUFOR setTriggerActivation ["EAST", "PRESENT", true]; areaBaseBLUFOR setTriggerStatements ["this", "[Sirens] call KS_fnc_playSignal;", "hint 'hello!'"]; // fnc_playSignal params ["_signals"]; _soundPlayable = false; { private _sound = playSound3D [getMissionPath "\sounds\BaseSounds\onBluforBase.wav", _x, true, getPosASL _x, 3, 1, 450]; } forEach _signals; Share this post Link to post Share on other sites
PrizraK11 0 Posted February 3 Thank you so much! Very useful! Its work! Share this post Link to post Share on other sites