Jump to content

Remove Vehicle


shurix

Recommended Posts

I found myself jumping around the map and cleaning-up abandoned vehicles with broken wheels/engine.

 

I decided to write a script that adds a "Remove Vehicle" action to every vehicle on the map.

 

Player needs to have a Jack for the script to work. Player comes to a vehicle (open or locked). Scroll mouse wheel to see Remove Vehicle action. Script gives 5 seconds for the player to change his mind. Vehicle is removed and change is pushed to the database. Depending on the amount of damage the script drops Vehicle Repair or Salvage Metal items instead of the vehicle. For larger vehicles like a helicopter or a support truck it also produces a Vehicle Repair Kit.

 

Add this line into mpmissions\epoch.Altis\init.sqf

//vehicle actions
[] execVM "custom\vehicle_actions.sqf";

Here's the contents of custom\vehicle_actions.sqf

systemChat(format["Vehicle Actions are loading. Please wait..."]);
{
		_x addAction ["<t color=""#ff0000"">Remove vehicle</t>","custom\remove_vehicle.sqf",[_x],0,false,true,"",""];
} forEach (vehicles);

systemChat(format["Finished loading Vehicle Actions"]);

Here's the actual file that removes the vehicle.

custom\remove_vehicle.sqf

private ["_vehSlot","_hasToolbox","_mags","_percent","_vehiclePosition","_remainingDamage","_damage","_part05","_part02","_part01","_vehicle","_hitpoints","_vehSlot","_vehHiveKey","_VAL","_box"];

_vehicle = _this select 0;
_vehicle_type = (typeOf _vehicle);
_isTruck = _vehicle isKindOf "Support";
_isHeli = _vehicle isKindOf "Helicopter";

_partTruckHeli = "VehicleRepairLg";
_part05 = "VehicleRepair";
_part02 = "ItemCorrugatedLg";
_part01 = "ItemCorrugated";

_hasToolbox = false;
_mags = magazines player;
_hasToolbox = "JackKit" in _mags;

_hitpoints = _vehicle call EPOCH_getHitpoints;
_damage = damage _vehicle;
_remainingDamage = 1 - _damage;
_vehiclePosition = getPos _vehicle;

//hint format["_damage=%1 \n _remainingDamage=%2 \n _hasToolbox=%3",_damage,_remainingDamage,_hasToolbox];
	
if (_hasToolbox) then {

	_cnt = 5;
	_locationPlayer = (getPosATL player);
	for "_p" from 1 to 5 do
	{
		systemChat(format ["WARNING! Removing vehicle in %1s - Move to cancel",_cnt]);
		if (player distance _locationPlayer > 0.2) then {
			systemChat("Removing vehicle canceled");
			breakOut "exit";
		};
		sleep 1;
		_cnt = _cnt - 1;
	};
	
	player playActionNow "Medic";
	
	//systemChat(format["b4 deleting _vehicle=%1",_vehicle]);
	
	_vehSlot=_vehicle getVariable["VEHICLE_SLOT","ABORT"];
	if(_vehSlot !="ABORT") then {
		removeFromRemainsCollector[_vehicle];
		deleteVehicle _vehicle;
		_vehHiveKey=format["%1:%2",(call EPOCH_fn_InstanceID),_vehSlot];
		_VAL=[];
		["Vehicle",_vehHiveKey,_VAL]call EPOCH_server_hiveSET;
		EPOCH_VehicleSlots pushBack _vehSlot;
		EPOCH_VehicleSlotCount=count EPOCH_VehicleSlots;
		publicVariable "EPOCH_VehicleSlotCount";
	};
	
	sleep 2;
	
	//systemChat(format["_vehiclePosition=%1",_vehiclePosition]);
	
	if (_remainingDamage > 0.1) then {
		_box = createVehicle ["groundWeaponHolder",[(_vehiclePosition select 0),(_vehiclePosition select 1),0.01], [], 0, "CAN_COLLIDE"];
		_box setVariable ["ObjectID","1",true];
		_box setVariable ["permaLoot",true];
	};

	while {_remainingDamage > 0.1} do {
		
		if ((_remainingDamage >= 0.1) && (_remainingDamage < 0.2)) then {
			_box addMagazineCargoGlobal [_part01, 1];
			//systemChat "added ItemCorrugated";
			_remainingDamage = _remainingDamage - ((random 3)/10);
		};
		
		if ((_remainingDamage >= 0.2) && (_remainingDamage <= 0.5)) then {
			_box addMagazineCargoGlobal [_part02, 1];
			//systemChat "added ItemCorrugatedLg";
			_remainingDamage = _remainingDamage - ((random 5)/10);
		};
		
		if (_remainingDamage > 0.5) then {
			if ((_isTruck) || (_isHeli)) then {
				_box addMagazineCargoGlobal [_partTruckHeli, 1];
				//systemChat "added VehicleRepairLg";
			};
			_box addMagazineCargoGlobal [_part05, 1];
			//systemChat "added VehicleRepair";
			_remainingDamage = _remainingDamage - ((random 10)/10);
		};
		
		sleep 3;
		//systemChat(format["_remainingDamage=%1",_remainingDamage]);
	};
	
	player switchMove "";
    player playActionNow "stop";
	
} else {
	systemChat(format["You need a Jack Tool Kit to remove this vehicle"]);
};

The script works great.

Enjoy!

Link to comment
Share on other sites

Ok after tinkering with this on my server here is how you get it running.....

 

Follow instructions by the OP but instead of saving your "custom\remove_vehicle as a .sql save it as a .sqf.

 

Than add these two lines to your BattlEye filters on line #25.....

 

!="Damage >= 0.1) && (_remainingDamage < 0.2)) then {_box addMagazineCargoGlobal [_part01, 1]"

 

!"_remainingDamage = _remainingDamag"

 

Hope this helps   ;)

Link to comment
Share on other sites

Ok after tinkering with this on my server here is how you get it running.....

 

Follow instructions by the OP but instead of saving your "custom\remove_vehicle as a .sql save it as a .sqf.

 

Than add these two lines to your BattlEye filters on line #25.....

 

!="Damage >= 0.1) && (_remainingDamage < 0.2)) then {_box addMagazineCargoGlobal [_part01, 1]"

 

!"_remainingDamage = _remainingDamag"

 

Hope this helps   ;)

 

Thanks Genocide for your share

Link to comment
Share on other sites

This is GREAT!

 

However, isn't there a way to check if the vehicle is locked, and only do it for unlocked vehicles?

 

That way, players would be able to only open 'non-owned' vehicles (well, on our server the lock time for groups is set to 6hrs, so a full reboot)?

 

EDIT: Also, how about adding a check to see how damaged the vehicle is, so only allowing it on vehicles damaged over a certain level?

 

That way, if the vehicle had to be:

 

1) Unlocked

 

2) Over 'x' damaged

 

it would stop the trolling a bit.

 

FINAL THOUGHT:

 

Check to see if there's a jammer within 100 meters of the vehicle, exitWith { // funny message here} if it's within 100 meters of a jammer? (stops some degree of base trolling, at least!

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

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