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

I took this off my server in the end because it was wasted lines. Basically what was happening firstly is that this script does not stop the heli from crashing if you disconnect and you're the only person in the heli at the time. It does only however give you the option to switch seats mid flight with another player and it fails at everything else because when the player disconnects, the heli immediately starts to drop down, no matter how many times I told my players they can jump into the passenger seat and take over, they just panic and eject (it's the heli descending that does it, it even gets me at me times).. Every player has done this so far.. It's the part where the pilot just starts to drop, he really needs to hold position and hover in that spot.

Shame though because I really love this idea and your coding is pretty clean , I can read it a lot better than most.

Hope to see a future update with fixes to the landing instead of hovering issue and to maybe have it land safely somewhere in a field if you're the only person in the heli when you disconnect.


I will think about that. im already working on a new version. Will be availible within the next few weeks ;)
 
I know the effort it takes to get something like this working, so drop a note in the code for a paypal donation button and I'll donate a few dollars. Can't donate much as I'm broke, but I always give kudos where they're due :D
 
Hm... bei mir aufm Testserver geht das nicht :/
Hab in die Init.sqf das hier rein:
//-------------------------Sitzwechsel
[] execVM "fixes\seat_action.sqf";
//-----------------------------
Und im Ordner fixes sind sind die 2 dateien seat_action.sqf und switchseat.sqf.
In der Switchseat.sqf hab ich den teil mit AI Pilot reinkopiert.
Soweit alles richtig oder?
Hab sogar in der seat_action.sqf geschaut das ich kein falschen heli spawne.. aber bekomm kein Menü...
In der Infistarconfig habe ich auch 's_building_snapping' hinzugefügt...

Irgendwas vergessen?
 
Hast du auch die richtigen Classnames für die Helis benutzt? Also häufig nicht Fahrzeug_DZ sondern Fahrzeug_DZE?
 
Klar, hab doch geschrieben das ich extra nachgeschaut habe welche in der SQF eingetragen sind.. hab auch 2-3 wahllos ausm menü rausgesucht, ohne erfolg :/
Aber vergessen habe ich nix, oder?
Ansonsten werd ichs nochmal löschen und neu machen.
 
Sonst hört es sich ganz gut an. Wenn du es gar nicht hinbekommst, kannste mal ins TS³ kommen (IP: n8m4re.de)!
 
was gammel ich da rum, ohne dich zu sehen, von dir angeschrieben zu werden oder überhaupt zu wissen wer du da drauf sein sollst?

und wiso kicken die kinder mich einfach mal so? sag nun ned dass da alle 12 sind... bestellst dem Acer nen gruss
 
Ich heiß auf dem Teamspeak FrOoZeN und du wirst mich da abends fast immer antreffen. Ja es gibt ne Menge kleiner Kinder...
 
I've tried it on my server (Pwnoz0r's pack), seats are switched, but no AI pilot. Stupid question - do i need some AI framework to be installed on my server to have AI pilot in this script?
 
Finally got it working! It was simply necessary to change AI Pilot's skin to one of allowed in 1.8.0.3:eek: (Default script skin is banned)
But now facing next issues:
  1. When i go to other seat, AI carefuly lands helicopter.
  2. If player gives AI order to go somewhere after landing and after AI went player takes pilot's seat, then AI is not deleted.
 
Last edited:
So, during my head-breaking i made new version of this script :) It checks for pilot to be ok, and if there is no pilot it makes warning text for passengers, allowing them to take pilot's place by pressing F5.
Don't know if it's necessary to make new thread for it, so will post it here (For those who may need it)


bottom of init.sqf:
Code:
if (!isDedicated) then
        {
            [] execVM "Scripts\pilot_check.sqf";
        };

pilot_check.sqf:
Code:
waitUntil {!isNil "dayz_animalCheck"};
private ["_PILOT","_unit","_veh","_inveh","_inheli","_DEADORAI"];

drivermissing = false;

