The deleteVehicle doesn't work with dynamic sounds created with createSoundSource[]. It is therefore impossible to stop any sounds started with this function. See steps to reproduce.
Description
Details
- Legacy ID
- 590232496
- Severity
- None
- Resolution
- Fixed
- Reproducibility
- Always
- Category
- Scripting
testSound = createSoundSource ["Sound_Alarm", getPos player, [], 0];
// Won't stop the sound
deleteVehicle testSound;
Event Timeline
It's weird. I managed to store the createSoundSource[] result with the setVariable on an object (cfgVehicle) - and later was able to simply deleteVehicle this sound and it worked. But the test code with the alarm sound SFX given above still has this issue.
OK, after some more testing I think I know the issue: You cannot use deleteVehicle on sound sources when the game is paused (which is the case when running the above example from debug console).
This is correct
null = [] spawn {testSound = createSoundSource ["Sound_Alarm", getPos player, [], 0]; sleep 5; deletevehicle testSound;}
will stop the sound.
However there is still a problem. This
null = [] spawn {testSound = createSoundSource ["Sound_Alarm", getPos player, [], 0]; uiSleep 5; deletevehicle testSound;}
will not stop the sound if you execute it then press escape for 10 seconds then come back. uiSleep does not pause on pause and so it will try delete sound while ui is on pause and fail.
I think this could be relative
testSound = createSoundSource ["Sound_Alarm", getPos player, [], 0]; hint format ["%1", testSound];
shows "NOID <no shape>" for the sound object.
It works now thanks to Druid. This ticket can be marked fixed.
EDIT the issue is with using it with pause menu as stated above, in MP it works without a hitch.