Jump to content
  • 0

[Help] Detect players in bike.


itsatrap

Question

Hello 

 

Hoping you can help we with my little error.

I was tried of all the bike's on my server, we use deploy bike and after a heavy PVP base fight there is always a butt load of bike laying around,

 

This is what I got now and it's almost works, the problem is that if a player is on his bike it gets deletede, but if he stands next to it, It will stay.

 

bike's a only meant to be deletede if no players is around 150m of them

 

its this line that finds all players, but it ignores players in vehicle's...

(isPlayer _x) && (alive _x) || (vehicle _x == _bike)

full script

private ["_pos","_delQtyBicycle","_qty","_allbicycle","_nearby","_bike"];
diag_log (format["CLEANUP: Finding unused bikes"]);
	_allBicycle = entities "Bicycle";
	_delQtyBicycle = 0;
	{
		if (_x getVariable "TempDeployed") then {
			_pos = getPosATL _x;
			_bike = _x;
				if ((count _pos > 0)) then {
					_nearby = {
						(isPlayer _x) && (alive _x) || (vehicle _x == _bike)
					} count (_pos nearEntities [["CAManBase"], 150]);
					
					if (_nearby==0) then {
						_x call dayz_perform_purge;
						sleep 0.05;
						_delQtyBicycle = _delQtyBicycle + 1;
					};
				};
			};
		sleep 0.001;
	} count _allbicycle;
	
	if (_delQtyBicycle > 0) then {
		_qty = count _allbicycle;
		diag_log (format["CLEANUP: Deleted %1 Bicycles out of %2",_delQtyBicycle,_qty]);
	};
diag_log (format["CLEANUP: Finding unused bikes Done"]);

Help me, Obi-Wan Kenobi. You're my only hope

 

 

 

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0
private ["_pos","_delQtyBicycle","_qty","_allbicycle","_nearby","_bike"];
diag_log (format["CLEANUP: Finding unused bikes"]);
	_allBicycle = entities "Bicycle";
	_delQtyBicycle = 0;
	{
		if (_x getVariable "TempDeployed") then {
			_pos = getPosATL _x;
			_bike = _x;
				if ((count _pos > 0)) then {
					_nearby = {
						(isPlayer _x) && (alive _x)
					} count (_pos nearEntities [["CAManBase"], 250]);
					
					if ((_nearby==0) && ({alive _x} count crew _bike == 0)) then {
						_x call dayz_perform_purge;
						sleep 0.05;
						_delQtyBicycle = _delQtyBicycle + 1;
					};
				};
			};
		sleep 0.001;
	} count _allbicycle;
	
	if (_delQtyBicycle > 0) then {
		_qty = count _allbicycle;
		diag_log (format["CLEANUP: Deleted %1 Bicycles out of %2",_delQtyBicycle,_qty]);
	};
diag_log (format["CLEANUP: Finding unused bikes Done"]);

Working code :)

 

Fixed it with 

{alive _x} count crew _bike == 0

I run it from

server_cleanup.fsm

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...