Jump to content
Sign in to follow this  
Big Dawg KS

Best Way to Check if ArmA2 or OA is Running

Recommended Posts

Simple really, discuss the most ideal way to determine in your addon whether the user is running ArmA 2 or OA.

You could make your addon require version 1.51 or greater, but I'm looking for solutions that work in either ArmA 2 or OA (stand alone or combined).

The requiredVersion script command would be great if it didn't show a warning message when your using a lower version. Unfortunately I'm not sure if there's anyway to passively/discretely check the version number in script, but that would probably be the most ideal for my purposes.

Well, share your thoughts people, as this will probably be an issue for quite a few of us addon makers, at least until OA reaches sort of a Resistance status (where it's pretty much required for anything in the community).

Share this post


Link to post
Share on other sites

Well, i think configwise you can't determine which version is runnin and based on that loading different part of the config. AFAIK you can make OA config as ArmA 2 will just ignore unknown config entries.

Scriptingwise it is simple: use isClass on a object you know it is only in ArmA 2 or OA available:

_a2 = false;
_oa = false;

if (isclass(configFile >> "cfgVehicles" >> "UNIQUE_CLASSNAME_FOR_A2")) then {_a2 = true};
if (isclass(configFile >> "cfgVehicles" >> "UNIQUE_CLASSNAME_FOR_OA")) then {_oa = true};

But don't ask me now which class possibly is exclusive on each version. :D

Share this post


Link to post
Share on other sites

I think, this code will do the job:

//****************************************************************************
// Author: 
//     HeliJunkie
// Description:
//     Figure out wich Version of Arma(II) is running.
// Returns:
//    number
//        0= Arma
//        2 = Arma + Queens Gambit
//        4 = Arma2
//        8 = Operation Arrowhead
//        12 = Arma2 + OA
//****************************************************************************
private ["_returnValue"];
// We assume at least Arma is running
_returnValue = 0;

// Lets check for Queens Gambit and leave if found
// because there cant' be Arma2 (at the Moment)
if ( isclass(configFile >> "cfgPatches" >> "DBE1" ))  exitwith { 2 };

// Lets see if Arma 2 is running
if ( isclass(configFile >> "cfgPatches" >> "CAAir2_C130J" )) then
{
       _returnValue = 4;
};

// Now check for Operation Arrowhead Expansion
if ( isclass(configFile >> "cfgPatches" >> "CAAir_E" )) then
{
       _returnValue = _returnValue + 8;
};

// return the value to the caller
// Dont put an ";" at the end of the line !!!
_returnValue

Hope this will help.

Share this post


Link to post
Share on other sites

Yes, these solutions could work. The problem though is that they still rely on checking content, not the actual build/version number. While in reality we can usually assume that the content will be there, it's not ideal, as it is potentially prone to being broken if the content changes somehow (ex if someone somehow gets OA content into ArmA 2).

Share this post


Link to post
Share on other sites

Perhaps another way to check would be to use the info coming from supportInfo. I briefly checked, and for ArmA 2 v1.07 the size of the array (count supportInfo "") returned was 1370, for OA v1.52 it was 1407.

You could even consider doing a search inside the array returned for a command unique to OA (like e.g. AddCamShake), if you don't want to rely on those numbers, e.g. hint STR ("u:addcamshake ARRAY" IN (supportinfo "")) which will return TRUE for OA, FALSE for ArmA 2

Edited by HitmanFF
Added working example

Share this post


Link to post
Share on other sites

Yea, supportInfo works. It's still not perfectly ideal but for now I'm going to use it.

Share this post


Link to post
Share on other sites
I briefly checked, and for ArmA 2 v1.07 the size of the array (count supportInfo "") returned was 1370, for OA v1.52 it was 1407.

And what is the value for Arma2 + OA ?

And will the value be the same after some update to (maybe) 1.53 or something ????

I think your version has the Problem, that it maybe doesn't work after a minor update, because the size of the supportInfo Array maybe change.

I think there won't be a "perfekt" method to obtain such data...

unless BI maybe give us such a scriptcommand wich returns such data... :rolleyes:

Share this post


Link to post
Share on other sites

I used supportInfo, but I used a specific command instead of counting the whole array. Yes, that command could potentially be added to ArmA 2, but it's probably not an issue for me.

Share this post


Link to post
Share on other sites

Found the "offical" way to get version...

"BIS_fn_version"... available with Module "function library".

   Returns:
   Array -    list ov expansions
       0 - ARMA 2
       1 - Operation Arrowhead
       2 - <surprise>

("ov" is original spelling. Think it should be "of"... ;))

The only thing they do, is checking the classes:

"cfgPatches" >> "chernaurus" => Arma2

"cfgPatches" >> "ca_E". => Operation Arrowhead

So if both version are found you get an array: [0,1]

Share this post


Link to post
Share on other sites
Found the "offical" way to get version...

"BIS_fn_version"... available with Module "function library".

   Returns:
   Array -    list ov expansions
       0 - ARMA 2
       1 - Operation Arrowhead
       2 - <surprise>

("ov" is original spelling. Think it should be "of"... ;))

The only thing they do, is checking the classes:

"cfgPatches" >> "chernaurus" => Arma2

"cfgPatches" >> "ca_E". => Operation Arrowhead

So if both version are found you get an array: [0,1]

Yep, I just saw this the other day. Official or not, I still don't think it's a very good method. :rolleyes:

Edit: This method is fine when you want to detect which content the user has, but if you're looking for a specific engine build then it's no good.

Share this post


Link to post
Share on other sites

This is what i use:

if (isclass (configFile >> "cfgPatches" >> "CA") ) then
{
      hint "ArmA 2";
}
else
{
      hint "ArmA 2 OA";
};

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  

×