Jump to content
Sign in to follow this  
saetheer

Pull vehicle classname usingCfgVehicles

Recommended Posts

Hi,

I'm trying to pull an array for all vehicles that uses the config: configfile >> "CfgVehicles" >> "Car"

But I have noe clue what to do with it.

For the Array I'm trying to fill with classname, this is displayed in a RscListBox, the knowledge of RscListBox should be irrelevant.

_car = [configfile >> "CfgVehicles" >> "Car"]; 
{lbAdd[1500,_x]} forEach _car;

Anyway, anyone care to help me out?

Share this post


Link to post
Share on other sites
_cfgVehicles = ( configFile >> "CfgVehicles" );

for "_i" from 0 to ( count _cfgVehicles ) -1 do
{

_entry = _cfgVehicles select _i;

if( isClass _entry ) then
{

	_class = configName _entry;
	_scope = getNumber( _entry >> "scope" );

	if( _scope >= 2 && { _class isKindOf "Car" } ) then {

			lbAdd[ 1500, _class ];

	};

};

};

Share this post


Link to post
Share on other sites

Thanks.

Is it possible to give it a more userfriendly name than C_offroad_01_F etc?

Share this post


Link to post
Share on other sites

This:

lbAdd[ 1500, _class ];

To this:

lbAdd[ 1500, getText( _cfgVehicles >> _class >> "displayName" ];

Share this post


Link to post
Share on other sites

Instead of _class try getText(_entry >> "displayName") You'll probably want to keep track of the _class somewhere though.

Share this post


Link to post
Share on other sites

you would know how I could detect when the index of a combobox is changed?

Share this post


Link to post
Share on other sites

this way still works for me.

_old_selectedCombo = -1;
while{!SQU_CloseDisplay}do
{
_selectedCombo1 = lbCurSel SQU_IDC_Combo;

if(_selectedCombo != _old_selectedCombo)then
{

              //it's changed
	_old_selectedCombo = _selectedCombo;

       };   

sleep 1;
};

Share this post


Link to post
Share on other sites

any change of an example for extracting the infantry (configfile >> "CfgGroups" >> "West" >> "BLU_F") groups classnames from cfgGroups storing as an array

Share this post


Link to post
Share on other sites
any change of an example for extracting the infantry (configfile >> "CfgGroups" >> "West" >> "BLU_F") groups classnames from cfgGroups storing as an array

Thanks for reminding me. :) Added to the wiki!

Share this post


Link to post
Share on other sites

Thanks. But I dont think I can use this, since I'm also using lbClear within that loop, which will be really annoying to see the items reappear/blinking really fast.

What I'm looking for is perhaps a eventhandler that is "always active" while the dialog is open, and only triggers when a new item is selected in the combobox.

edit: wait, I think that is what you presented. I'll have to test when I get home.

Edited by Saetheer

Share this post


Link to post
Share on other sites
any change of an example for extracting the infantry
Thanks for reminding me. Added to the wiki!

Sorry I mistyped "change" should be "chance", anyway I have my own example to create an array of infantry groups and then spawn a random one...

TAG_WEST_GROUPS_INF = [];
_cfgGroups = ( configfile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry");


for "_i" from 0 to ( count _cfgGroups ) -1 do
{
_entry = _cfgGroups select _i;

   if( isClass _entry ) then {
   TAG_WEST_GROUPS_INF = TAG_WEST_GROUPS_INF + [_entry];
   };

};


_grp = TAG_WEST_GROUPS_INF call BIS_fnc_selectRandom;


[getPos player, side player, _grp] call BIS_fnc_spawnGroup;

Share this post


Link to post
Share on other sites

...

Really appreciate this. This created a list. Is there anyway to use something like this:

item_select = ( configFile >> "CfgVehicles" >> lbCurSel 1500 );

to find the class for the selected item?

Share this post


Link to post
Share on other sites

You could save the class name for each item:

// ...
_index = lbAdd [1500, getText(configFile >> "CfgVehicles" >> _class >> "displayName")];
lbSetData [1500, _index, _class];

Then in your lbSelChanged event handler:

_selected = ( configFile >> "CfgVehicles" >> lbData [1500, lbCurSel 1500]);

Share this post


Link to post
Share on other sites
You could save the class name for each item:

// ...
_index = lbAdd [1500, getText(configFile >> "CfgVehicles" >> _class >> "displayName")];
lbSetData [1500, _index, _class];

Then in your lbSelChanged event handler:

_selected = ( configFile >> "CfgVehicles" >> lbData [1500, lbCurSel 1500]);

^this didnt work.

Tried something else

When I select an item in the list, and press spawn button, it spawnes wrong vehicle.

_index = lbAdd [1500, getText(configFile >> "CfgVehicles" >> _class >> "displayName")];

lbSetData [1500, _index, _class];

SelectClass = _class;

and when button clicked:

SelectClass createVehicle (getmarkerpos "Spawn");

Share this post


Link to post
Share on other sites

Instead of

SelectClass createVehicle (getmarkerpos "Spawn");

You want

lbData [1500, lbCurSel 1500] createVehicle (getmarkerpos "Spawn");

Share this post


Link to post
Share on other sites
Instead of

SelectClass createVehicle (getmarkerpos "Spawn");

You want

lbData [1500, lbCurSel 1500] createVehicle (getmarkerpos "Spawn");

Appreciate your time, but it aint it either. Return nothing by the looks of it

---------- Post added at 22:40 ---------- Previous post was at 21:31 ----------

Should'nt this work flawless? On button pressed, this is the only thing in the script.

_vehicle = lbData [1500, lbCurSel 1500] 

_vehicle createVehicle (getmarkerpos "Spawn");

Share this post


Link to post
Share on other sites

Noone else have a way to pull the selected item's classname into a string?

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  

×