Jump to content
NemesisRE

[RELEASE] NRE Earplugs

Recommended Posts

Hi there,

I'm currently working on a mission template for my clan [qip] and wanted to include earplugs because everyone is complaining about the noise of the helicopters :P

I looked at several scripts, some of them didn't suit and some didn't work. Maybe it would have been easy to fix but as I wanted to learn sqf scripts anyway I

started to write my own script.

The earplugs work everywhere so they are not bound to a specific location, like inside a helicopter or so. Everything is translatable and currently in english and german.

Setup:

  1. Create a "scripts" folder in your mission and put the main script in there (or update init.sqf and NreEarplugsPath variable in the main script)
  2. Create stringtable.xml (or add to existing) the language strings
  3. Add "execVM "scripts\NRE_earplugs.sqf";" to your init.sqf
  4. Have fun with your earplugs :)

regards

NemesisRE

NRE_earplugs.sqf:

/*
Script name:	NRE_earplugs.sqf
Created on:		03.06.2015 (06/03/2015)
Author:			NemesisRE
Author website:	http://nrecom.net

Description:	Adds action to insert/remove Earplugs (toggles).
			Inspired by A3Wasteland132DSOv14.Altis kopfh script

License:		Copyright (C) 2015 Steven "NemesisRE" Köberich

			This program is free software: you can redistribute it and/or modify
			it under the terms of the GNU General Public License as published by
			the Free Software Foundation, either version 3 of the License, or
			(at your option) any later version.

			This program is distributed in the hope that it will be useful,
			but WITHOUT ANY WARRANTY; without even the implied warranty of
			MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
			GNU General Public License for more details.

			You should have received a copy of the GNU General Public License
			along with this program.  If not, see <http://www.gnu.org/licenses/>.


Manual:			Call from init.sqf via:
				execVM "scripts\NRE_earplugs.sqf";

			Add following to your stringtable.xml:
				<?xml version="1.0" encoding="UTF-8"?>
				<Project name="NRE Earplugs">
					<Package name="NREEarplugs">
						<Key ID="STR_NREEP_IN_HINT">
							<Original>You have insert the earplugs!</Original>
							<English>You have insert the earplugs!</English>
							<Russian>Беруши вÑтавлены!</Russian>
							<German>Du hast die Ohrstoepsel eingesteckt!</German>
							<Spanish>¡Te has puesto los tapones!</Spanish>
						</Key>
						<Key ID="STR_NREEP_OUT_HINT">
							<Original>You have removed the earplugs!</Original>
							<English>You have removed the earplugs!</English>
							<Russian>Беруши вытащены!</Russian>
							<German>Du hast die Ohrstoepsel rausgenommen!</German>
							<Spanish>¡Te has quitado los tapones!</Spanish>
						</Key>
						<Key ID="STR_NREEP_IN_ACTION">
							<Original>Insert earplugs</Original>
							<English>Insert earplugs</English>
							<Russian>Ð’Ñтавить беруши</Russian>
							<German>Ohrstoepsel einstecken</German>
							<Spanish>Ponerte los tapones</Spanish>
						</Key>
						<Key ID="STR_NREEP_OUT_ACTION">
							<Original>Remove earplugs</Original>
							<English>Remove earplugs</English>
							<Russian>Вытащить беруши!</Russian>
							<German>Ohrstoepsel rausnehmen</German>
							<Spanish>Quitarte los tapones</Spanish>
						</Key>
					</Package>
				</Project>
*/

waitUntil {!isNull player}; //to prevent MP / JIP issues

NreEarplugsPath = "scripts\";

