Jump to content
austin_medic

If statment being completely ignored

Recommended Posts

So got another issue with my unit interaction system that I have no clue how to solve.

 

I got an if statement checking for an enemy factionto add some variables and event handlers to, but the if statement seems to be completely disregarded and the handlers get added to all units instead of just enemies.

 

 
{
_x setVariable ["AUSMD_interact_tiedUp",false,true];
_x setVariable ["AUSMD_interact_arrested",false,true];
_x setVariable ["AUSMD_interact_beingInterrogated",false,true];
_x setVariable ["AUSMD_interact_gaveInfo",false,true];
if(side _x == east && !isPlayer _x) then //problem is here
{
   _hitHandle = _x addEventHandler
   [
      "Hit",
      {
       if(side (_this select 0) != side (_this select 1) && !((_this select 0) getVariable "AUSMD_interact_surrendered")) then 
     {
        _chance = 5;
        _chance2 = 395;


    if(random 400 < _chance && random 400 > _chance2 && !((_this select 0) getVariable       "AUSMD_interact_arrested")) then
     {
            [(_this select 0)] spawn AUSMD_fnc_surrender;
      };
     };
    }
  ];
    _x addEventHandler["Killed",{_x removeEventHandler["Hit",_hitHandle];}];
};
} forEach allUnits;

no errors provided at all.

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

×