Announcement

Collapse
No announcement yet.

Arma 3 - Earplugs Script - Class Based

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Arma 3 - Earplugs Script - Class Based

    Here is an earplug script that will automatically reduce the volume of vehicles so you can communicate via voice/radio again!

    put in your init.sqf...
    Code:
    _handle = []execVM "earplugs.sqf"
    Copy the following code into a text file and name it "earplugs.sqf"...
    Code:
    // put earplugs on all players in applicable vehicles
    // by |TG189| Unkl for TacticalGamer.com
    _run = true;
    _listOfVehicleTypes = ["air","support","armoured","ship","submarine","car","autonomous"];
    _earplugs = false;
    _playerInVehicle = false;
    
    while {_run} do
    {
    	if !(_earplugs) then
    	{
    		{
    			if ((typeOf (vehicle player)) isKindOf _x) then
    			{
    				_playerInVehicle = true;
    			};
    		} forEach _listOfVehicleTypes;
    		if (_playerInVehicle) then
    		{
    			1 fadeSound .35;
    			hintSilent "Putting earplugs in...";
    			_earplugs = true;
    		};
    	} else {
    		_playerInVehicle = false;
    		{
    			if ((typeOf (vehicle player)) isKindOf _x) then
    			{
    				_playerInVehicle = true;
    			}
    		} forEach _listOfVehicleTypes;
    		if !(_playerInVehicle) then
    		{
    			1 fadeSound 1;
    			hintSilent "Taking earplugs out...";
    			_earplugs = false;
    		};
    	};
    	
    	
    	sleep 2;
    	if (stopEarplugs != "false") then {_run = false;};
    };
    |TG-189th| Unkl
    ArmA 3 Game Officer
    Dean of Tactical Gamer University
    189th Infantry Brigade Member
    SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
    "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

  • #2
    Re: Arma 3 - Earplugs Script - Class Based

    Is this an automatic process? As in it happens to players whether they want it or not?

    Comment


    • #3
      Re: Arma 3 - Earplugs Script - Class Based

      It is automatic atm.
      |TG-189th| Unkl
      ArmA 3 Game Officer
      Dean of Tactical Gamer University
      189th Infantry Brigade Member
      SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
      "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

      Comment


      • #4
        Re: Arma 3 - Earplugs Script - Class Based

        I'll make a version that the player controls the use very very soon.
        |TG-189th| Unkl
        ArmA 3 Game Officer
        Dean of Tactical Gamer University
        189th Infantry Brigade Member
        SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
        "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

        Comment


        • #5
          Re: Arma 3 - Earplugs Script - Class Based

          THIS ONE IS ALL DONE BY PLAYER ACTIONS

          The path is assumed you are putting these 3 files in a folder "earplugs".

          playerEarplugs.sqf
          Code:
          // wearable earplugs
          // init.sqf -- _handle = []execVM "...\earplugs\playerEarplugs.sqf";
          // by |TG189| Unkl for TacticalGamer.com
          _inID = 78;
          _outID = 79;
          
          _inID = player addAction [
          "<t color='$FF0000'>Put In Earplugs</t>",
          "package\earplugs\earplugsPutIn.sqf",
          "",
          1,
          false,
          true,
          "",
          "player == player"];
          
          _outID = player addAction ["<t color='$FF0000'>Take Out Earplugs</t>","package\earplugs\earplugsTakeOut.sqf","",1,false,true,"","player == player"];
          earplugsPutIn.sqf
          Code:
          hintSilent "Putting earplugs in....";
          2 fadeSound .35;
          earplugsTakeOut.sqf
          Code:
          hintSilent "Taking earplugs out...";
          2 fadeSound 1;
          Depending on your mission you may need to make your event handler for respawn point to the first script again...(have not tested this with the TG revive yet).

          onPlayerRespawn.sqf
          Code:
          _handle = "earplugs\playerEarplugs.sqf"
          |TG-189th| Unkl
          ArmA 3 Game Officer
          Dean of Tactical Gamer University
          189th Infantry Brigade Member
          SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
          "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

          Comment


          • #6
            Re: Arma 3 - Earplugs Script - Class Based

            Looks awesome! Thanks!

            Always annoyed me that I had to turn down the audio to hear comms in a vehicle.
            "Nearly all men can stand adversity, but if you want to test a man's character, give him power." -Abraham Lincoln
            ΜΟΛΩΝ ΛΑΒΕ

            Comment


            • #7
              Re: Arma 3 - Earplugs Script - Class Based

              Adding onto this:

              Code:
              //initPlayerLocal.sqf
              call TG_fnc_earplugs;
              Code:
              //cfgfunctions.hpp
              class TG
              {
              	tag = "TG"; //tag of functions. TG_fnc_...
              	class TG
              	{
              		file = "TG";		//folder name inside the mission folder.
              		class earplugs {};
              
              	};
              };
              Code:
              //fn_earplugs.sqf
              sepa = 
              ["<t color='#ffff33'>Put on ear plugs</t>",
              		{	
              			_i = _this select 2;
              			if (soundVolume == 1) then 
              			{
              				hintSilent "Putting earplugs in....";
              				2 fadeSound 0.35;
              				player setUserActionText [_i,"<t color='#ffff33'>Take off ear plugs</t>"];
              			} 
              			else 
              			{
              				hintSilent "Taking earplugs out...";
              				2 fadeSound 1;
              				player setUserActionText [_i,"<t color='#ffff33'>Put on ear plugs</t>"];
              			}
              		},
              		[],
              		-90,
              		false,
              		true,
              		"",
              		"_target == vehicle player"
              ];
              
              player addAction sepa;
              player addEventHandler 
              [
              	"Respawn",
              	{
              		2 fadeSound 1;
              		player addAction sepa;
              	}
              ];

              Comment


              • #8
                Re: Arma 3 - Earplugs Script - Class Based

                Thanks B! I was hoping you'd take an interest in doing that.
                |TG-189th| Unkl
                ArmA 3 Game Officer
                Dean of Tactical Gamer University
                189th Infantry Brigade Member
                SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
                "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

                Comment


                • #9
                  Re: Arma 3 - Earplugs Script - Class Based

                  Originally posted by Unkl View Post
                  Thanks B! I was hoping you'd take an interest in doing that.
                  Is there something you need to add to the unit's init field? Im using the player controlled earplugs. Not the automatic one. Im still having a hard time getting these to work? Any suggestions? Thanks!

                  Comment


                  • #10
                    Re: Arma 3 - Earplugs Script - Class Based

                    Last time I used this I just copied B's text from above into the files as he indicates. However, what you're probably missing is we have a custom set of scripts we use in almost all TG missions that B has been adding to.

                    I think we have been adding to them and custom configuring for each of our missions for a while so there is quite a template there.
                    |TG-189th| Unkl
                    ArmA 3 Game Officer
                    Dean of Tactical Gamer University
                    189th Infantry Brigade Member
                    SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
                    "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

                    Comment


                    • #11
                      Re: Arma 3 - Earplugs Script - Class Based

                      Originally posted by Unkl View Post
                      Last time I used this I just copied B's text from above into the files as he indicates. However, what you're probably missing is we have a custom set of scripts we use in almost all TG missions that B has been adding to.

                      I think we have been adding to them and custom configuring for each of our missions for a while so there is quite a template there.
                      Well, im basically looking for that KOTH earplug script which used ctrl-F1 to lower the effects volume. But i cant seem to find it anywhere :(. I have been relentlessly trying to find any working, user activated earplugs script since last friday. I cant find it :(

                      Comment


                      • #12
                        Re: Arma 3 - Earplugs Script - Class Based

                        From the third code window in B's post HERE

                        You would copy that text into a file named:
                        cfgfunctions.hpp

                        So you would also need a line in your description.ext file that says
                        Code:
                        #include cfgfunctions.hpp
                        If your having problems then join our Custom Coop server and run say "Enemy Assault" and you could get the structure from there. It works well. You'd find the file in your %appdata% folder under "Local\Arma 3" i think.
                        |TG-189th| Unkl
                        ArmA 3 Game Officer
                        Dean of Tactical Gamer University
                        189th Infantry Brigade Member
                        SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
                        "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

                        Comment


                        • #13
                          Re: Arma 3 - Earplugs Script - Class Based

                          Originally posted by Unkl View Post

                          You would copy that text into a file named:
                          cfgfunctions.hpp

                          So you would also need a line in your description.ext file that says
                          Code:
                          #include cfgfunctions.hpp
                          If your having problems then join our Custom Coop server and run say "Enemy Assault" and you could get the structure from there. It works well. You'd find the file in your %appdata% folder under "Local\Arma 3" i think.
                          Thanks brother, ill let you know if it works for me.

                          Comment


                          • #14
                            Re: Arma 3 - Earplugs Script - Class Based

                            Hi Mikey,

                            Join us for a Tac Tuesday session sometime and test it out. We usually run missions on Tuesday evenings. Sometimes it doesn't pan out but many Tuesdays we have a full server and full fun.

                            Hope to see you on and welcome to TG.
                            sigpic
                            |TG-1st|Grunt
                            ARMA Admin (retired)
                            Pathfinder-Spartan 5

                            Comment

                            Connect

                            Collapse

                            TeamSpeak 3 Server

                            Collapse

                            Advertisement

                            Collapse

                            Twitter Feed

                            Collapse

                            Working...
                            X