[Script] Helicoper Disconnect Protection/Switch Seat [v1.2

oOFabioOo

New Member
Hello guys!
I want to share my new script with you.

What it does:
- You can switch from Gunner/Backseat to pilot's seat --> If you pilot looses connection, simply switch to pilot's seat!
- Pilot can switch to Back-/Gunnerseat and a AI Pilot will take place as pilot, so you can shoot people from the gunner, even when you are alone. The AI Pilot is controllable with the "," on the NumPad.

Instructions:

1. Add in your init.sqf at the VERY bottom the following code!
Code:
[] execVM "Scripts\seat_action.sqf";

2. Create a folder called "Scripts" and create two files called "seat_action.sqf" and "switchseat.sqf"!

3. Paste in your seat_action.sqf the following code and edit the lines like shown...

Code:
sleep 10;
{
If (typeOf _x in ["CH_47F_EP1_DZ","Mi17_DZ","UH60M_EP1_DZ","UH60M_EP1","MH60S","UH1H_DZ","UH1Y_DZ"]) then //Helis with 10+ seats armed
{
nul = _x addAction ["To Pilot's Seat","fixes\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Gunner's Seat","fixes\switchseat.sqf",["gunner"],5,false,true,"","driver _target == player"];
nul = _x addAction ["To Backseat","fixes\switchseat.sqf",["back"],5,false,true,"","driver _target == player"];
};

If (typeOf _x in ["Ka60_PMC","Mi17_Civilian_DZ","UH60M_MEV_EP1"]) then //Helis with 10+ seats unarmed
{
nul = _x addAction ["To Pilot's Seat","fixes\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Backseat","fixes\switchseat.sqf",["back"],5,false,true,"","driver _target == player"];
};

If (typeOf _x in ["AH6X_DZ","AH6X_EP1","AH6J_EP1","AH6J","GNT_C185","GNT_C185C","GNT_C185F","GNT_C185R","GNT_C185U"]) then //Helis with 2 seats unarmed
{
nul = _x addAction ["To Pilot's Seat","fixes\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Backseat","fixes\switchseat.sqf",["backlittle"],5,false,true,"","driver _target == player"];
};

If (typeOf _x in ["Ka137_MG_PMC"]) then //Helis with 2 seats armed
{
nul = _x addAction ["To Pilot's Seat","fixes\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Gunner's Seat","fixes\switchseat.sqf",["gunner"],5,false,true,"","driver _target == player"];
};

If (typeOf _x in ["MH6J_DZ","MH6J_EP1","MH6J"]) then //Helis with <7 seats
{
nul = _x addAction ["To Pilot's Seat","fixes\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Backseat","fixes\switchseat.sqf",["backmedium"],5,false,true,"","driver _target == player"];
};
} forEach (vehicles);

4. Add this stuff to your switchseat.sqf!

If you want a AI Pilot:
Code:
private ["_PILOT"];

_unit = player;
_veh = vehicle _unit;
_actionArray = _this select 3;
_action = _actionArray select 0;
enableRadio false;
showSubtitles false;

if (_action == "pilot") then
{
if (isNull driver _veh or !alive driver _veh or !isplayer driver _veh) then
    {
_DEADORAI = driver _veh;
if (!isplayer driver _veh and alive driver _veh) then
{
driver _veh setpos [0,0,0];
deletevehicle _DEADORAI;
} else {
driver _veh setpos (getpos _veh);
};
    sleep 0.5;
    _unit action ["movetodriver", _veh];
    sleep 1;
    _unit action ["AutoHover", _veh];
    _unit action ["engineOn", _veh];
    sleep 0.5;
    hint format ["You are now pilot!"];
    } else {
    sleep 0.5;
    hint format ["There is already a pilot inside!"];
    }
};

if (_action == "gunner") then
{
if (((getPos _veh) select 2) > 10) then
{
if (isNull gunner _veh or !alive gunner _veh) then
    {
    _PILOT = group player createUnit ["US_Pilot_Light_EP1", Position player, [], 0, "CAN_COLLIDE"];
    _PILOT setVehicleVarName "_PILOT";
    _PILOT setUnitAbility 0.60000002;
    _PILOT removeweapon "itemmap";
    _PILOT removeweapon "itemradio";
    _PILOT removeweapon "itemwatch";
    _PILOT removeweapon "itemcompass";
    _unit action ["movetogunner", _veh];
    sleep 0.1;
    _PILOT action ["getindriver", _veh];
    hint format ["You are now gunner!"];
    } else {
    sleep 0.5;
    hint format ["There is already a gunner inside!"];
    }
} else {
hint format ["You are flying too low!"];
}
};

if (_action == "back") then
{
if (((getPos _veh) select 2) > 10) then
{
    _PILOT = group player createUnit ["US_Pilot_Light_EP1", Position player, [], 0, "CAN_COLLIDE"];
    _PILOT setVehicleVarName "_PILOT";
    _PILOT setUnitAbility 0.60000002;
    _PILOT removeweapon "itemmap";
    _PILOT removeweapon "itemradio";
    _PILOT removeweapon "itemwatch";
    _PILOT removeweapon "itemcompass";
    _unit action ["movetocargo", _veh, 7];
    sleep 0.1;
    _PILOT action ["getindriver", _veh];
    hint format ["You are now in the back!"];
} else {
hint format ["You are flying too low!"];
}
};

if (_action == "backlittle") then
{
if (((getPos _veh) select 2) > 10) then
{
    _PILOT = group player createUnit ["US_Pilot_Light_EP1", Position player, [], 0, "CAN_COLLIDE"];
    _PILOT setVehicleVarName "_PILOT";
    _PILOT setUnitAbility 0.60000002;
    _PILOT removeweapon "itemmap";
    _PILOT removeweapon "itemradio";
    _PILOT removeweapon "itemwatch";
    _PILOT removeweapon "itemcompass";
    _unit action ["movetocargo", _veh, 0];
    sleep 0.1;
    _PILOT action ["getindriver", _veh];
    hint format ["You are now in the back!"];
} else {
hint format ["You are flying too low!"];
}
};

if (_action == "backmedium") then
{
if (((getPos _veh) select 2) > 10) then
{
    _PILOT = group player createUnit ["US_Pilot_Light_EP1", Position player, [], 0, "CAN_COLLIDE"];
    _PILOT setVehicleVarName "_PILOT";
    _PILOT setUnitAbility 0.60000002;
    _PILOT removeweapon "itemmap";
    _PILOT removeweapon "itemradio";
    _PILOT removeweapon "itemwatch";
    _PILOT removeweapon "itemcompass";
    _unit action ["movetocargo", _veh, 4];
    sleep 0.1;
    _PILOT action ["getindriver", _veh];
    hint format ["You are now in the back!"];
} else {
hint format ["You are flying too low!"];
}
};

If you don't want a AI Pilot:
Code:
private ["_PILOT"];

_unit = player;
_veh = vehicle _unit;
_actionArray = _this select 3;
_action = _actionArray select 0;
enableRadio false;
showSubtitles false;

if (_action == "pilot") then
{
if (((getPos _veh) select 2) > 10) then
{
if (isNull driver _veh or !alive driver _veh or !isplayer driver _veh) then
    {
    _DEADORAI = driver _veh;
    if (!isplayer driver _veh and alive driver _veh) then
        {
        driver _veh setpos [0,0,0];
        deletevehicle _DEADORAI;
        } else {
        driver _veh setpos (getpos _veh);
        };
    sleep 0.5;
    _unit action ["movetodriver", _veh];
    sleep 1;
    _unit action ["AutoHover", _veh];
    _unit action ["engineOn", _veh];
    sleep 0.5;
    hint format ["You are now pilot!"];
    } else {
    hint format ["There is already a pilot inside!"];
    }
} else {
hint format ["The altitude is too low!"];
}
};

if (_action == "gunner") then
{
if (((getPos _veh) select 2) > 10) then
{
if (isNull gunner _veh or !alive gunner _veh) then
    {
    _unit action ["movetogunner", _veh];
    hint format ["You are now gunner!"];
    } else {
    sleep 0.1;
    hint format ["There is already a gunner inside!"];
    }
} else {
hint format ["You are flying too low!"];
}
};

if (_action == "back") then
{
if (((getPos _veh) select 2) > 10) then
{
    _unit action ["movetocargo", _veh, 7];
    hint format ["You are now in the back!"];
} else {
hint format ["You are flying too low!"];
}
};

if (_action == "backlittle") then
{
if (((getPos _veh) select 2) > 10) then
{
    _unit action ["movetocargo", _veh, 0];
    hint format ["You are now in the back!"];
} else {
hint format ["You are flying too low!"];
}
};

if (_action == "backmedium") then
{
if (((getPos _veh) select 2) > 10) then
{
    _unit action ["movetocargo", _veh, 4];
    hint format ["You are now in the back!"];
} else {
hint format ["You are flying too low!"];
}
};




DONE!

Thanks for testing it out and have a nice day ;)


 
Last edited:
I'm on 1.7.7.1 and while this lets me switch to the gunner seat the heli nose dives as soon as I do, have to switch back to pilot and recover.

