[Release - 1.7.6.1] Gear Menu Slots Remaining

AlienX

Valued Member!
Hello all,
My first release for you guys to get your fingers on!
Okay, lets get to business:

Gear Menu Slots Remaining
v1.0

What it does:
This script is simple, and yet effective - It simply modifies the gear's title to display how much gear is inside the tent/vehicle/etc and how much it can take - no more will you lose a weapon or that tiny morphine injector when overfilling your tent!

Requirements
Difficulty: Easy <10 Minutes
Apps: Notepad ++, cpbo

Step One
Firstly, create a folder called axs_gearmanagement inside your mission folder (where init.sqf lives) and insert the following code into a file called doGear.sqf:
Code:
private [ "_lookingat", "_type", "_maxGuns", "_maxMags", "_maxBags", "_cntGuns", "_cntMags", "_cntBags", "_fndDisplay", "_fndDisplay_Visible", "_dispEnum", "_dispControl", "_dispControlInitText", "_distance", "_typeName" ];
 
waitUntil {!isNil ("dayzLoginRecord")};
 
disableSerialization;
 
_dispControlInitText = "";
_lookingat = objNull;
 
while {true} do
{
    sleep 0.5;
    _fndDisplay = findDisplay 106;
    _fndDisplay_Visible = ( (str _fndDisplay) != "No display");
 
    if ( _fndDisplay_Visible ) then {
        if ( !isNull cursorTarget ) then {
            if ( isNull _lookingat ) then {
                _lookingat = cursorTarget;
            };
            _type = typeOf _lookingat;
            _distance = ((getPos _lookingat) distance (getPos player));
 
            if ( _distance < 10.5 ) then {
                _maxGuns = getNumber(configFile >> "cfgVehicles" >> _type >> "transportMaxWeapons");
                _maxMags = getNumber(configFile >> "cfgVehicles" >> _type >> "transportMaxMagazines");
_maxBags = getNumber(configFile >> "cfgVehicles" >> _type >> "transportmaxbackpacks");
   
                if ( (_maxGuns + _maxMags + _maxBags) > 0 ) then {
                    _typeName = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
                    _cntGuns = 0;
                    _cntMags = 0;
_cntBags = 0;
       
                    {
                        _cntGuns = _cntGuns + _x;
                    } foreach ( (getWeaponCargo _lookingat) select 1 );
       
                    {
                        _cntMags = _cntMags + _x;
                    } foreach ( (getMagazineCargo _lookingat) select 1 );
 
                    {
                        _cntBags = _cntBags + _x;
                    } foreach ( (getBackpackCargo _lookingat) select 1 );
       
                    _dispControl = _fndDisplay displayCtrl 1001; //156 is the title of the object (eg "old camping tent"), however it flashes every half a second or so - makes it unusable... 1001 is the title of the dialog.
       
                    if ( _dispControlInitText == "" ) then {
                        _dispControlInitText = ctrlText _dispControl;
                    };
       
                    _dispControl ctrlSetText format [ "%8 (%2/%3 %4/%5 %6/%7)", _dispControlInitText, _cntGuns, _maxGuns, _cntMags, _maxMags, _cntBags, _maxBags, _typeName];
                };
            };
        };
    } else {
        _lookingat = objNull;
        _dispControlInitText = "";
    };
};
(thanks cyrq for the backpack update!)


Step Two
Now open your init.sqf (root of mission folder), find the following:
Code:
if (!isDedicated) then {

Inside this IF statement at the bottom before the closing brace, insert the following:
Code:
[] ExecVM "axs_gearmanagement\doGear.sqf";

For example, my if statement looks like this
(please use as reference only to where the snippet above should go - do NOT copy and paste this over your if statement!)
Code:
if (!isDedicated) then {
    //Conduct map operations
    0 fadeSound 0;
    waitUntil {!isNil "dayz_loadScreenMsg"};
    dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");
 
    //Run the player monitor
    _id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
 
    _playerMonitor =    [] execVM "fixes\player_monitor.sqf";
    _logistic = execVM "=BTC=_Logistic\=BTC=_Logistic_Init.sqf"; //Helicopter lift script
    _void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf"; //Initialise weight counter
 
    serverCommand = {
    };
 
    [] ExecVM "axs_gearmanagement\doGear.sqf";
};



Help, I use R3F Realism and they do not work together well!
Find and open the following file: R3F_DoWeight.sqf

Between
Code:
#endif

And

Code:
if(_gearbox_visible) then {

Insert
Code:
if ( !isNull cursorTarget ) then {
        _distance = ((getPos cursorTarget) distance (getPos player));
        if ( _distance < 10.5 ) then {
            _gearbox_visible = false;
        };
    };

I hope this little script is useful to you and your players!

Picture:
(thanks cyrq for the picture (note: this picture is a little different, but it gives you the idea))
20130417141327522.png


-- AlienX
 
Back
Top