EGG_EVO_Eject = 
{
	PRIVATE ["_unit", "_vec"];
	_unit = _this select 0;
	_vec = _this select 1;
	_unit action ["ENGINEOFF", _vec];
	if (_vec iskindof "helicopter") then 
	{
		_unit action ["GetOut",_vec];
	} else
	{
		_unit action ["Eject",_vec];
	};
	_vec setVelocity [0, 0, 0];
	sleep 1;
	if(_unit == player) then 
	{
		disableUserInput false;
	};
};

EGG_EVO_VecInit = 
{ 
	PRIVATE ["_unit", "_vec","_Vehicle","_pilotchecktype","_rank0","_rank1","_rank2","_rank3","_rank4","_rank5","_rank6","_dunit"];

	_unit = _this select 0;
	_vec = _this select 1;
	_Vehicle = typeOf _vec;
	_pilotchecktype = typeOf _unit;
	_rank0 = EGG_EVO_rank0;
	_rank1 = EGG_EVO_rank1;
	_rank2 = EGG_EVO_rank2;
	_rank3 = EGG_EVO_rank3;
	_rank4 = EGG_EVO_rank4;
	_rank5 = EGG_EVO_rank5;
	_rank6 = EGG_EVO_rank6;
	_dunit = _unit;
	//_warning = 0;

	if (not (local _unit)) exitwith {};
//	if(_unit == player) then {disableUserInput true};

	if (getdammage _vec == 0) then
	{
		_vec setDamage 0.01;
	};
	
	if (not (isPlayer _unit)) then
	{
		_dunit = (leader _unit);
	};
	
	if (!isNil "wcam") then 
	{
		_vec removeaction wcam;
	};

	//unlocks everything for pilots
	_pilotcheck = 0;
	if (_pilotchecktype in EGG_EVO_playerPilot) then
	{
		if (EGG_EVO_allowpilots == 1) then 
		{
			_pilotcheck = 1;
		};
		if ( (EGG_EVO_allowpilots == 2) AND (score _dunit >= 150) ) then 
		{
			_pilotcheck = 1;
		};
	};

/*
//in init
EGG_EVO_vrank0 = ["B_MRAP_01_F","B_Truck_01_medical_F","C_Offroad_01_F","B_Quadbike_01_F","B_Lifeboat"];
EGG_EVO_vrank1 = ["B_MRAP_01_hmg_F","O_MRAP_02_F","B_Heli_Light_01_F","B_Mortar_01_F","B_Boat_Armed_01_minigun_F"];
EGG_EVO_vrank2 = ["O_MRAP_02_hmg_F","O_Heli_Light_02_F","O_Boat_Armed_01_hmg_F"];
EGG_EVO_vrank3 = ["B_Boat_Transport_01_F"];
EGG_EVO_vrank4 = ["B_MRAP_01_gmg_F","O_assaultboat"];
EGG_EVO_vrank5 = ["O_MRAP_02_gmg_F"];
EGG_EVO_vrank6 = ["B_Heli_Light_01_armed_F"];
*/

	if(_vec isKindOf "Air") then
	{
		if (_Vehicle in EGG_EVO_vrank0) then
		{
			if (score _dunit < _rank0 && ranklock < 2 && _pilotcheck !=1) then {[_dunit,_rank0] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};
		if (_Vehicle in EGG_EVO_vrank1) then
		{
			if (score _dunit < _rank1 && ranklock < 2 && _pilotcheck !=1) then {[_dunit,_rank1] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};
		if (_Vehicle in EGG_EVO_vrank2) then
		{
			if (score _dunit < _rank2 && ranklock < 2 && _pilotcheck !=1) then {[_dunit,_rank2] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};
		if (_Vehicle in EGG_EVO_vrank3) then
		{
			if (score _dunit < _rank3 && ranklock < 2 && _pilotcheck !=1) then {[_dunit,_rank3] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};
		if (_Vehicle in EGG_EVO_vrank4) then
		{
			if (score _dunit < _rank4 && ranklock < 2 && _pilotcheck !=1) then {[_dunit,_rank4] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};
		if (_Vehicle in EGG_EVO_vrank5) then
		{
			if (score _dunit < _rank5 && ranklock < 2 && _pilotcheck !=1) then {[_dunit,_rank5] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};
		if (_Vehicle in EGG_EVO_vrank6) then
		{
			if (score _dunit < _rank6 && ranklock < 2 && _pilotcheck !=1) then {[_dunit,_rank6] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};

		//weapon camera
		if(_unit == player) then {wcam = _vec addaction [("<t color='#4169e1'>" + "#Weapon Camera On" + "</t>"), "actions\wepcam.sqf",0,1, false, true,"test2"]};
		setViewDistance EGG_EVO_avdist;

	} else {

		if (_Vehicle in EGG_EVO_vrank0) then
		{
			if (score _dunit < _rank0 && ranklock < 2) then {[_dunit,_rank0] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};
		if (_Vehicle in EGG_EVO_vrank1) then
		{
			if (score _dunit < _rank1 && ranklock < 2) then {[_dunit,_rank1] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};
		if (_Vehicle in EGG_EVO_vrank2) then
		{
			if (score _dunit < _rank2 && ranklock < 2) then {[_dunit,_rank2] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};
		if (_Vehicle in EGG_EVO_vrank3) then
		{
			if (score _dunit < _rank3 && ranklock < 2) then {[_dunit,_rank3] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};
		if (_Vehicle in EGG_EVO_vrank4) then
		{
			if (score _dunit < _rank4 && ranklock < 2) then {[_dunit,_rank4] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};
		if (_Vehicle in EGG_EVO_vrank5) then
		{
			if (score _dunit < _rank5 && ranklock < 2) then {[_dunit,_rank5] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};
		if (_Vehicle in EGG_EVO_vrank6) then
		{
			if (score _dunit < _rank6 && ranklock < 2) then {[_dunit,_rank6] call EGG_EVO_RankReq;[_unit, _vec] call EGG_EVO_Eject};
		};
	};

	if (_Vehicle in EGG_EVO_repairtruck) then
	{
		if (_pilotchecktype in EGG_EVO_playerEng) then
		{    
			if(not (isNull EGG_EVO_ltrk)) then
			{
				EGG_EVO_ltrk removeaction EGG_EVO_elock;
				EGG_EVO_ltrk lock false;
			};
			EGG_EVO_elock = _vec addaction [("<t color='#4169e1'>" + "#" + localize "STR_M04t54" + "</t>"), "actions\englock.sqf",0,1, false, true,"test2"];EGG_EVO_ltrk = _vec
		};
	};
	if(_unit == player) then {disableUserInput false};
	Waituntil {player != driver _vec};
	//_vec removeaction wcam;
	//_vec removealleventhandlers "Fired";
	setViewDistance EGG_EVO_vdist;
	if(_unit != player) exitWith {};
};