Home   Help Search Login Register  

Author Topic: Need to debug a function  (Read 431 times)

0 Members and 1 Guest are viewing this topic.

Rocko Bonaparte

  • Guest
Need to debug a function
« on: 25 Oct 2004, 02:57:20 »
I am writing a function to test if the flag carrier is the crew member of the single-person vehicles I am using.  The test is within the bounds of a trigger I understand the script isn't too robust right now -- it should be prepared for non-vehicles and vehicles were the player could be in another crew slot.  But I'm just trying to get it working right now.  I get an error in the ForEach loop:

Code: [Select]
// Calculates if the flag owner is in the scoreable zone, assuming the flag owner is in a 1p tank
// Arguments -- flag to test for a score, list of units
private ["_flag", "_zone", "_vehicle", "_flag_found"];

_flag = _this select 0;
_zone = _this select 1;

_flag_found = false;


// See if the flag is being owned by a crew member in this zone's list
{

   _vehicle = _x select 0;

   If(flagowner _flag == ((crew _vehicle) select 0)) Then {
      hint "Found flag in list";
      _flag_found = true;
   };
} ForEach list _zone;

_flag_found
If I take the conditional out the ForEach loop it works for the limited case where the player is the only thing in that zone.  I am getting my ForEach syntax from snYper's function tutorial, and the error string I get is so long in game that it doesn't even get to the message before it's cut off the screen.  Is there a way to prevent that?