Jump to content
Sign in to follow this  
Double Doppler

isClass in array?

Recommended Posts

Hi, is there any possible way to check if config entries (say, cfgPatches) are in an array?

Something like

cfgarray = ["CAData"];

isClass >> CfgPatches in cfgarray

Perhaps finding if the next config entry is in the array, but with no set entry (counts all cfgPatches and returns if they are the array or not)

If(isClass(configFile >> "CfgPatches" >> "(_cfg in cfgarray)")) Then {...

^

I need a function to get the next entry but without setting a specific text

Obviously not in this syntax it would not work but I am just curious as to if any of you editing gurus have done something like this before?

Edited by Double Doppler

Share this post


Link to post
Share on other sites

something like this you mean?

_a2 = false;
_oa = false:
_co = false;
if (isClass(configFile >> "CfgPatches" >> "Chernarus")) then {
_a2 = true;
diag_log text "A2 installed";
};
if (isClass(configFile >> "CfgPatches" >> "Takistan")) then {
_oa = true;
diag_log text "OA installed";
};
if (_a2 AND _oa) then {
_co = true;
diag_log text "CO installed";
};

Share this post


Link to post
Share on other sites

No, I want to check if all classes on the player's loaded game are in an array, and return true if one of them (or more) is not.

Share this post


Link to post
Share on other sites
{!isClass (configFile >> "CfgPatches" >> _X)} count cfgarray > 0; // returns true if number of cfgarray elements that aren't classes in CfgPatches is more than zero

Share this post


Link to post
Share on other sites
{!isClass (configFile >> "CfgPatches" >> _X)} count cfgarray > 0; // returns true if number of cfgarray elements that aren't classes in CfgPatches is more than zero

Actually I need it to do vice versa. The CfgPatches must be counted and if not in the cfgarray then it will return as true.

Share this post


Link to post
Share on other sites

That's a little more complicated:

cfgarray = ["class1","class2","class3"];

_patches = configFile >> "CfgPatches";
_c = count _patches;
_loop = true;
_missing = false; // will become true if any class in CfgPatches is missing from cfgarray
_n = 0;
while{_loop}do{
  _cur = _patches select _n;
  if(!_cur in cfgarray)then{ // Note: "in" is case sensitive, so classes in cfgarray must match those in the config file exactly
     _missing = true;
     _loop = false;
  };
  _n = _n + 1;
  if(_n > _c)then{
     _loop = false;
  };
};

Edited by Big Dawg KS

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  

×