if (isNil "NreEarplugsActive") then {
NreEarplugsActive = 0;
1 fadeSound 1;
_id = player addAction [("<t color=""#00FF00"">" + (localize "STR_NREEP_IN_ACTION") +"</t>"),NreEarplugsPath+"NRE_earplugs.sqf","",5,false,true,"",""];
player setVariable ["NreEarplugsAction", _id];
// Handle respawn
player addEventHandler ["Respawn", {
	NreEarplugsActive = 0;
	1 fadeSound 1;
	_id = (_this select 1) getVariable "NreEarplugsAction";
	(_this select 1) removeAction _id;
	_id = (_this select 0) addAction [("<t color=""#00FF00"">" + (localize "STR_NREEP_IN_ACTION") +"</t>"),NreEarplugsPath+"NRE_earplugs.sqf","",5,false,true,"",""];
	(_this select 0) setVariable ["NreEarplugsAction", _id];
}];
breakto "firstInitFinished";
};

if ( NreEarplugsActive == 1 ) then {
NreEarplugsActive = 0;
1 fadeSound 1;
hint format	[ localize "STR_NREEP_OUT_HINT" ];
_id = player getVariable "NreEarplugsAction";
player removeAction _id;
_id = player addAction [("<t color=""#00FF00"">" + (localize "STR_NREEP_IN_ACTION") +"</t>"),NreEarplugsPath+"NRE_earplugs.sqf","",5,false,true,"",""];
player setVariable ["NreEarplugsAction", _id];
} else {
NreEarplugsActive = 1;
1 fadeSound 0.4;
hint format	[ localize "STR_NREEP_IN_HINT" ];
_id = player getVariable "NreEarplugsAction";
player removeAction _id;
_id = player addAction [("<t color=""#FF0000"">" + (localize "STR_NREEP_OUT_ACTION") +"</t>"),NreEarplugsPath+"NRE_earplugs.sqf","",5,false,true,"",""];
player setVariable ["NreEarplugsAction", _id];
};

scopename "firstInitFinished";

stringtable.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Project name="NRE Earplugs">
<Package name="NREEarplugs">
	<Key ID="STR_NREEP_IN_HINT">
		<Original>You have insert the earplugs!</Original>
		<English>You have insert the earplugs!</English>
		<Russian>Беруши вÑтавлены!</Russian>
		<German>Du hast die Ohrstoepsel eingesteckt!</German>
		<Spanish>¡Te has puesto los tapones!</Spanish>
	</Key>
	<Key ID="STR_NREEP_OUT_HINT">
		<Original>You have removed the earplugs!</Original>
		<English>You have removed the earplugs!</English>
		<Russian>Беруши вытащены!</Russian>
		<German>Du hast die Ohrstoepsel rausgenommen!</German>
		<Spanish>¡Te has quitado los tapones!</Spanish>
	</Key>
	<Key ID="STR_NREEP_IN_ACTION">
		<Original>Insert earplugs</Original>
		<English>Insert earplugs</English>
		<Russian>Ð’Ñтавить беруши</Russian>
		<German>Ohrstoepsel einstecken</German>
		<Spanish>Ponerte los tapones</Spanish>
	</Key>
	<Key ID="STR_NREEP_OUT_ACTION">
		<Original>Remove earplugs</Original>
		<English>Remove earplugs</English>
		<Russian>Вытащить беруши!</Russian>
		<German>Ohrstoepsel rausnehmen</German>
		<Spanish>Quitarte los tapones</Spanish>
	</Key>
</Package>
</Project>

GITHUB: https://github.com/NemesisRE/NRE_earplugs

Download: https://github.com/NemesisRE/NRE_earplugs/archive/master.zip

Edited by NemesisRE
respawn event only triggerd on init
  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks for work!

Add russian localize!


	<Key ID="STR_NREEP_IN_HINT">
		<Original>You have insert the earplugs!</Original>
		<English>You have insert the earplugs!</English>
		<Russian>Беруши вÑтавлены!</Russian>
		<German>Du hast die Ohrstoepsel eingesteckt!</German>
	</Key>
	<Key ID="STR_NREEP_OUT_HINT">
		<Original>You have removed the earplugs!</Original>
		<English>You have removed the earplugs!</English>
		<Russian>Беруши вытащены!</Russian>
		<German>Du hast die Ohrstoepsel rausgenommen!</German>
	</Key>
	<Key ID="STR_NREEP_IN_ACTION">
		<Original>Insert earplugs</Original>
		<English>Insert earplugs</English>
		<Russian>Ð’Ñтавить беруши</Russian>
		<German>Ohrstoepsel einstecken</German>
	</Key>
	<Key ID="STR_NREEP_OUT_ACTION">
		<Original>Remove earplugs</Original>
		<English>Remove earplugs</English>
		<Russian>Вытащить беруши!</Russian>
		<German>Ohrstoepsel rausnehmen</German>
	</Key>

