Jump to content
Sign in to follow this  
General McTavish

Spawn Vehicles Listbox

Recommended Posts

I am trying to create a list box menu that will spawn vehicles on left double-click

 

The following code populates the Listbox with all the vehicles and pictures etc but after reading many posts I am unsure on how to code the rest so that when I double-click it gets the class name from the index and then spawns the vehicle

_lbList = (findDisplay 9801) displayCtrl 9877;

disableSerialization;

private["_position","_className","_displayName"];

lbclear _lblist;

_vehiclelist = ("(configname _x isKindOf 'LandVehicle' or configname _x isKindOf 'Air' or configname _x isKindOf 'Ship') && getNumber (_x >> 'scope') == 2 " configClasses (configfile >> "CfgVehicles"));

{
    _className = configName _x;
    _vehicle = getText(configFile >> "CfgVehicles" >> _className >> "displayName");
    _picture = getText(configFile >> "CfgVehicles" >> _className >> "picture");


   if !(_className isEqualTo "") then {
        _index = _lbList lbAdd _vehicle;
        _lbList lbSetPicture [_index,_picture];
        _lbList lbSetData [_index,_className];
        _lbList lbSetTooltip [_index,_className];

   }; 

} forEach _vehiclelist;

lbSort [_lblist, "ASC"];
        class VehiclesBox: RscListBox
        {

            idc = 9877;
            x = 0.845468 * safezoneW + safezoneX;
            y = 0.126 * safezoneH + safezoneY;
            w = 0.134062 * safezoneW;
            h = 0.858 * safezoneH;
            onLBDblClick = "systemChat str ['onLBDblClick',_this]; false";
            colorBackground[] = {0.8,0,0.5,0.1};

        };

 

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  

×