Jump to content
Sign in to follow this  
CarlGustaffa

nearestObject or trigger

Recommended Posts

Hi

I'm trying to use nearestObjects or a trigger to find out if I have a certain type of vehicle around. Problem with using nearestObjects is that is finds all subclasses as well.

What I have this far is this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_obj = nearestObjects[getMarkerPos "bonus_vehicles",["HMMWV50"],30];

if ( count _obj >0 && ((typeOf (_obj select 0)) ==  "HMMWVMK")) then {ctrlEnable [11006, true]} else {ctrlEnable [11006, false]};

It looks a bit weird, because the HMMWV50 is the parent class, not the HMMWV which you might expect. Now, this works ok if it is the only Mk near the marker, but (naturally) it fails when I place a TOW there as well since I don't count through every item in the array.

So, question: How can I easily find out if there are more than 0 of a specified *type* (instead of *kind*) within the search distance?

I also tried placing a trigger, but I'm having problems with the condition field. What is the best solution to this?

I know it must be kindOf obvious, but I just can't seem to nail it right now biggrin_o.gif

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_obj = nearestObjects[getMarkerPos "bonus_vehicles",["HMMWV50"],30];

if (({(typeOf _x) in ["HMMWVMK","HMMWVTOW"]} count _obj)>0) then {ctrlEnable [11006, true]} else {ctrlEnable [11006, false]}

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  

×