Jump to content
Sign in to follow this  
barbolani

Know type Of units from cfgGroups

Recommended Posts

Hello!

I know there is a way to do it, but it is beyond my knowledge right now.

I use to spawn groups the BIS_fnc_spawnGroup, for example: _grupo = [_posorigen, EAST, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_Fnc_spawnGroup;

It's because I have a table of costs for each type of units, and when the player buys one group in Antistasi, I'm calculating the total cost with the DIRTY trick of really spawning it, and calculating the cost in a foreach units group.

I want to do it better, without spawning (because now, If player hasnt enough money, I hace to spawn and despawn the group).

Thanks in advance!

Edited by barbolani

Share this post


Link to post
Share on other sites
//Test variable for current funds	
_money = 700;

//Temporary cost table for testing
costTable = [
"O_soldier_SL_F", 100,
"O_soldier_F", 100,
"O_soldier_LAT_F", 100,
"O_soldier_M_F", 100,
"O_soldier_TL_F", 100,
"O_soldier_AR_F", 100,
"O_soldier_A_F", 100,
"O_medic_F", 100
];

//Cfg group to spawn
_cfgGroup = ( configFile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad" ) ;

//Varaible to hold total cost of group
_totalCost = 0;

//For each unit in the config group
//Get the 'vehicle' class type
//Find the class type in the cost table
//Add its value to totalCost
"
_class = getText ( _x >> 'vehicle' );
_index = costTable find _class;
_totalCost = _totalCost + ( costTable select ( _index + 1 ));
false
"configClasses _cfgGroup;

//Do we have enough money
if ( _totalCost > _money ) then {

//If not then hint to the player
hintSilent "You do not have enough money";
}else{

//If we do spawn the group
_newGroup = [ getPosATL player, EAST, _cfgGroup ] call BIS_Fnc_spawnGroup;
};

Should be enough info to get you going.

Share this post


Link to post
Share on other sites

Thanks, this plus what I could "steal" from bis_fnc_spawngroup solved the issue, thanks a lot!

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  

×