ACE3/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf

44 lines
1.1 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2015-08-08 00:26:09 +00:00
/*
* Author: commy2
* Plays weapon firemode change sound.
2015-08-08 00:26:09 +00:00
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Weapon <STRING>
*
* Return Value:
* None
*
* Example:
* [ACE_player, currentWeapon ACE_player] call ace_safemode_fnc_playChangeFiremodeSound
*
* Public: No
*/
2015-08-08 00:26:09 +00:00
params ["_unit", "_weapon"];
private _sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "changeFiremodeSound");
2015-09-27 06:28:55 +00:00
if (_sound isEqualTo []) exitWith {
playSoundUI ["ACE_Sound_Click"];
};
_sound params [["_filename", ""], ["_volume", 1], ["_soundPitch", 1], ["_distance", 0]];
2015-09-27 06:28:55 +00:00
if (_filename == "") exitWith {
playSoundUI ["ACE_Sound_Click"];
};
// Add file extension .wss as default
if !(toLowerANSI (_filename select [count _filename - 4]) in [".wav", ".ogg", ".wss"]) then {
2015-09-27 06:28:55 +00:00
_filename = format ["%1.wss", _filename];
};
// Get position where to play the sound (position of the weapon)
private _position = _unit modelToWorldVisualWorld (_unit selectionPosition "RightHand");
playSound3D [_filename, objNull, insideBuilding _unit >= 0.5, _position, _volume, _soundPitch, _distance];
nil // return