Jump to content
thoops99

How To Make A Custom Player Inverntory

Recommended Posts

Just like the title says i would like to know how to customize the arma 3 inventory so i can put a custom one on my server. I'm making a modded altis life and i'm wanting to display your y menu items in the inventory. The reason being that i set it up so you have to buy a phone in order to access your y menu but it does not make much sense to have to buy a phone in order to eat. I know that with alits life i could just create a dialog and when the user presses a button then i could have it show only the y menu items and not the cellphone stuff but this would still be handy to know. 

 

This is an example i found ONLINE all credit goes to the creator. (Link)

3.jpg?w=1024&h=576

Share this post


Link to post
Share on other sites

Very simple, just two steps:

  1. Create custom inventory dialog
  2. Handle player gear opening event, where replace default dialog with your own
  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, serena said:

Very simple, just two steps:

  1. Create custom inventory dialog
  2. Handle player gear opening event, where replace default dialog with your own

Ok. With altis life everything had a particular idc (I think it's called that). Does the inventory do the same? How does the game know to show ground items in the bar. How does it know where to show the hedgear etc.

Share this post


Link to post
Share on other sites

I'll be looking through it as well.  This is my current use case.

 

Problem

Inventory size in arma is limited, however for my mission I want to simulate an unlimited storage of gear

 

Possible solution

All gear is stored in a multidimensional array stored as a variable server side on the Object.  When opening the inventory you intercept the default inventory gui and create your own.  The left side will be a list with all the gear and the amount available.  The right side will be the player layout, I like to keep it as it is default but not sure if I can get my hands on that gui code ?  When you drag and drop from the left to the right, the item gets assigned to the player and the array updated, then the gui refreshes.  Same way the other way around the item gets unassigned and the array updated, gui refreshes.  All this happens by remoteExec to the server, the server handles the assigning and unassigning of the items to the player.  This way we circumvent the maxLoad parameter on the Objects blueprint and use our array as storage.

 

Any thoughts on this ?  It might give some insights to Thoops99 as well (who's thread I just hijacked ...)

Share this post


Link to post
Share on other sites

celludriel, do you know about:

uniformContainer player addmagazineCargo  ["HandGrenade", 2000]

n46HEIV.png

  • Like 1

Share this post


Link to post
Share on other sites
8 hours ago, celludriel said:

 I like to keep it as it is default but not sure if I can get my hands on that gui code ?

Open the GUI editor, CTRL + i, configfile >> "RscDisplayInventory" will load the BI inventory gui for you to look at.

Most of it is handled by the game engine but you can get an idea of the general layout etc.

 

8 hours ago, celludriel said:

When opening the inventory you intercept the default inventory gui and create your own.  The left side will be a list with all the gear and the amount available.

e.g You can get an idea of where to place a listbox next to it and do something like...

player_stash = ( items player call BIS_fnc_consolidateArray ) +
( weapons player call BIS_fnc_consolidateArray ) +
( magazines player call BIS_fnc_consolidateArray );

player addEventHandler [ "InventoryOpened", {
	
	h = [] spawn {
		disableSerialization;
		
		waitUntil { !isNull ( findDisplay 602 ) };
		_display = findDisplay 602;
		
		_lb = _display ctrlCreate [ "RscListBox", 10001 ];
		_lb ctrlSetPosition [
			0.681818 * safeZoneW + safeZoneX, 
			0.247 * safeZoneH + safeZoneY,
			0.1 * safeZoneW, 
			0.506 * safeZoneH
		];
		_lb ctrlCommit 0;
		
		TAG_fnc_fillLB = {
			{
				_x params[ "_item", "_count" ];
				_text = format[ "%1 - %2", _item, _count ];
				_index = _lb lbAdd _text;
				_lb lbSetValue [ _index, _count ];
				_lb lbSetData [ _index, _item ];
				_pic = switch true do {
					case ( isClass( configFile >> "CfgWeapons" >> _item ) ) : {
						getText( configFile >> "CfgWeapons" >> _item >> "picture" )
					};
					case ( isClass( configFile >> "CfgMagazines" >> _item ) ) : {
						getText( configFile >> "CfgMagazines" >> _item >> "picture" )
					};
					case ( isClass( configFile >> "CfgVehicles" >> _item ) ) : {
						getText( configFile >> "CfgVehicles" >> _item >> "picture" )
					};
					case ( isClass( configFile >> "CfgGlasses" >> _item ) ) : {
						getText( configFile >> "CfgGlasses" >> _item >> "picture" )
					};
				};
				_lb lbSetPicture [ _index, _pic ];
			}forEach player_stash;
		};
		
		call TAG_fnc_fillLB;
		
		_lb ctrlAddEventHandler [ "LBDblClick", {
			params[ "_lb", "_index" ];
			
			_item = _lb lbData _index;
			player addItem _item;
			_count = ( _lb lbValue _index ) - 1;
			if ( _count > 0 ) then {
				_lb lbSetValue [ _index, _count ];
				_lb lbSetText [ _index, format[ "%1 - %2", _item, _count ] ];
				{
					_x params[ "_stash_item", "_stash_count" ];
					if ( _stash_item == _item ) exitWith {
						player_stash select _forEachIndex set[ 1, _count ];
					};
				}forEach player_stash;
			}else{
				lbClear _lb;
				{
					_x params[ "_stash_item", "_stash_count" ];
					if ( _stash_item == _item ) exitWith {
						_nul = player_stash deleteAt _forEachIndex;
					};
				}forEach player_stash;
				call TAG_fnc_fillLB;
			};
		}];
		
	};
}];

Just a real quick dirty example.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Larrow this can put me on the way, I was already looking at some work others did like AustinMedic he made some kind of Inventory System this gives me another idea how to proceed !

Share this post


Link to post
Share on other sites
4 hours ago, serena said:

celludriel, do you know about:


uniformContainer player addmagazineCargo  ["HandGrenade", 2000]

n46HEIV.png

 

Well I do but if you do that it's the same as with a container where you add an insane amount of items, they get added and fill up the inventory, but ingame later you can't add anything anymore until you empty it below the maxLoad parameter :(.  So I really like to try creating a custom Inventory GUI as close to the original as possible.

Share this post


Link to post
Share on other sites

This is an example of a custom inventory system using a simple GUI and some scripting. This video is from an old project of mine. I made a quick video for you - excuse the poor quality, my computer is slowly dying.

 

 

  • Like 1

Share this post


Link to post
Share on other sites
46 minutes ago, hallyg said:

This is an example of a custom inventory system using a simple GUI and some scripting. This video is from an old project of mine. I made a quick video for you - excuse the poor quality, my computer is slowly dying.

 

 

 

It might be best to start out small like this, together with Larrow's prototype I should be able to get something going.  I like to keep the normal GUI as stated but that means a lot of eventhandlers, like a right click on a weapon could put the weapon in the primary, secondary or handgun slot, a first aid pack in a backpack, etc... A lot of small stuff that can go wrong and needs to be covered.  It's a challenge :)

Share this post


Link to post
Share on other sites

Well using Larrow's instructions I managed to extract the gui classes

 

https://github.com/Celludriel/Simple_CTI/blob/develop/custom/modules/ArsenalModule/gui/DefaultInventory.hpp

 

As expected and told by him all eventhandlers are gone, so are the right icons to use for the item holders.  There is some excess stuff on the default inventory nobody really cares about I believe.  I'm getting the feeling it is better to just start simple and then go more complex in further iterations.  I probably make a new git repository for this so I can develop it independantly from SimpleCTI.  Anyone that wants to help then more then welcome, goal of the project is give objects (not players, units or vehicles) the ability to have an unlimited storage inventory.

 

 

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

×