#include "..\script_component.hpp"

/*
 * Author: IDSolutions
 * Create a sound source and play an ambient sfx sound
 *
 * Arguments:
 * 0: The sound source <OBJECT>
 * 1: The name of the SFX sound <STRING>
 * 2: Number of seconds before SFX sound will be deleted <NUMBER>
 *
 * Return Value:
 * N/A
 *
 * Examples:
 * [this, "sfx_sound_name"] spawn forge_client_ambient_fnc_ambientSound
 *
 * Public: Yes
 */

params [["_source", nil, [objNull, 0, [], sideUnknown, grpNull, ""]], ["_sfx", "", [""]], ["_time", nil, [0]]];

private _sound0 = createSoundSource [_sfx, position _source, [], 0];

while { alive _source } do {
	if (!isNil "_time") exitWith {
		uiSleep _time;
		deleteVehicle _sound0;
	};

	uiSleep 5;

	if (!alive _source) exitWith {
		deleteVehicle _sound0;
	};
};