//here we assign hot key to change to pilot seat.

waituntil {!(IsNull (findDisplay 46))};
disableSerialization;
_display = findDisplay 46;
_display displayAddEventHandler ["KeyDown", "_this call F5Action"];

//this is hot-key action activator.
F5Action = {
    private ["_dikCode", "_handled"];
    _dikCode = _this select 1;
    _handled = false;
     if (_dikCode == 0x3F) then { //F5 has 0x3F hex code.
     if (drivermissing) then //only activate seat switching if there is no pilot
    {
    [] spawn gotopilot;
    };
    };
    _handled
};

////function to move player to pilot

gotopilot =
{
    _unit = player;
    _veh = vehicle _unit;
    _DEADORAI = driver _veh;
    _inheli = (typeOf _veh in ["Mi17_DZ","UH1H_DZ","UH1H_DZ2","AH6X_DZ","AN2_DZ","MH6J_DZ"]); //i have these classes of flying vehicles on my server.

    if ((_inheli) and (isNull driver _veh or !alive driver _veh or !isplayer driver _veh)) then
        {
    
        if (!isplayer driver _veh and alive driver _veh) then //think, this check can be safely removed, but not sure.
        {
        driver _veh setpos [0,0,0];
        deletevehicle _DEADORAI;
        } else {
        driver _veh setpos (getpos _veh);
        };
    _unit action ["movetodriver", _veh];
    sleep 1;
    if (((getPos _veh) select 2) > 3) then //no need to switch on auto hover, and engine below 3m.
    {
        _unit action ["AutoHover", _veh];
        _unit action ["engineOn", _veh];
    };

    cutText [format["You are pilot now!"], "PLAIN DOWN"];
    sleep 3;
    cutText ["", "PLAIN DOWN"];
    } else {
    cutText [format["There is pilot already on place!"], "PLAIN DOWN"];
        sleep 3;
        cutText ["", "PLAIN DOWN"];
    };
};





pilot_check =
{
while{true} do
    {
    //main pilot state check goes here
    _unit = player;
    _veh = vehicle _unit;
    _inveh = (_veh != player);
    _inheli = (typeOf _veh in ["Mi17_DZ","UH1H_DZ","UH1H_DZ2","AH6X_DZ","AN2_DZ","MH6J_DZ"]);


        if ((((getPos _veh) select 2) > 1) and (_inheli) and (isNull driver _veh or !alive driver _veh or !isplayer driver _veh)) then //no need to scream if on ground, or type of vehicle is not a plane/heli
        {
            drivermissing = true;
            cutText ["There is no pilot anymore!!! Press F5 To take over the helm!", "PLAIN"];
        }
        else
        {
            drivermissing = false;
        };

    sleep 0.5;

    };



};

[] spawn pilot_check;

Credits go to:
oOFabioOo for main idea and logic.
kaysio
- for idea how to make main check loop and hotkey handler (taken from J0k3r5 stats panel)
 
Last edited:
Not getting any option, to use were would the options show? Do you have to have the "," on the numpad to pull up the options, if so how would i adjust this setting as i do not have the key.
 
Giving this a try. No AI spawns as pilot (any fix for this yet?) but I do get the option to switch by pressing F5.
BTW, for users of infiSTAR, F5 is already mapped to Map Options. You'll need to switch the hex code for the key to press to switch seats. I changed mine to F6 which is 0x40. So, if you want to do this, in the pilot_check.sqf at line 18 look for

Code:
if (_dikCode == 0x3F) then { //F5 has 0x3F hex code.

and change it to

Code:
if (_dikCode == 0x40) then { //F6 has 0x40 hex code.

Also, and I'm not sure if this entirely matters, but at line 14 look for

Code:
F5Action = {

and change it to

Code:
F6Action = {

That is, if you want to change it to F6. If not, then go here for a list of DIK key codes. Make sure to use the Hex. code.
 
Last edited:
Back
Top