Jump to content
  • 0

Save vehicle on player disconnect


megaz

Question

10 answers to this question

Recommended Posts

  • 0
Just now, megaz said:

found it in onplayerdisconect.sqf

 

maybe something like this?

if ((vehicle player) isKindOf "AIR") then {
				if (driver (vehicle player) == player) then {
					_pos = ([((vehicle player) call fnc_getPos),10,1000,2,0,5,0] call BIS_fnc_findSafePos); //AH_fnc_getPos
					[(vehicle player),[_pos select 0,_pos select 1,2]] call fnc_setPos; //AH_fnc_setPos
					sleep 1;
					{if (_x != player) then {_x action ['Eject',(vehicle player)]}} forEach (crew (vehicle player));
					player action ['Eject',(vehicle player)];
				} else {
					waitUntil {(vehicle player == player)};
					sleep 1;
				};
			} else {
				sleep 1;
				{if (_x != player) then {_x action ['Eject',(vehicle player)]}} forEach (crew (vehicle player));
				player action ['Eject',(vehicle player)];
			};

 

Link to comment
Share on other sites

  • 0

This is what I had before but wont work now anyone know what to change:

this used to tp the vehicle to a certain area if player lost connection

thanks

MegaZ

 

// teleport flying players on dc
        if( (driver (vehicle _playerObj) == _playerObj) && (((getPosATL _playerObj) select 2) > 2) && ((vehicle _playerObj) iskindof "AIR") ) then {
            diag_log format["LOGOUT IN FLYING VEHICLE: %1 at location %2", _playerName,(getPosATL _playerObj)];
            _rnd_vec1 = (random 1);
            _rnd_vec2 = (random 1);
            (vehicle _playerObj) engineOn false;
            _playerObj action ["engineOff", vehicle _playerObj]; 
            (vehicle _playerObj) setVelocity [0,0,0];
            (vehicle _playerObj) setVectorUp [0,0,1];
            (vehicle _playerObj) setPos [4878 + (_rnd_vec1 * (-737)) + (_rnd_vec2 * 175),9637 + (_rnd_vec1 * 900) + (_rnd_vec2 * 95),0];
            
        };
        _playerObj action ["eject", vehicle _playerObj];
        _invehicle = true;
        diag_log format["LOGOUT IN VEHICLE: %1 at location %2", _playerName,(getPosATL _playerObj)];
    };

Link to comment
Share on other sites

  • 0

@megaz

hely_guard.sqf   (by donnovan)

Spoiler


private ["_message"];

//CHECK PILOT STATE AND IGNITE PROTECTION
if (hasInterface) then {
	while {true} do {
		while {vehicle player != player} do {
			_veh = vehicle player;
			if (_veh isKindOf "Air" && !(_veh isKindOf "ParachuteBase")) then {
				if (driver _veh == player) then {
					_vehProtected = _veh getVariable ["donn_protect",false];
					if (!_vehProtected) then {
						_veh setVariable ["donn_protect",true,true];
						donn_heli_monitor = _veh;
						publicVariableServer "donn_heli_monitor";
						
						//_message = format ["%1 (%2) lost connection %3 landed @%4", dayz_playerName, dayz_playerUID, _veh, mapGridPosition (getPosATL _veh)];
						//["heliddos",_message,true] call fnc_Log;
			
					};
					uiSleep 5;
				} else {
					uiSleep 5;
				};
			} else {
				uiSleep 5;
			};
			uiSleep 3;
		};
		uiSleep 5;
	};
};

//PROTECT THE HELI
if (isServer) then {
	"donn_heli_monitor" addPublicVariableEventHandler {
		_veh = _this select 1;
		_veh spawn {
			_veh = _this;
			_crew = crew _veh;_crewOk = [];
			waitUntil {uiSleep 1.5;_crewOk = _crew;_crew = crew _veh;count _crew == 0};
			_mans = nearestObjects [getPosATL _veh,["CAManBase"],100];
			_air = (getPosATL _veh) nearEntities ["Air",100];
			_DDOS = true;
			{if (_x in _mans) exitwith {_DDOS = false;};} forEach _crewOk;
			{_passenger = _x;{if (_passenger in crew _x) exitwith {_DDOS = false;};} forEach _air;} forEach _crewOk;
			if (_DDOS && ((getPosATL _veh) select 2) > 1.5) then {
				private ["_vPosNew"];
				_vPos = getPosATL _veh;_mapCenter = getMarkerPos "center";_vehSafeRadius = (sizeOf typeOf _veh)/2 + 4;
				for "_k" from 1 to 100 do {
					_vPosNew = [[_vPos select 0,_vPos select 1,0],(18+(_k-1)*2)*(_k-1),(18+_k*2)*_k,_vehSafeRadius,0,15,0,[],[_mapCenter,[0,0,0]]] call BIS_fnc_findSafePos;
					_x1 = round (_mapCenter select 0);_y1 = round (_mapCenter select 1);
					_x2 = round (_vPosNew select 0);_y2 = round (_vPosNew select 1);
					if !(_x1 == _x2 && _y1 == _y2) exitWith {};
				};
				_vPosNew = [_vPosNew select 0,_vPosNew select 1,0.5];
				_veh setPosATL _vPosNew;
				_veh setVectorUp surfaceNormal _vPosNew;
				_veh setVelocity [0,0,0];
				_fuel = fuel _veh;
				_veh setFuel 0;
				uiSleep 2.5;
				_veh setFuel _fuel;
				
				//_message = format ["%1 (%2) lost connection %3 landed @%4", dayz_playerName, dayz_playerUID, _veh, mapGridPosition (getPosATL _veh)];
			//["heliddos",_message,true] call fnc_Log;
			
			};
			_veh setVariable ["donn_protect",false,true];			
		};
	};
};

 

