Jump to content
Sign in to follow this  
malakdecaen

How to interact in inventory ? left click on item

Recommended Posts

Hi everybody ,

Do you know if is possible to interact with inventory item with a left click on them ?

Left click on item open a little menu "use" or "build" .

I find this on dayz mod :

private ["_control","_button","_parent","_group","_pos","_item","_conf","_name","_cfgActions","_numActions","_height","_menu","_config","_type","_script"];
_control = 	_this select 0;
_button =	_this select 1;
_parent = 	findDisplay 106;

if (_button == 1) then {	
_group = _parent displayCtrl 6902;

_pos = 		ctrlPosition _group;
_pos set [0,((_this select 2) + 0.48)];
_pos set [1,((_this select 3) + 0.07)];

_item = gearSlotData _control;

_conf = configFile >> "cfgMagazines" >> _item;
if (!isClass _conf) then {
	_conf = configFile >> "cfgWeapons" >> _item;
};
_name = getText(_conf >> "displayName");

_cfgActions = _conf >> "ItemActions";
_numActions = (count _cfgActions);
_height = 0;

//Populate Menu
for "_i" from 0 to (_numActions - 1) do 
{
	_menu = 	_parent displayCtrl (1600 + _i);
	_menu ctrlShow true;
	_config = 	(_cfgActions select _i);
	_type = 	getText	(_config >> "text");
	_script = 	getText	(_config >> "script");
	_height = _height + (0.025 * safezoneH);
	_menu ctrlSetText format[_type,_name];
	_menu ctrlSetEventHandler ["ButtonClick", format["_id = '%2' %1;",_script,_item]];
};
_pos set [3,_height];
//hint format["Obj: %1 \nHeight: %2\nPos: %3",_item,_height,_grpPos];		

_group ctrlShow true;
ctrlSetFocus _group;
_group ctrlSetPosition _pos;
_group ctrlCommit 0;
};

please help me i really appreciate .

thanks and sorry for my english .

Share this post


Link to post
Share on other sites
Hi everybody ,

Do you know if is possible to interact with inventory item with a left click on them ?

Left click on item open a little menu "use" or "build" .

I find this on dayz mod :

private ["_control","_button","_parent","_group","_pos","_item","_conf","_name","_cfgActions","_numActions","_height","_menu","_config","_type","_script"];
_control = 	_this select 0;
_button =	_this select 1;
_parent = 	findDisplay 106;

if (_button == 1) then {	
_group = _parent displayCtrl 6902;

_pos = 		ctrlPosition _group;
_pos set [0,((_this select 2) + 0.48)];
_pos set [1,((_this select 3) + 0.07)];

_item = gearSlotData _control;

_conf = configFile >> "cfgMagazines" >> _item;
if (!isClass _conf) then {
	_conf = configFile >> "cfgWeapons" >> _item;
};
_name = getText(_conf >> "displayName");

_cfgActions = _conf >> "ItemActions";
_numActions = (count _cfgActions);
_height = 0;

//Populate Menu
for "_i" from 0 to (_numActions - 1) do 
{
	_menu = 	_parent displayCtrl (1600 + _i);
	_menu ctrlShow true;
	_config = 	(_cfgActions select _i);
	_type = 	getText	(_config >> "text");
	_script = 	getText	(_config >> "script");
	_height = _height + (0.025 * safezoneH);
	_menu ctrlSetText format[_type,_name];
	_menu ctrlSetEventHandler ["ButtonClick", format["_id = '%2' %1;",_script,_item]];
};
_pos set [3,_height];
//hint format["Obj: %1 \nHeight: %2\nPos: %3",_item,_height,_grpPos];		

_group ctrlShow true;
ctrlSetFocus _group;
_group ctrlSetPosition _pos;
_group ctrlCommit 0;
};

please help me i really appreciate .

thanks and sorry for my english .

great quote, You just saved me a ton of work.

But yeah,

It reads ItemActions from cfgWeapons,

Then assigns variables based on those custom items.

and then just adds a ui ontop

Its scripted really clever and could probably work on A3.

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
Sign in to follow this  

×