Jump to content
doctorbutts

Scripting help. Where did I screw up? (undefined variable)

Recommended Posts

I have a trigger that starts a script:

OnAct

null = [suicardriver_2] execVM "ambush\carfollow.sqf";

ambush script
 

_driverman = _this select 0;

_driverman setBehaviour "CARELESS";
_driverman setSpeedMode "FULL";

_fol = [] spawn { 
 while {alive _driverman} do { 
  _driverman doMove (position veh_food); 
  sleep 5; 
 }; 
};

Whenever the trigger is touched, I get an undefined variable error- but only in the following area:

_fol = [] spawn { 
 while {alive _driverman} do { 
  _driverman doMove (position veh_food); 
  sleep 5; 
 }; 
};

(script error says line 7 is the issue).

Share this post


Link to post
Share on other sites
_fol = _this spawn { 
  _driverman = _this select 0;

  _driverman setBehaviour "CARELESS";
  _driverman setSpeedMode "FULL";

  while {alive _driverman} do { 
    _driverman doMove (position veh_food); 
    sleep 5; 
  }; 
};

_driverman wasn't defined in the spawned code, this fixes it (untested tho)

  • Like 2

Share this post


Link to post
Share on other sites

Yep. If it breaks, the first suspect is scope.

  • Haha 1

Share this post


Link to post
Share on other sites

There's no need of spawn because of the execVM

  • Like 3

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

×