at bottom of init.sqf

//DDOS Heli Guard
	execVM "scripts\others\heli_guard.sqf";

original post:

Spoiler

 

 

Link to comment
Share on other sites

  • 0
On 6/26/2017 at 4:17 AM, juandayz said:

@megaz

hely_guard.sqf   (by donnovan)

  Reveal hidden contents



private ["_message"];

//CHECK PILOT STATE AND IGNITE PROTECTION
if (hasInterface) then {
	while {true} do {
		while {vehicle player != player} do {
			_veh = vehicle player;
			if (_veh isKindOf "Air" && !(_veh isKindOf "ParachuteBase")) then {
				if (driver _veh == player) then {
					_vehProtected = _veh getVariable ["donn_protect",false];
					if (!_vehProtected) then {
						_veh setVariable ["donn_protect",true,true];
						donn_heli_monitor = _veh;
						publicVariableServer "donn_heli_monitor";
						
						//_message = format ["%1 (%2) lost connection %3 landed @%4", dayz_playerName, dayz_playerUID, _veh, mapGridPosition (getPosATL _veh)];
						//["heliddos",_message,true] call fnc_Log;
			
					};
					uiSleep 5;
				} else {
					uiSleep 5;
				};
			} else {
				uiSleep 5;
			};
			uiSleep 3;
		};
		uiSleep 5;
	};
};

//PROTECT THE HELI
if (isServer) then {
	"donn_heli_monitor" addPublicVariableEventHandler {
		_veh = _this select 1;
		_veh spawn {
			_veh = _this;
			_crew = crew _veh;_crewOk = [];
			waitUntil {uiSleep 1.5;_crewOk = _crew;_crew = crew _veh;count _crew == 0};
			_mans = nearestObjects [getPosATL _veh,["CAManBase"],100];
			_air = (getPosATL _veh) nearEntities ["Air",100];
			_DDOS = true;
			{if (_x in _mans) exitwith {_DDOS = false;};} forEach _crewOk;
			{_passenger = _x;{if (_passenger in crew _x) exitwith {_DDOS = false;};} forEach _air;} forEach _crewOk;
			if (_DDOS && ((getPosATL _veh) select 2) > 1.5) then {
				private ["_vPosNew"];
				_vPos = getPosATL _veh;_mapCenter = getMarkerPos "center";_vehSafeRadius = (sizeOf typeOf _veh)/2 + 4;
				for "_k" from 1 to 100 do {
					_vPosNew = [[_vPos select 0,_vPos select 1,0],(18+(_k-1)*2)*(_k-1),(18+_k*2)*_k,_vehSafeRadius,0,15,0,[],[_mapCenter,[0,0,0]]] call BIS_fnc_findSafePos;
					_x1 = round (_mapCenter select 0);_y1 = round (_mapCenter select 1);
					_x2 = round (_vPosNew select 0);_y2 = round (_vPosNew select 1);
					if !(_x1 == _x2 && _y1 == _y2) exitWith {};
				};
				_vPosNew = [_vPosNew select 0,_vPosNew select 1,0.5];
				_veh setPosATL _vPosNew;
				_veh setVectorUp surfaceNormal _vPosNew;
				_veh setVelocity [0,0,0];
				_fuel = fuel _veh;
				_veh setFuel 0;
				uiSleep 2.5;
				_veh setFuel _fuel;
				
				//_message = format ["%1 (%2) lost connection %3 landed @%4", dayz_playerName, dayz_playerUID, _veh, mapGridPosition (getPosATL _veh)];
			//["heliddos",_message,true] call fnc_Log;
			
			};
			_veh setVariable ["donn_protect",false,true];			
		};
	};
};

 

at bottom of init.sqf


//DDOS Heli Guard
	execVM "scripts\others\heli_guard.sqf";

original post:

  Reveal hidden contents

 

 

Thanks  juanddayz,

Working fine: but is there a way to add a certain place on the map where it will tp the choppers too (say anywhere in an area of 1000 meters of a certain set of coordinates ?)

thanks again for your help

 

MegaZ

Link to comment
Share on other sites

  • 0
Just now, megaz said:

Thanks  juanddayz,

Working fine: but is there a way to add a certain place on the map where it will tp the choppers too (say anywhere in an area of 1000 meters of a certain set of coordinates ?)

thanks again for your help

 

MegaZ

well see  heres where the script take the pos to locate the heli

_vPosNew = [_vPosNew select 0,_vPosNew select 1,0.5];
				_veh setPosATL _vPosNew;

so i guess if u replace it by;

_customPosition = [300,120,0];//put your own coords.
_vPosNew = [_customPosition, 1, 1000, 10, 0, 20, 0] call BIS_fnc_findSafePos;
_veh setPosATL _vPosNew;

or if u wanna choose between unique pos or more than one then

_use_more_than_one_positions = false;//true uses random pos
if (!_use_more_than_one_positions) then {
_customPosition = [300,120,0];//put your own coords.
}else{
_customPosition = [
	[0,0,0],
	[0,0,0],
	[0,0,0],
	[0,0,0],
	[0,0,0],
	[0,0,0]
]call BIS_fnc_selectRandom;
};
_vPosNew = [_customPosition, 1, 1000, 10, 0, 20, 0] call BIS_fnc_findSafePos;
_veh setPosATL _vPosNew;

should or could be work :laugh:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...