← Go back

Arma 3: Not another ear plugs script!


Posted on October 16, 2017 at 00:15 (GMT +00:00) by Colin



An SQF script for inserting and removing virtual earplugs!

So probably just about everyone has meddled with an ear plugs script for Arma. When I first messed around with SQF a couple of weeks ago I decided I would first make this legendary *smirk* script to hone my SQF skillz. I originally have written it to be a part of my upcoming game mode "Decay", but I decided to try make most of the functionality modular, this means it was simple enough to make it stand-alone.

/////////////////////////////////////////////////////////////////////////////////
//
// EarPlugs - part of PixeL_GaMMa library.
// Simulate having earplugs in, allowing you to hear radio over other noises
// Copyright (c) Colin J.D. Stewart. All rights reserved
// APL-ND License - https://www.bistudio.com/community/licenses/arma-public-license-nd
//
/////////////////////////////////////////////////////////////////////////////////

if (hasInterface) then {
	PX_fnc_earPlugsInsert = {
		PX_earPlugActive = true;
		1 fadeSound 0.2;	
		player removeAction PX_earPlugAction;
		hint "Ear plugs have been inserted!";
		PX_earPlugAction = player addAction [("<t color='#FF0000'>Remove Ear Plugs</t>"), {call PX_fnc_earPlugsRemove}, [], 1, false, true];
	};

	PX_fnc_earPlugsRemove = {
		PX_earPlugActive = false;
		1 fadeSound 1;
		player removeAction PX_earPlugAction;
		hint "Ear plugs have been removed!";
		PX_earPlugAction = player addAction [("<t color='#00FF00'>Insert Ear Plugs</t>"), {call PX_fnc_earPlugsInsert}, [], 1, false, true];	
	};

	PX_earPlugActive = false;
	player addEventHandler ["Respawn", {
		if (PX_earPlugActive) then {
			PX_earPlugAction = player addAction [("<t color='#FF0000'>Remove Ear Plugs</t>"), {call PX_fnc_earPlugsRemove}, [], 1, false, true];
		} else {
			PX_earPlugAction = player addAction [("<t color='#00FF00'>Insert Ear Plugs</t>"), {call PX_fnc_earPlugsInsert}, [], 1, false, true];
		};	
	}];
	player addEventHandler ["Killed", { player removeAction PX_earPlugAction; }];
};

This script is ran client-side, and is simple to add to any of your missions. Create a sub-folder "PX" and a file inside "px_earplugs.sqf" inside your mission folder, paste the code into the file and save. Now simply execute it from your init.sqf in your mission. (note to self: Write some Arma 3 mission creation tutorials).

Your init.sqf file should contain something like this:
// execute ear plugs script
[] execVM "PX\px_earplugs.sqf";


If you find this useful or you have any issues, please drop me a comment below, now play your mission and use your player context menu for inserting and removing your ear-plugs!
/Scripting/Programming/Game Modding

Search
Tags
Accident Adoption Albums Algorithms Altcoins Animal Rescue AnL Aquarium Arma ArmA nd Leg Array Partitioning Arrays Assembler Assembly Atanasovsko Award Bazaar Binary Search Bitcoin Bohemia Bootstrap Bulgaria Bulgaria Za Mladite Burgas C C++ Celerity Charity Chemical Records Chemical Shock Chemlight Code Competition Compiler Contest Converter Covid-19 CPP Crypto Cryptocurrency css Data Recovery Database DataTables Decode Dedicated Dedicated Server Delphi Development Dialogs Divide & Conquer DIY DnB Drum & Bass Earplugs Event Exchange Eyes Fish Floating-point Flood Fog Freeware Function Funny Gallery Game Game Development Game Modding Gaming Garden Gardening Gazebo GERB GitHub Glitch Hamish Harding Happy New Year Heapify HeapSort Helga HTML HTML entities Introduction Jackie JavaScript JQuery Jungle Lake Language Linker Listbox ListNBox lnbSetTooltip MariaDB Maths Merry Christmas Mini Mining Miningpoolhub Mist Modding MPH Multiplayer Music MySql NGO OceanGate One Nature ORCA organisation OverHertz Paludarium Pandemic Pascal Paul-Henri Nargeolet Paws Furever Pergola Persistence Pets Photography Pier Plugin Programming progress bar Project PX Library Quicksort r53 Racing Replace Scripting Searching Server Shahzada Dawood Simulation Simulator Smoke Snippet Social media Software Sorting Source Sourcecode SQF Statistics Stockton Rush String Strings Submarine Suleman Dawood Terrain Detail Text Titan Tool Tragedy tutorial UCS4Char UE4 Unreal Engine Victims View Distance ViewBug web Web Development Website Welcome Woodworking Ziron Zynk