Jump to content

[Solved] Adding Icons to Simple Earplugs script


Jyggs

Recommended Posts

I am trying to add an icon indicator to js2k6 Very Simple Earplugs Script to replace the normal silent hint box that appears every time you insert or remove earplugs. The problem is that the icon will always be shown when a player starts the game and I have no way of shutting it off by default. Here is what I've done so far....

 Right now I'm using "Cen's HUD Indicators" on my HUD screen, so I modified it's ATD_hud.h file to have an earplugs icon display on my HUD like so....

//EARPLUGS ICON
            class RscPicture_1434: RscPictureGUI
            {
                idc = 1434;
                text = "mods\hud\gui\status\earplugs.paa";
                x = 0.950 * safezoneW + safezoneX;
                y = 0.345 * safezoneH + safezoneY;
                w = 0.075;
                h = 0.10;
				colorText[] = {1,1,1,1.0};
            };

On my custom dayz_spaceInterrupt.sqf I added js2k6 earplugs script and added a couple of variables to be able to call my earplugs icon from there. So I added the following variables to my private scope at top and these lines on my sqf file.....

Private ["_display","_earplugs",....... etc etc ect]

//Added these to the top of the SQF to call my earplug icon.
_display = uiNamespace getVariable 'DAYZ_GUI_display';
_earplugs = _display displayCtrl 1434;

This is the modified earplugs script part.....

// Earplugs
if (_dikCode == 0x16) then		// U key to trigger earplugs
    {
        if (soundVolume == 1) then {
            1 fadeSound 0.25;
			_earplugs ctrlShow true;		// Inserted Earplugs - Icon On
        }
            else
        {
            1 fadeSound 1;
			_earplugs ctrlShow false;	//Removed Earplugs - Icon Off
        };
    };

 

With this, everything works as intended except one thing. The earplugs icon will always be ON by default when a player joins the game. However, if he presses U to activate and then deactivate the earplugs, the icon will disappear and will show up properly when adding or removing the earplugs. I've tried different stuff like  adding a "_earplugs ctrlShow false;" line before the script itself, but it will turn the icon off even when using the earplugs after like 5 seconds. Also tried adding an " if (soundVolume ==1)" line before the script to force the icon to be off by sensing that the volume is "normal", but that doesn't work either. For some reason it can't sense the volume level when the game loads so it doesn't respond.

I am not sure how to work around this, any help will be greatly appreciated. Thanks

Link to comment
Share on other sites

Finally... after a while trying to figure it out I got it working. Going to make a step by step just in case anyone wants to do it.

1) Add an entry on your ATD_hud.h file for your custom icon. Must be under RSCPicture.... (or the same class as the Hud icons on screen)  <-- I'm using Cen's Hud so yours may vary.

//EARPLUGS ICON
            class RscPicture_1434: RscPictureGUI
            {
                idc = 1434;
                text = "mods\hud\gui\status\earplugs.paa";	//Change to your custom icon path and name
                x = 0.950 * safezoneW + safezoneX;		//Change position on screen Left/Right
                y = 0.345 * safezoneH + safezoneY;		//Change position on screen Up/Down
                w = 0.075;
                h = 0.10;
				colorText[] = {1,1,1,1.0};	//Change color - Current color WHITE
            };

 

2) Open up your dayz_spaceInterrupt.sqf file and add this code (or replace if you already have it) before the line commented as " // Disable ESC after death ". Note: All the credit for this code goes to JS2k6. I do NOT take any credit for it.... I just modified it to add a toggable icon instead of the hint text box.

// JS2k6 Very Simple Earplugs Script (modified for toggable icon)
if (_dikCode == 0x16) then 		//Press U key to trigger. Change dikCode 0x16 to edit which key to press.
    {
        if (soundVolume == 1) then {
            1 fadeSound 0.25;
			player setVariable["plugstate",true];		//Sets Earplug state to True - Earplugs On

        }
            else
        {
            1 fadeSound 1;
			player setVariable["plugstate",false];		//Sets Earplug state to False - Earplugs Off

    };
};

 