Share this post


Link to post
Share on other sites

Spanish localize:

	<Key ID="STR_NREEP_IN_HINT">
		<Original>You have insert the earplugs!</Original>
		<English>You have insert the earplugs!</English>
		<Russian>Беруши вÑтавлены!</Russian>
		<German>Du hast die Ohrstoepsel eingesteckt!</German>
		<Spanish>¡Te has puesto los tapones!</German>
	</Key>
	<Key ID="STR_NREEP_OUT_HINT">
		<Original>You have removed the earplugs!</Original>
		<English>You have removed the earplugs!</English>
		<Russian>Беруши вытащены!</Russian>
		<German>Du hast die Ohrstoepsel rausgenommen!</German>
		<Spanish>¡Te has quitado los tapones!</Spanish>
	</Key>
	<Key ID="STR_NREEP_IN_ACTION">
		<Original>Insert earplugs</Original>
		<English>Insert earplugs</English>
		<Russian>Ð’Ñтавить беруши</Russian>
		<German>Ohrstoepsel einstecken</German>
		<Spanish>Ponerte los tapones</Spanish>
	</Key>
	<Key ID="STR_NREEP_OUT_ACTION">
		<Original>Remove earplugs</Original>
		<English>Remove earplugs</English>
		<Russian>Вытащить беруши!</Russian>
		<German>Ohrstoepsel rausnehmen</German>
		<Spanish>Quitarte los tapones</Spanish>
	</Key>

Share this post


Link to post
Share on other sites

Updated translation and fix to prevent MP / JIP issues :)

Thank you :)

Share this post


Link to post
Share on other sites

From looks of it, actions will not reappear when player will respawn and will remain on dead body.

Share this post


Link to post
Share on other sites

@SaMatra

I add the action to the player not the body so it shouldn't appear on dead bodys and I have a event handler for respawn so it must be readded on respawn.

Do you have any revive scripts/mods running? Maybe something is messing with the respawn event?

Edit: I have branched a possible fix for that I need to test it in the evening, if it works I will merge it.

Edited by NemesisRE

Share this post


Link to post
Share on other sites
@SaMatra

I add the action to the player not the body so it shouldn't appear on dead bodys and I have a event handler for respawn so it must be readded on respawn.

Do you have any revive scripts/mods running? Maybe something is messing with the respawn event?

Edit: I have branched a possible fix for that I need to test it in the evening, if it works I will merge it.

You're right, on a second look it should be fine. I didn't test or use it, I went through script and missed how you handled Respawn events.

Share this post


Link to post
Share on other sites

New version which adds eventhandler only once on init.

Share this post


Link to post
Share on other sites
Guest
stringtable.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Project name="NRE Earplugs">
	<Package name="NREEarplugs">
		<Key ID="STR_NREEP_IN_HINT">
			<Original>You have inserted the earplugs!</Original>
			<English>You have inserted the earplugs!</English>
			<Russian>Беруши вÑтавлены!</Russian>
			<German>Du hast die Ohrstoepsel eingesteckt!</German>
			<Spanish>¡Te has puesto los tapones!</Spanish>
                        <French>Vous avez mis les bouchons d'oreille</French>
		</Key>
		<Key ID="STR_NREEP_OUT_HINT">
			<Original>You have removed the earplugs!</Original>
			<English>You have removed the earplugs!</English>
			<Russian>Беруши вытащены!</Russian>
			<German>Du hast die Ohrstoepsel rausgenommen!</German>
			<Spanish>¡Te has quitado los tapones!</Spanish>
                        <French>Vous avez enlevé les bouchons d'oreille!</French>
		</Key>
		<Key ID="STR_NREEP_IN_ACTION">
			<Original>Insert earplugs</Original>
			<English>Insert earplugs</English>
			<Russian>Ð’Ñтавить беруши</Russian>
			<German>Ohrstoepsel einstecken</German>
			<Spanish>Ponerte los tapones</Spanish>
                        <French>Mettre les bouchons d'oreille</French>
		</Key>
		<Key ID="STR_NREEP_OUT_ACTION">
			<Original>Remove earplugs</Original>
			<English>Remove earplugs</English>
			<Russian>Вытащить беруши!</Russian>
			<German>Ohrstoepsel rausnehmen</German>
			<Spanish>Quitarte los tapones</Spanish>
                        <French>Retirer les bouchons d'oreille!</French>
		</Key>
	</Package>