Scripts I have installed: SARGE AI, self bloodbag, autorefuel, strip vehicle parts, a couple safezones, and custom buildings via sqf.
 
I changed the priority of the menu items as it was putting them above auto-hover, which lead to some deaths!

Code:
sleep 10;
{
If (typeOf _x in ["CH_47F_EP1_DZ","Mi17_DZ","UH60M_EP1_DZ","UH60M_EP1","MH60S","UH1H_DZ","UH1Y_DZ"]) then //Helis with 10+ seats armed
{
nul = _x addAction ["To Pilot's Seat","Scripts\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Gunner's Seat","Scripts\switchseat.sqf",["gunner"],5,false,true,"","driver _target == player"];
nul = _x addAction ["To Backseat","Scripts\switchseat.sqf",["back"],5,false,true,"","driver _target == player"];
};
 
If (typeOf _x in ["Ka60_PMC","Mi17_Civilian_DZ","UH60M_MEV_EP1"]) then //Helis with 10+ seats unarmed
{
nul = _x addAction ["To Pilot's Seat","Scripts\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Backseat","Scripts\switchseat.sqf",["back"],5,false,true,"","driver _target == player"];
};
 
If (typeOf _x in ["AH6X_DZ","AH6X_EP1","AH6J_EP1","AH6J","GNT_C185","GNT_C185C","GNT_C185F","GNT_C185R","GNT_C185U"]) then //Helis with 2 seats unarmed
{
nul = _x addAction ["To Pilot's Seat","Scripts\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Backseat","Scripts\switchseat.sqf",["backlittle"],5,false,true,"","driver _target == player"];
};
 
If (typeOf _x in ["Ka137_MG_PMC"]) then //Helis with 2 seats armed
{
nul = _x addAction ["To Pilot's Seat","Scripts\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Backseat","Scripts\switchseat.sqf",["backlittle"],5,false,true,"","driver _target == player"];
};
 
If (typeOf _x in ["MH6J_DZ","MH6J_EP1","MH6J"]) then //Helis with <7 seats
{
nul = _x addAction ["To Pilot's Seat","Scripts\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Backseat","Scripts\switchseat.sqf",["backmedium"],5,false,true,"","driver _target == player"];
};
} forEach (vehicles);
 
