Home   Help Search Login Register  

Author Topic: check if a addon is present  (Read 1943 times)

0 Members and 1 Guest are viewing this topic.

Offline myke13021

  • Contributing Member
  • **
  • Myke
check if a addon is present
« on: 08 Sep 2007, 21:45:51 »
Hi

is there a way to determine if a certain addon (in my special case: MAP_misc) is installed?

What i'm tryin to do:
In my coop essential pack i'm using markers which are part of the MAP_misc. Now to keep it compatible for those who doesn't have this addon i would like to define repacement markers (original BIS markers, i.e. DOT).

So, is it possible to check if addon present then use these markers else use standard markers?

If i know how to query this, i could write it but i don't see the way.


Myke out

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: check if a addon is present
« Reply #1 on: 08 Sep 2007, 21:48:52 »
Aye

You might be able to make use of the configFile command in some way for this, I haven't used it too much but hoz has, he might be able to help more.

Something along the lines of:

_cfg =(configFile >> "CfgWhatever" >> "Class");


Planck
« Last Edit: 08 Sep 2007, 21:53:53 by Planck »
I know a little about a lot, and a lot about a little.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: check if a addon is present
« Reply #2 on: 08 Sep 2007, 22:06:59 »
thx Planck

already thought about this configFile command but the logic behind it will not talk to me.  :D

If someone could give a real example (doesn't need to be the MAP_misc) and show me how to achieve the needed parameters (maybe de-pbo some stuff) would be a great help, but be warned, i'm a slow learner...explain it how you would do it to a 5 year old.  :D


Myke out

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re: check if a addon is present
« Reply #3 on: 08 Sep 2007, 23:44:05 »
In OFP it was possible to detect if an addon is present by trying to camCreate it, then check the object with isNull.

This code can be used to detect if you have FDF Mod:

Code: [Select]
BDO_isFDFMod = false

_tmp = "FDFbloodsplatS" camCreate [0,0]

if (!isNull _tmp) then {BDO_isFDFMod = true}

deleteVehicle _tmp

After that the variable BDO_isFDFMod tells you whether you have FDF Mod installed or not.

I'm not sure why I have deleteVehicle there instead of camDestroy. This code is from a couple of years ago so I don't recall what is up with that. Maybe I had some problem destroying the bloodsplat with camDestroy.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: check if a addon is present
« Reply #4 on: 09 Sep 2007, 00:10:26 »
Thx Baddo, i'll give this a try....but one question though...does a camcreate or any create with an object that isn't available (as it's in a needed addon) not throw an error message?

Anyway, i'll try it out and see what happens.


Myke out

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: check if a addon is present
« Reply #5 on: 09 Sep 2007, 00:20:15 »
If you know that one of the MAP marker classes is MAP_marker1 (I made that marker class up; I imagine you know what the marker names are if you are using the pack already), then you could assume that if that one marker exists then the whole pack is installed with:
Code: [Select]
_mapMarkersInstalled = isClass (configFile >> "CfgMarkers" >> "MAP_marker1");
And then you can use something like this:
Code: [Select]
_marker = createMarker ["diddlydee", _pos];
_marker setMarkerShape "ICON";

if (_mapMarkersInstalled) then
{
    _marker setMarkerType "MAP_marker77";
}
else
{
    _marker setMarkerType "dot";
};

** EDIT **
Corrected the stupid code errors. Teach me not to make code up without thinking, especially since I implemented this exact thing YESTERDAY ;P
« Last Edit: 09 Sep 2007, 00:31:54 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re: check if a addon is present
« Reply #6 on: 09 Sep 2007, 00:24:06 »
Thx Baddo, i'll give this a try....but one question though...does a camcreate or any create with an object that isn't available (as it's in a needed addon) not throw an error message?

Anyway, i'll try it out and see what happens.


Myke out

In OFP it doesn't throw an error. I have not tested this in ArmA but I think it works the same as in OFP, but no promises a I haven't tested it. Also you got there another suggestion from Spooner which could also work for your situation.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: check if a addon is present
« Reply #7 on: 09 Sep 2007, 00:29:33 »
Thx Spooner, that sounds indeed promising to me.

Please let me clarify, just to make sure i understood it correctly:

In the line:
Code: [Select]
_mapMarkersInstalled = isClass (configFile >> "CfgMarkers" >> "MAP_marker1");
CfgMarkers is a given, i don't have to research around to get a correct entry there. And yes, as "testmarker" i could take "ARMA_MARKER_Car" as this one exists in the MAP_misc addon.

Therefor this line:
Code: [Select]
_mapMarkersInstalled = isClass (configFile >> "CfgMarkers" >> "ARMA_MARKER_Car");
would set me the variable _mapMarkersInstalled either to TRUE or FALSE.

And the rest is a simple if then else story.


Can you confirm that i wasn't too stupid to get it in my mind?  :D

Thx all for your replies.


Myke out

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: check if a addon is present
« Reply #8 on: 09 Sep 2007, 00:35:36 »
Yep, that sounds fine, though notice I just edited the if/else part of my code, since I was getting cocky and writing it that bit too fast. At least now, I double-checked what I wrote against code I definitely had working fine yesterday.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: check if a addon is present
« Reply #9 on: 09 Sep 2007, 00:44:01 »
Yep, thanks alot Spooner. The if then else part isn't a problem, i just had to have a way to determine if the markers i'd like to use were present or do i have to fiddle with ArmA default markers. Wouldn't make it "you MUST have this addon for the scripts to work properly", always prefer to let user decide if he want to have it or not.

So my if then else looks like this (the determining if present occurs in another script):
Code: [Select]
if (cep_markers_installed) then
{
switch (_cep_typeof) do
{
case "ARMORED":
{
_cep_marker_type = "ARMA_MARKER_Abrams";
};
case "LIGHT":
{
_cep_marker_type = "ARMA_MARKER_M113";
};
case "ARMED":
{
_cep_marker_type = "ARMA_MARKER_HumveeMG";
};
case "UNARMED":
{
_cep_marker_type = "ARMA_MARKER_Car";
};
case "STANDARD":
{
_cep_marker_type = "ARMA_MARKER_Man";
};
case "SPECOPS":
{
_cep_marker_type = "ARMA_MARKER_SpecOp";
};
};
}
   else
{
_cep_marker_type = "Dot";
};


Myke out


:EDIT:

This solution works like a charm....no error thrown, but marker replaced by original markers...excellent...and therefor..


- SOLVED -
« Last Edit: 09 Sep 2007, 02:38:15 by myke13021 »