Jump to content
Sign in to follow this  
gnarly_rider

Deleted: Nesting IF THEN ELSE statements?

Recommended Posts

One can code that in several ways. Here's one way:

_who      = _this select 0;
_vehicle1 = _this select 1;
_vehicle2 = _this select 2;
_vehicle3 = _this select 3;


// Find the first functional vehicle of the three
_vehicles=[_vehicle1, _vehicle2, _vehicle3];
_c=count vehicles;
_found=false;        // Have we found a working vehicle?
_i=0;

// Search through the array of candidate vehicles and
// see if we can find one that's usable
_vehicleToUse=objNull;
while {_i<_c && !_found } do
{
   _v=_vehicles select _i;
   if (canMove _v) then
   {
       _vehicleToUse=_v;
       _found=_true;
   };
   _i=_i+1;
}; 

if (_found) then
{
   _who globalChat format ["I will use vehicle %1", vehicleVarName _vehicleToUse];

   _who doMove getPos _vehicleToUse;
   _who assignAsDriver _vehicleToUse;
   [_who] orderGetIn true;
}
else
{
   _who globalChat "No usable vehicle was found.";
};

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  

×