Jump to content
Sign in to follow this  
MadM0nkey

Script: NVGoggles Activation On/Off = Sound

Recommended Posts

I have been meaning to add a sound effect that auto plays any time a player switches On/Off his nvgoogles similar to an old game I loved to play a long time ago, I'm just not sure how to do it automatically so that no one nearby hears tons of nvgoogles switching on if say we all spawn in together at one time..

for now I am just using the basic easy method just by adding this to the leaders player Init field:

playername action ["NVGoggles", playername]; playername say "NVG_On";

Doing it this old boring way means it only happens once when the player spawns in,

I would much rather have an auto script that will always play if switched On/Off for a specific mission.

the problem:

for one is not identifying if the Action nvgoogles is taking place eg being turned on/off in the loop so that it's being checked to set the action of playing the sound as a Type of returned Boolean??

If Type weapon "nvgoogles" mode: String ??

I know this isn't correct or even close but something like this so you get my drift:

NVgooglesFX_Init.sqf


/*
Side is: "WEST", "EAST", etc. -with quotes
playername is: name of the player = the sound source
distance sound is carried from relation to the active sound =player,  eg 1km?
nul = ["WEST",playername, 1] execVM "NVgooglesFX_Init.sqf";
*/

if (!isServer) exitWith {};

private ["_obj","_sensor","_wait","_check","_SoundOn","_active","_nvgon"];

_side = _this select 0;
_obj  = _this select 1;
_dist = _this select 2;

_wait = false;
_active = false;

_sensor = createTrigger ["EmptyDetector", position _obj];
_sensor setTriggerActivation [_side, "present", true];
_sensor setTriggerArea [_dist, _dist, 0, true];
_sensor setTriggerStatements ["this", "", ""];
_sensor setTriggerText "nvgoogle sensor";
_sensor setTriggerTimeout [0, 0, 0, false];
_sensor setTriggerType "SWITCH";

   while {alive player and alive leader player} do
{
   _wait = true;
   while {_wait} do
   {
    _check = list _sensor;
       sleep 5.00;

       _nvgon = false;
    if (count _check > 0) then {_nvgon = true};

       if (_nvgon) then
       {
           if (not _active) then
           {
               _soundOn = createSoundSource ["NVG_On", getpos _obj, [], 0];
               _active = true;
               hint " Debug: NV turned on?";
           };
       }
       else
       if (_nvgon) then
       {
           if (not _active) then
           {
                _soundOn = createSoundSource ["NVG_Off", getpos _obj, [], 0];
                _active = false;
                hint " Debug: NV turned off?"; 
           };
       }
       else
       {
           if (_active) then
           {
               deletevehicle _soundOn;
               _active = false;
               _wait = false;
           };
       };
   };
};

description.ext for missions folder


//  sounds
class CfgSounds
{
   // List of sounds (.ogg files without the .ogg extension)
sounds[] = {NVG_On, NVG_Off};

   // Definition for each sound
   class NVG_On
   {
       name = "NVG_On"; // Name for mission editor
       sound[] = {\sounds\nvgon.ogg, db + 0, 1.0};
       titles[] = {0, ""};
   };
   class NVG_Off
   {
       name = "NVG_Off"; // Name for mission editor
       sound[] = {\sounds\nvgoff.ogg, db + 0, 1.0};
       titles[] = {0, ""};
   };
};

for anyone who would care to help with it I have uploaded to share my own created NVgoogles On/Off soundfx

for anyone who wishes to use them: yes you may but only under these agreed terms:

(1) they are only used for BI ArmA Series Games.

(2) they are Not Sold for Profit for any reason period.

(3) they do not require registration for any websites to download and use on any servers.

(4) if you can't understand the 4 listed terms do not download or use them.

Download:

NVGoogles On/Off sounds @ sendspace : http://www.sendspace.com/file/do3tsz

Edited by MadM0nkey
Example syntax! test at your own risk!

Share this post


Link to post
Share on other sites

41 views & no help?

I take it Splinter Cell sound fx editing falls under the category: not cool enough to help you *bumb*

Share this post


Link to post
Share on other sites

Into the init.sqf:

if (!isDedicated) then
{
nvGogglesActive = false;
nvGoggleKeys	= actionKeys "NightVision";

checkForNVGoggles = {
	_keyCode = _this;
	if (player hasWeapon "NVGoggles") then
	{
		if (_keyCode in nvGoggleKeys) then
		{
			_sound = if(nvGogglesActive) then {"NVG_Off"} else {"NVG_On"};

			player setVehicleInit format["this say3D '%1';", _sound];
			processInitCommands;
			clearVehicleInit player;

			nvGogglesActive = !nvGogglesActive;
		};
	}
	else
	{
		nvGogglesActive = false;
	};
};

waitUntil {!isNull (findDisplay 46)};
(findDisplay 46) displayAddEventHandler ["keyPress", "(_this select 1) call checkForNVGoggles;"];
};

Edited by XxAnimusxX

Share this post


Link to post
Share on other sites

thanks XxAnimusxX I really appreciate your help I will try this soon. =)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×