Any fix for the AI pilot not being added?

BTW, AWESOME script. Since they took out the attack helis this is the next best thing to being able to fly and shoot
 
Thank you guys for testing that out ;)

I'm on 1.7.7.1 and while this lets me switch to the gunner seat the heli nose dives as soon as I do, have to switch back to pilot and recover.

Scripts I have installed: SARGE AI, self bloodbag, autorefuel, strip vehicle parts, a couple safezones, and custom buildings via sqf.

Well I've running the script since a week and its working fine at Epoch (with Anim. Helicrash, Auto-Refuel, and other stuff) without problems. I will test this out with a few other mods when i've got time... There are a few "sleep" in the script. Please go to a high level and then try to switch the seat...

how would you go about removing him from the group once your back in the pilot seat

I'm working on this ;) If anyone has ideas how to do that, a tip would be nice!
 
how would you go about removing him from the group once your back in the pilot seat


I'm working on this ;) If anyone has ideas how to do that, a tip would be nice!

Okay found something. I'm testing it out atm and seems to work fine
 
is this possible to have this script but so the AI will not spawn
as i think if you have a heli full of people its good you can save it if pilot dies or dc but do not like the idea of been able to fly shot fly
 
is this possible to have this script but so the AI will not spawn
as i think if you have a heli full of people its good you can save it if pilot dies or dc but do not like the idea of been able to fly shot fly