</Project>

Fixed english localization + Added French localization

Share this post


Link to post
Share on other sites

Uuhm, how does it work? How do i enable this ?

 

Welcome to the forums Dalle!  The three steps to getting this working as listed under Setup in the first post.  What sorts of trouble or errors were you getting when you tried those in your mission?

Share this post


Link to post
Share on other sites

Welcome to the forums Dalle!  The three steps to getting this working as listed under Setup in the first post.  What sorts of trouble or errors were you getting when you tried those in your mission?

Thankyou!. I have only putted the code into the files as i should, but when i enter my server it dosen't lower the sound. Is there a button who needs to be pressed before this script works?

Share this post


Link to post
Share on other sites

When you look at your script files, especially the init.sqf one, what type of file does Windows say it is?  Is it an "SQF File" or a "Text Document"?  If it says Text Document that would explain why it's not running.  Windows by default hides actual extensions for files.  Here's how to fix that on Win 7.

Share this post


Link to post
Share on other sites

When you look at your script files, especially the init.sqf one, what type of file does Windows say it is?  Is it an "SQF File" or a "Text Document"?  If it says Text Document that would explain why it's not running.  Windows by default hides actual extensions for files.  Here's how to fix that on Win 7.

It does say SQF but the question is. Does this automatically activates by itself when entering a vehicle or do i have to press something to activate earplugs?

Share this post


Link to post
Share on other sites

A really useful script.

Any plans to make it a pbo'd mod? It would help a lot with missions that run with lots of scripts or frameworks.

  • Like 1

Share this post


Link to post
Share on other sites

Gents,

 

Great script and it works extremely well when i use the editor - as soon as i export the mission to MP and then run on my dedicated server (hosted by gtxgaming,com) the action to insert/remove does not appear in game?  Can anyone help me out with this?

 

Many thanks in advance 

Share this post


Link to post
Share on other sites
6 minutes ago, Hydrol said:

Gents,

 

Great script and it works extremely well when i use the editor - as soon as i export the mission to MP and then run on my dedicated server (hosted by gtxgaming,com) the action to insert/remove does not appear in game?  Can anyone help me out with this?

 

Many thanks in advance 

 

Nevermind - i placed the init line in the initPlayerLocal.sqf file and its working now - not sure if that is meant to happen or not?

Share this post


Link to post
Share on other sites

Hey :D,

 

I'm very new to all this scripting & mission making stuff. I have run into a brick wall now because I have added this script to one of my multiplayer mission files and followed all the instructions that were given on the Armaholic page, but the sound isn't lowering. I can see the add actions, but when I select them, in-game, nothing happens? Would anyone have an answer/solution for me?

 

Thanks :D

Share this post


Link to post
Share on other sites

This deactivates the action menu and interaction icons for group (and likely also for side) respawn in a mission a friend made (which also includes AIS wounds, CRS, and Outlaw mag repack). The player can't insert or remove plugs, open doors, pick up items (without using inventory keybind) etc. after they have respawned into an ai entity.

Share this post


Link to post
Share on other sites
On 2/10/2023 at 10:44 PM, Lucas Andre (Lunga Gamer) said:

What is the key to make it work? Or is it on the mouse scroll.

NRE uses mouse wheel / action menu. George Floros has one that uses a key (and which works with group and side respawn).

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

×