3) Open up player_updateGUI.sqf and add "_state" to the Private scope at the top. Then add this after the _display = uiNamespace getVariable 'DAYZ_GUI_display';  line.

_state = player getVariable["plugstate",false];		// Sets Earplugs icon OFF by default when loading into the game.
_ctrlEarPlugs = _display displayCtrl 1434;

if(_state) then {
	_ctrlEarPlugs ctrlShow true;
	player setvariable["plugstate",true];			// If value = true, then show icon on screen. Earplugs On
} else {
	_ctrlEarPlugs ctrlShow false;
	player setvariable["plugstate",false];			// If value = false, then show no icon. Earplugs Off
};

 

4) Make your own custom icon and place it inside your Mission.PBO. Remember to add the correct directory path and name for the icon back in step 1. ( I labeled it with a comment)

 

Results:

http://i.imgur.com/RxnQUaO.jpg

 

Link to comment
Share on other sites

On 3/4/2016 at 9:46 PM, Tweety060286 said:

Hello mate!
I have to add your ear-plug icon and it worked, but it was a problem.
If I install your icon step by step then attack the zombies to no player.
Have been looking for the error until I came to your ear plug icon.
Sorry for my bad English

I'm sorry, I don't understand very well what you just wrote. However, I think what you are trying to say is that "After adding the earplug script, your zombies stopped working properly".... is that it?

If so, I have no idea what you did wrong. To be honest, even if you screwed up any of the files I described above, your zombies should still be working. All of those file are related only to button inputs or HUD elements on screen. Also I do believe if you screw up the syntax on ATD_hud.h or Player_UpdateGUI.sqf , your server won't even start properly and give you an error message when trying to join.

To me, it sounds more like a problem with the fn_damagehandler.sqf file. Have you modded this file recently? Also as a side note, I had this same problem you are describing when I tried the "No Lobby after Death" mod by Donnovan. When I tested it and died, everytime I respawned the zombies would not attack me.

Link to comment
Share on other sites

I am using the standard gui on my server. Would I add the first part below to my description.ext?

//EARPLUGS ICON
            class RscPicture_1434: RscPictureGUI
            {
                idc = 1434;
                text = "mods\hud\gui\status\earplugs.paa";
                x = 0.950 * safezoneW + safezoneX;
                y = 0.345 * safezoneH + safezoneY;
                w = 0.075;
                h = 0.10;
				colorText[] = {1,1,1,1.0};
            };
Link to comment
Share on other sites

Nope. To be honest I don't know how to add it properly inside the "vanilla" description.ext.  On my setup it goes on a different file which is then included using  #include inside Description.ext... like this.

class RscTitles
{
#include "mods\hud\gui\ATD_Hud.h"
};

Then that line that you are referring to goes inside ATD_Hud.h.  I'm sure there is a proper way to add it inside Description.ext, but I don't know the correct Syntax to do it. If you want, here is the link for Cen's Custom GUI and check it out, you could probably modify his files to only add the earplugs icon via an external file and not his HUD icons..... not sure. Sorry I'm not much help  :sad:

 

Link to comment
Share on other sites

16 hours ago, lonewolfgaming said:

ok, thanks for the info. I have tried to install that GUI, but could never get it to work correct

 

Yeah I had to do some finagling with that script in order to get it to work. Another guy on that thread (don't remember his name) suggested adding a defines.hpp or guidefines.hpp file with some extra corrections and using that worked for me. It's all jumbled in between all the comments though, so I had to read all the thread to get it fully working. I'm pretty sure you don't have to use IT in order to add the earplugs icon, you just need to call it from an external file in the description.ext. At least that how the custom hud works.

Link to comment
Share on other sites

15 hours ago, ElDubya said:

I use this and Jyggs' icon fix thingy works perfectly with it.

 

Ahhh there we go! Yeah that is way much easier than Cen's Hud and you can add the icon using that one instead. Thank you for the suggestion.  :biggrin:

Link to comment
Share on other sites

  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...