Just change the code in the seat_actions.sqf to:
Code:
sleep 10;
{
If (typeOf _x in ["CH_47F_EP1_DZ","Mi17_DZ","UH60M_EP1_DZ","UH60M_EP1","MH60S","UH1H_DZ","UH1Y_DZ"]) then //Every heli for which the script will run
{
nul = _x addAction ["To Pilot's Seat","Scripts\switchseat.sqf",["pilot"],10,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
};
} forEach (vehicles);
 
Very nice script there Fabio, I have really missed this function and its been annoying me for to long, thank you!

Although I just like Timmy didnt like the AI pilot idea very much, i solved it by removing every "_PILOT" from the switchseat.sqf this way you can still change to gunner/back from the pilot seat but no AI will spawn.
 
Hello guys!

Instructions:

1. Add in your init.sqf at the VERY bottom the following code!
Code:
[] execVM "Scripts\seat_action.sqf";

2. Create a folder called "Scripts" and create two files called "seat_action.sqf" and "switchseat.sqf"!

3. Paste in your seat_action.sqf the following code and edit the lines like shown...


If you want a AI Pilot:
Code:
sleep 10;
{
If (typeOf _x in ["CH_47F_EP1_DZ","Mi17_DZ","UH60M_EP1_DZ","UH60M_EP1","MH60S","UH1H_DZ","UH1Y_DZ"]) then //Helis with 10+ seats armed
{
nul = _x addAction ["To Pilot's Seat","fixes\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Gunner's Seat","fixes\switchseat.sqf",["gunner"],5,false,true,"","driver _target == player"];
nul = _x addAction ["To Backseat","fixes\switchseat.sqf",["back"],5,false,true,"","driver _target == player"];
};
 
If (typeOf _x in ["Ka60_PMC","Mi17_Civilian_DZ","UH60M_MEV_EP1"]) then //Helis with 10+ seats unarmed
{
nul = _x addAction ["To Pilot's Seat","fixes\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Backseat","fixes\switchseat.sqf",["back"],5,false,true,"","driver _target == player"];
};
 
If (typeOf _x in ["AH6X_DZ","AH6X_EP1","AH6J_EP1","AH6J","GNT_C185","GNT_C185C","GNT_C185F","GNT_C185R","GNT_C185U"]) then //Helis with 2 seats unarmed
{
nul = _x addAction ["To Pilot's Seat","fixes\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Backseat","fixes\switchseat.sqf",["backlittle"],5,false,true,"","driver _target == player"];
};
 
If (typeOf _x in ["Ka137_MG_PMC"]) then //Helis with 2 seats armed
{
nul = _x addAction ["To Pilot's Seat","fixes\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Gunner's Seat","fixes\switchseat.sqf",["gunner"],5,false,true,"","driver _target == player"];
};
 
If (typeOf _x in ["MH6J_DZ","MH6J_EP1","MH6J"]) then //Helis with <7 seats
{
nul = _x addAction ["To Pilot's Seat","fixes\switchseat.sqf",["pilot"],5,false,true,"","player in (assignedVehicle _target) and driver _target != player"];
nul = _x addAction ["To Backseat","fixes\switchseat.sqf",["backmedium"],5,false,true,"","driver _target == player"];
};
} forEach (vehicles);

I know its easily changed but is there a reason your script points to fixes\switchseat.sqf while we'll your instructions point to scripts\switchseat.sqf. Its just for other people installing this. Currently not working for me on Chernarus 1.7.7.1. But will reinstall and try again.
 
Got it working :p Removed the _pilot stuff from the code and works great :p Now I can switch seats and go for a smoke break hehe
 
I know its easily changed but is there a reason your script points to fixes\switchseat.sqf while we'll your instructions point to scripts\switchseat.sqf. Its just for other people installing this. Currently not working for me on Chernarus 1.7.7.1. But will reinstall and try again.

My mistake, was adjusted for my setup, and forgot to change it back!
 
Hopefully the AI pilot part is what's causing issues with chernarus 1.7.7.1. I'll switch it around and see if it works later today. Thanks for the update!
 
this is cool how could i take the to low bit out so you can change seats on the ground and could you make it so you could change from back seat to gunner? and other way
 
this is cool how could i take the to low bit out so you can change seats on the ground and could you make it so you could change from back seat to gunner? and other way

1. Remove all lines similar to this
Code:
if (((getPos _veh) select 2) > 10) then
{
and this line
Code:
} else {
hint format ["You are flying too low!"];
}
from your switchseat.sqf

But I can tell you that this will cause weird running AI Pilots on the Ground (If you don't disable them)...

Maybe later on, but atm I'm working on a different Script...
 
Back
Top