Home   Help Search Login Register  

Author Topic: Assign a new driver if the regular one dies?  (Read 1201 times)

0 Members and 1 Guest are viewing this topic.

Offline matteg91

  • Members
  • *
Assign a new driver if the regular one dies?
« on: 06 Nov 2007, 15:12:12 »
Hi, Ive tried searching the forums for this and found some stuff but I cant for my life make it work...

What I want to do is as follows: I have a 4 man group and 1 empty car. The leader is assigned as driver and the 3 other as cargo. When i order them to move they all get in the car and move...so far so good. But if the driver dies i need someone to replace him. As it is now, if the driver bites the dust, the 3 other moroons just pile in the car but noone gets behind the stearingwheel so they just sit there, heh he.

Ive tried to make a trigger that fires if the leader (the driver) is killed and then assigns the driverrole to the new leader of the group but I cant make it work. A little help would be greatly appriciated and please treat me like a complete idiot, im pretty new to scripting so try to explain it like you would to a 3 year old :)

/Matte

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Assign a new driver if the regular one dies?
« Reply #1 on: 06 Nov 2007, 18:16:11 »
You may use a script to check and control this, lets say the leader should be always the driver:
Code: [Select]
// keepinvehicle.sqf
// Exec this way:
// res = [group, vehicle] execVM "keepinvehicle.sqf"
_grp = _this select 0;
_car = _this select 1;
while {true} do
{
   _lead = leader group _grp;
   _lead assignAsDriver _car;
   {
      if (_x != _lead) then
      {
         _x assignAsCargo _car;
      };
   } forEach units _grp;
   waitUntil {(!alive _lead) || !(canMove _car)};
   _grp leaveVehicle _car;
   waitUntil {count crew _car == 0};
   if ((!canMove _car) || ({alive _x} count units _grp == 0)) exitWith {};
   Sleep 1;
};

Offline matteg91

  • Members
  • *
Re: Assign a new driver if the regular one dies?
« Reply #2 on: 06 Nov 2007, 20:24:18 »
Many thanks for your help! I still can't get it to work but there is some progress, though. Instead of just sitting in the backseat like a bunch of idiots they take off on foot if the leader dies :)

Maybe I should have added in my first post that the mission is built on top of CoC and maybe thats what causes it to act crazy?

/Matte