Comrades in Arms Discussion Board

Full Version: Only allowing a specific unit in a specific vehicle as driver or pilot
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
My second question...


I want to be able to say something like "Player named bob can drive vehicle named car1" not allowing anyone else to drive the vehicle... only bob.


Its basically a way to only allow pilots to fly.. but its a bit more in depth than that, and being able to specify which units are allowed to drive/fly which vehicles would fit perfectly


Im looking up  possible ways... but if anyone here knows of a nice way to do this, that would be great


Thanks again
I used this in Bloodlines to prevent all non-Pilots to steer the Little Birds:

Code:
{
    _x addEventHandler ["GetIn",
    {
        _vehicle = _this select 0;
        _position = _this select 1;
        _unit = _this select 2;
        if (_position == "driver") then {
            if (_unit != p13 && _unit != p14 && _unit != p15) then {
                doGetOut _unit;
                hint "You are not qualified to fly this rotary aircraft";
            };
        };
    }];

} forEach [mh1, mh2, mh3];
]

units p13, p14 and p15 are the pilots, mh1, mh2 and mh3 are the MH-9's.
perfect thanks : )

ok... getting a little confused here... the script above works however copilot can still get in and control the aircraft.


I have tweaked the code to check for turretUnit and even tried just checking position is "gunner"

I have however, discovered that if you try to enter as a gunner or co pilot, we are getting inside the if statement and it hints that you are not qualified, however it doesnt kick you out the vehicle

Thought maybe because you need to unassign the role of gunner or something... but nothing seems to work.

Any ideas? my adjusted code is below (will tidy it up once i get it working)


just seems that doGetOut doesn't work for gunners or co pilot?

Code:
{
    _x addEventHandler ["GetIn",
    {
        _vehicle = _this select 0;
        _position = _this select 1;
        _unit = _this select 2;
       
        _sUnitInCopilot = format["%1",_vehicle turretUnit [0]];
        _sUnitName = format["%1",_unit];
     
     hint parseText format["test: <br/>%1<br/> and: <br/>%2<br/> and: %3", _sUnitInCopilot, _sUnitName, _position];
             
        //if (_position == "driver" || _sUnitInCopilot == _sUnitName) then {
     if (_position == "driver" or _position == "gunner") then {   
     hint "asdfads";
            if (_unit != eng1 && _unit != eng2 && _unit != eng3 && _unit != eng4) then {
             //unassignVehicle _unit; 
                doGetOut _unit;
                //_unit leaveVehicle _vehicle;
                hint "You are not qualified to operate this vehicle";
                hint format["ccc %1",_position];
            };
        };
    }];


} forEach [tank1, tank2, chopper1, chopper2];

];
Hold fire : )  found a way around this... see below:

used
Code:
_unit action ["getOut", _vehicle];
instead

Code:
{
    _x addEventHandler ["GetIn",
    {
        _vehicle = _this select 0;
        _position = _this select 1;
        _unit = _this select 2;
       
        _sUnitInCopilot = format["%1",_vehicle turretUnit [0]];
        _sUnitName = format["%1",_unit];
     
     //this would be ideal... but doesnt seem to pick up if unit is in this position   
     //if (_position == "driver" || _unit in _vehicle turretUnit [0]) then {   
     
     //Use this if you dont want to allow copilot or gunner
     //if (_position == "driver" || _position == "gunner") then {   
     
     //this works for just pilot or copilot
        if (_position == "driver" || _sUnitInCopilot == _sUnitName) then {
     
           if (_sUnitName != "eng1" && _sUnitName != "eng2" && _sUnitName != "eng3" && _sUnitName != "eng4") then {

                _unit action ["getOut", _vehicle];
                hint "You are not qualified to operate this vehicle";
            };
        };
    }];

} forEach [tank1, tank2, chopper1, chopper2];

];