Robustcolor 30 Posted September 19, 2020 Is it possible to add a ADS sound from initPlayerLocal? I've been trying to solve it with the code below but it wont play any sound. initPlayerLocal.sqf (findDisplay 46) displayAddEventHandler ["MouseButtonClick", { params ["_control", "_button"]; if (_button == 1) then { if (cameraView == "GUNNER") then { playSound [ironsightsout, true]; }else{ playSound [ironsightsin, true]; }; }; }]; Share this post Link to post Share on other sites
gc8 970 Posted September 19, 2020 are you passing string as the soundName to playSound? https://community.bistudio.com/wiki/playSound Share this post Link to post Share on other sites
Robustcolor 30 Posted September 19, 2020 9 minutes ago, gc8 said: are you passing string as the soundName to playSound? https://community.bistudio.com/wiki/playSound Description.EXT class CfgSounds { class ironsightsin { name = "ironsightsin"; sound[] = {"\ironsights_in.ogg", 1, 1}; titles[]={0,""}; }; class ironsightsout { name = "ironsightsout"; sound[] = {"\ironsights_out.ogg", 1, 1}; titles[]={0,""}; }; }; Share this post Link to post Share on other sites
gc8 970 Posted September 19, 2020 yeah you should definitely add quotation marks: playSound ["ironsightsout", true]; 1 Share this post Link to post Share on other sites
Robustcolor 30 Posted September 19, 2020 12 minutes ago, gc8 said: yeah you should definitely add quotation marks: playSound ["ironsightsout", true]; Thanks, yes i missed adding quotation marks. But my code still don't work. Share this post Link to post Share on other sites
Larrow 2800 Posted September 19, 2020 Make sure display 46 is available before adding the event. InitPlayerLocal.sqf runs before it is available. //initPlayerLocal.sqf h = [] spawn { disableSerialization; _display = findDisplay 46; //Immediately get display 46 waitUntil{ !isNull ( findDisplay 46 ) }; //Wait until display is available hint format[ "D: %1", _display ]; //Show initial = No Display _display = findDisplay 46; //Get display gain sleep 1; //Quick pause just to make sure we see systemchat systemChat format[ "D: %1", _display ]; //Show after = Display 46 }; 1 Share this post Link to post Share on other sites
Robustcolor 30 Posted September 20, 2020 Thanks @gc8 and @Larrow it works now. Needed this for it to work. waituntil {!isnull (finddisplay 46)}; Share this post Link to post Share on other sites
Robustcolor 30 Posted September 20, 2020 Any suggestion how i can disable the playSound if a player only zooms and not aiming down sights? I'm using !(weaponlowered) and !(Visiblemap) so it don't execute the code in those conditions. If a player has the weapon raised and zooms it executes the playSound, how can i prevent it from executing when doing this? If the weapon is lowered and the player zooms it don't execute as wanted. waituntil {!isnull (finddisplay 46)}; (findDisplay 46) displayAddEventHandler ["MouseButtonDown", { params ["_control", "_button"]; if ((_button == 1) && ((!(weaponLowered player) && !(visibleMap)) then { if (cameraView isEqualTo "GUNNER") then { playSound ["ironsightsout", true]; }; if (cameraView isEqualTo "INTERNAL" || {cameraView isEqualTo "EXTERNAL"}) then { playSound ["ironsightsin", true]; };}; }]; Share this post Link to post Share on other sites