Jump to content

Recommended Posts

I play on an Altis life server and I am making a virtual items list to spawn virtual items in locally (to the admins inventory)

 

The dialog (Rsedit) works fine in which to add numbers but when I click to it does nothing

 

I have tried so many different ways but something is not working and I can't figure out where also tried lbText as well as lbData

 

If I run this from debug (local exec) it gives me the item

 

_item = "largegift";
_num = 1;
[true, _item, _num] call RR_fnc_handleInv;

 

 

Code

private ["_item","_num"];

_display = findDisplay 9801;
_item = lbData [9873, (lbCurSel 9873)];
_num = parseNumber(ctrlText 65465);


//Add
_add = _display ctrlCreate ["ModShop_RscButton",65466];
_add ctrlSetPosition [0.432969 * safezoneW + safezoneX, 0.511 * safezoneH + safezoneY, 0.061875 * safezoneW, 0.022 * safezoneH];
_add ctrlSetText "Add Item";
_add ctrlCommit 0;
_add ctrlAddEventHandler ['ButtonClick','[true, _item, _num] call RR_fnc_handleInv'];

 

RR_fnc_HandleInv

private["_math","_item","_num","_return","_var","_weight","_value","_diff"];

params [
    ["_math",false,[false]],
    ["_item","",[""]],
    ["_num",0,[0]]
];

Can post full script if needed

 

Virtual Items List

lbclear _lblist;

{
	_itemName = format ["%1",configName _x];
	_itemDisplayName = getText(missionConfigFile >> "VirtualItems" >> _itemName >> "displayname");
	_itemDisplayIcon = getText(missionConfigFile >> "VirtualItems" >> _itemName >> "icon");
	_itemDisplayName = localize _itemDisplayName;

	if !(_itemName isEqualTo "") then {
		
		_lbList lbAdd format ["%1",_itemDisplayName];
		_lbList lbSetData [(lbSize _lbList)-1,_itemName];
		_lbList lbSetPicture [(lbSize _lbList )-1,_itemDisplayIcon];
	};
} forEach ("true" configClasses (missionConfigFile >> "VirtualItems"));

 

Share this post


Link to post
Share on other sites
On 8/31/2020 at 12:11 AM, General McTavish said:

_add ctrlAddEventHandler ['ButtonClick','[true, _item, _num] call RR_fnc_handleInv'];

as...

'[true, _item, _num] call RR_fnc_handleInv'

...is CODE as STRING passed to the event, when the event occurs and the engine runs the code it has no idea what _item and _num are as they will not exist in the current context.

You need to format that values of _item and _num into the code string.

_add ctrlAddEventHandler[ 'ButtonClick', format[ '[ true, %1, %2 ] call RR_fnc_handleInv', str _item, _num ]];

 

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

×