Jump to content

[Release] Enhanced Vehicle Deployment (with right click option)


Recommended Posts

Nice work!

 

Suggestions:

 

It does allow you to pack items while people are driving them.  Change it to check for a driver/pilot.

Add a jerrycan to the recipes for the motorcycle and mozzie, or people get free fuel to siphon.

 

1) I've stated that this was one of my future additions, however, I encountered a problem. That is when to check if the vehicle is empty. Do you check before the action sequence or after it? Because another player can enter the vehicle while the action for the packing is taking place, however, you don't want a person to go through the action if there is someone already in the vehicle.

 

2) An admin can add fuel items by adding them to the EVDGetMaterials function in EVD_common.sqf. I may, however, add a check to the packing script that if a fuel item is used as a material, they will get an empty one back in return.

Link to comment
Share on other sites

1) I've stated that this was one of my future additions, however, I encountered a problem. That is when to check if the vehicle is empty. Do you check before the action sequence or after it? Because another player can enter the vehicle while the action for the packing is taking place, however, you don't want a person to go through the action if there is someone already in the vehicle.

 

2) An admin can add fuel items by adding them to the EVDGetMaterials function in EVD_common.sqf. I may, however, add a check to the packing script that if a fuel item is used as a material, they will get an empty one back in return.

 

1) Once before the action sequence starts is fine imo.

 

2) I think that's a grand idea - although I'd check the litres and spawn the vehicle with the same amount that was in the jerry, and give back whatever the tank has in it when it's packed.  If more than a jerry, give back a full one.

Link to comment
Share on other sites

Doesn't seem to work for me. You can deploy stuff regardless to whether you have the items?!

 

EVD_Common

// Do you want vehicles to be sold at traders?
EVDSellVehicles = false;

//////////////////////////////////////////////////////////////////////////////////////////
//                                   Common Functions                                   //
//////////////////////////////////////////////////////////////////////////////////////////
EVDGetMaterials = {
	private ["_type","_materials"];

	_type = _this select 0;

	switch (_type) do {
		case "MMT_Civ":		{ _materials = [["ItemToolbox", 1]; };
		case "TT650_Civ":	{ _materials = [["PartGeneric", 2], ["PartEngine", 1], ["PartWheel", 2]]; };
		case "CSJ_GyroC":	{ _materials = [["PartGeneric", 1], ["PartEngine", 1], ["PartVRotor", 1]]; };
	};

	_materials;
};

Link to comment
Share on other sites

1) I've stated that this was one of my future additions, however, I encountered a problem. That is when to check if the vehicle is empty. Do you check before the action sequence or after it? Because another player can enter the vehicle while the action for the packing is taking place, however, you don't want a person to go through the action if there is someone already in the vehicle.

 

2) An admin can add fuel items by adding them to the EVDGetMaterials function in EVD_common.sqf. I may, however, add a check to the packing script that if a fuel item is used as a material, they will get an empty one back in return.

 

Great script.  Will give it a go soon.  Just what I need for my lone wolf playing.

 

For question 1).  I would

  • check at the start: on vehicle not empty: Error (cannot pack as vehicle not empty) and exit script before any other action.
  • Check at the end: on vehicle not empty: Error (Packing failed as vehicle not empty).

Covers both bases and pretty simple to do.

 

RB

Link to comment
Share on other sites

Doesn't seem to work for me. You can deploy stuff regardless to whether you have the items?!

 

1. You have an unclosed array that is breaking the script.

 

2. See other posts in this topic about how to use the toolbox as material. Adding it to the materials list will not work because it is a special item and not a magazine item.

Link to comment
Share on other sites

This seems nice, but I think it conflicts with GeekGarage's plot pole/keep player UID modification. Ever since I installed it, none of these deploy vehicle scripts work (scroll doesn't show any option to build a bike/etc).

 

If you're familiar with how his plot pole/UID modification works, do you have any idea why they would conflict?

Link to comment
Share on other sites

1. You have an unclosed array that is breaking the script.

 

2. See other posts in this topic about how to use the toolbox as material. Adding it to the materials list will not work because it is a special item and not a magazine item.

 

Can you help me on the unclosed array, as i haven't had the time lately to properly learn Arma Code.

 

I haven't changed any closing brackets in the file i just removed the materials required for the Bike.

 

I edited the toolbox problem thanks for that

 

Thanks

Link to comment
Share on other sites

EVDGetMaterials = {
	private ["_type","_materials"];

	_type = _this select 0;

	switch (_type) do {
		case "MMT_Civ":		{ _materials = [[]; };
		case "TT650_Civ":	{ _materials = [["PartGeneric", 2], ["PartEngine", 1], ["PartWheel", 2]]; };
		case "CSJ_GyroC":	{ _materials = [["PartGeneric", 1], ["PartEngine", 1], ["PartVRotor", 1]]; };
	};

	_materials;
};
Link to comment
Share on other sites

Should put a closeDialog 602; in your deploy, so it shuts down the inventory window once the deploy starts.  I been running a similar version for awhile and had to go ahead and remove the toolbox/whatever part you using first before the animation finishes.  Came on my server to someone duping a ton of bikes by the inventory window staying open.

Link to comment
Share on other sites

This is bugging me now can someone please assist me, you can build the vehicles regardless if you have the materials or not

 

Common

/*
	Enhanced Vehicle Deployment by TheFarix
*/

//////////////////////////////////////////////////////////////////////////////////////////
//                                     Configuration                                    //
//////////////////////////////////////////////////////////////////////////////////////////

// Do you want vehicles to be sold at traders?
EVDSellVehicles = false;

//////////////////////////////////////////////////////////////////////////////////////////
//                                   Common Functions                                   //
//////////////////////////////////////////////////////////////////////////////////////////
EVDGetMaterials = {
	private ["_type","_materials"];

	_type = _this select 0;

	switch (_type) do {
		case "MMT_Civ":		{ _materials = []; };
		case "TT650_Civ":	{ _materials = [["PartGeneric", 2], ["PartEngine", 1], ["PartWheel", 2]]; };
		case "CSJ_GyroC":	{ _materials = [["PartGeneric", 2], ["PartEngine", 1], ["PartVRotor", 1]]; };
	};

	_materials;
};

Deploy

/*
	Enhanced Vehicle Deployment by TheFarix
*/

call compile preprocessFileLineNumbers "SCRIPT_PATH\EVD\EVD_common.sqf";

if (dayz_combat == 1) exitwith { cutText ["\n\nYou are in combat and cannot perform that action!", "PLAIN DOWN"] };

private ["_type","_inVehicle","_onLadder","_canDo","_materials","_proceed","_qty","_missing","_missingQty","_objectID"];

_type = _this select 0;

_inVehicle = (vehicle player != player);
_onLadder =	(getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder and !_inVehicle);

if (_canDo) then {
	_materials = [_type] call EVDGetMaterials;

	// Dry run to see if all parts are available.
	_proceed = true;
	if (count _materials > 0) then {
		{
			_itemIn = _x select 0;
			_countIn = _x select 1;
		
			_qty = { _x == _itemIn } count magazines player;

			if(_qty < _countIn) exitWith { _missing = _itemIn; _missingQty = (_countIn - _qty); _proceed = false; };
		} forEach _materials;
	};

	if (_proceed) then {
		closeDialog 1;

		cutText ["\n\nDeploying vehicle started", "PLAIN DOWN"];

		[1,1] call dayz_HungerThirst;
		player playActionNow "Medic";

		[player,"repair",0,false] call dayz_zombieSpeak;
		[player,50,true,(getPosATL player)] spawn player_alertZombies;

		r_interrupt = false;
		_animState = animationState player;
		r_doLoop = true;
		_started = false;
		_finished = false;

		while {r_doLoop} do {
			_animState = animationState player;
			_isMedic = ["medic",_animState] call fnc_inString;
			if (_isMedic) then {
				_started = true;
			};
			if (_started and !_isMedic) then {
				r_doLoop = false;
				_finished = true;
			};
			if (r_interrupt) then {
				r_doLoop = false;
			};
			sleep 0.1;
		};
		r_doLoop = false;

		_hasToolbox = "ItemToolbox" in items player;
		if (_finished and _hasToolbox) then {
			player removeWeapon "ItemToolbox";
			_removed_total = 0; // count total of removed items
			_tobe_removed_total = 0; // count total of all to be removed items
			// Take items
			{
				_removed = 0;
				_itemIn = _x select 0;
				_countIn = _x select 1;
				_tobe_removed_total = _tobe_removed_total + _countIn;

				{
					_configParent = configName(inheritsFrom(configFile >> "cfgMagazines" >> _x));
					if( (_removed < _countIn) && ((_x == _itemIn) || (_configParent == _itemIn))) then {
						_num_removed = ([player,_x] call BIS_fnc_invRemove);
						_removed = _removed + _num_removed;
						_removed_total = _removed_total + _num_removed;
						if(_num_removed >= 1) then {
							_temp_removed_array set [count _temp_removed_array,_x];
						};
					};

				} forEach magazines player;

			} forEach _materials;
		
			// Only proceed if all parts were removed successfully
			if(_removed_total == _tobe_removed_total) then {
				if (EVDSellVehicles) then {
					_objectID = str(round(random 999999));
				} else {
					_objectID = "0";
				};

				_object = _type createVehicle (position player);
				_object setVariable ["ObjectID", _objectID, true];
				_object setVariable ["ObjectUID", _objectID, true];
				_object addEventHandler ["GetIn",{
					_nil = [nil,(_this select 2),"loc",rTITLETEXT,"Warning: This vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
				}];

				clearWeaponCargoGlobal _object;
				clearMagazineCargoGlobal _object;
				_object setVehicleAmmo 0;

				player reveal _object;

				cutText ["\n\nYou've built a vehicle!", "PLAIN DOWN"];
			} else {
				// Refund parts since we failed
				{player addMagazine _x;} forEach _temp_removed_array;

				cutText [format[(localize "str_epoch_player_151"),_removed_total,_tobe_removed_total], "PLAIN DOWN"];
			};
		} else {
			r_interrupt = false;
			player switchMove "";
			player playActionNow "stop";
			cutText ["\n\nCanceled deploying vehicle", "PLAIN DOWN"];
		};
	} else {
		_textMissing = getText(configFile >> "CfgMagazines" >> _missing >> "displayName");
		cutText [format["Missing %1 more of %2",_missingQty, _textMissing], "PLAIN DOWN"];
	};
} else {
	cutText ["\n\nCanceled deploying vehicle", "PLAIN DOWN"];
};

Pack

/*
	Enhanced Vehicle Deployment by TheFarix
*/

call compile preprocessFileLineNumbers "SCRIPT_PATH\EVD\EVD_common.sqf";

if (dayz_combat == 1) exitwith { cutText ["\n\nYou are in combat and cannot perform that action!", "PLAIN DOWN"] };

private ["_obj","_animState","_started","_finished"];

if(DZE_ActionInProgress) exitWith { cutText ["Vehicle packing already in progress." , "PLAIN DOWN"]; };
DZE_ActionInProgress = true;

player removeAction s_player_packVehicle;
s_player_packVehicle = 1;

_obj = _this select 3;

cutText ["Packing vehicle started", "PLAIN DOWN"];

[1,1] call dayz_HungerThirst;
player playActionNow "Medic";

[player,"repair",0,false] call dayz_zombieSpeak;
[player,50,true,(getPosATL player)] spawn player_alertZombies;

r_interrupt = false;
_animState = animationState player;
r_doLoop = true;
_started = false;
_finished = false;

while {r_doLoop} do {
	_animState = animationState player;
	_isMedic = ["medic",_animState] call fnc_inString;
	if (_isMedic) then {
		_started = true;
	};
	if (_started and !_isMedic) then {
		r_doLoop = false;
		_finished = true;
	};
	if (r_interrupt) then {
		r_doLoop = false;
	};
	sleep 0.1;
};
r_doLoop = false;
		
if (_finished) then {
	// Double check that object is not null
	if(!isNull(_obj)) then {
		_ipos = getPosATL _obj;
		_type = typeOf _obj;

		_materials = [_type] call EVDGetMaterials;

		//Delete from hive
		_objectID  = _obj getVariable ["ObjectID","0"];
		_objectUID = _obj getVariable ["ObjectUID","0"];
		_activatingPlayer = player;
		PVDZE_obj_Delete = [_objectID,_objectUID,_activatingPlayer];
		publicVariableServer "PVDZE_obj_Delete";

		deleteVehicle _obj;

		if (_ipos select 2 < 0) then {
			_ipos set [2,0];
		};

		_radius = 1;

		// give refund items
		if((count _materials) > 0) then {
			_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
			{
				_itemOut = _x select 0;
				_countOut = _x select 1;
				if (typeName _countOut == "ARRAY") then {
					_countOut = round((random (_countOut select 1)) + (_countOut select 0));
				};
				_item addMagazineCargoGlobal [_itemOut,_countOut];
			} forEach _materials;
			
			_item addWeaponCargoGlobal ["ItemToolbox", 1];

			_item setposATL _iPos;

			player reveal _item;

			player action ["Gear", _item];
		};
	} else {
		cutText [(localize "str_epoch_player_91"), "PLAIN DOWN"];
	};
} else {
	r_interrupt = false;
	player switchMove "";
	player playActionNow "stop";
	cutText ["Canceled packing vehicle", "PLAIN DOWN"];
};

DZE_ActionInProgress = false;
s_player_packVehicle = -1;

Thanks

Link to comment
Share on other sites

EVDGetMaterials = {
	private ["_type","_materials"];

	_type = _this select 0;

	switch (_type) do {
		case "MMT_Civ":		{ _materials = [[]; };
		case "TT650_Civ":	{ _materials = [["PartGeneric", 2], ["PartEngine", 1], ["PartWheel", 2]]; };
		case "CSJ_GyroC":	{ _materials = [["PartGeneric", 1], ["PartEngine", 1], ["PartVRotor", 1]]; };
	};

	_materials;
};

Um, I'm just passing through... looking for clues as to how I recently broke this WONDERFUL script, we love it!

 

And, I think I see a frequent POSSIBLE problem... you might be missing a close-bracket in your mountainbike line.

 

You have:

case "MMT_Civ":        { _materials = [[]; };

But if you look real close at each of the deployable vehicles, there is a set of brackets enclosing the whole list of each vehicles required materials, and also a set of brackets enclosing each material. So instead of the [ [ ] in your line, it should possibly look like the others, like this [ [ ] ] 

 

I think that might be called an "open array"...but I'm still learning.

Link to comment
Share on other sites

I am stuck on "Waiting for Host" RPT doesn't say anything either.

#  Bone leftshoulder doesn't exist in some skeleton 
 2:19:52 Error: Bone rightshoulder doesn't exist in some skeleton 
 2:19:52 Error: Bone leftshoulder doesn't exist in some skeleton 
 2:19:52 Error: Bone leftshoulder doesn't exist in some skeleton 
 2:19:52 Error: Bone rightshoulder doesn't exist in some skeleton 
 2:19:52 Error: Bone leftshoulder doesn't exist in some skeleton 
 2:19:52 Error: Bone rightshoulder doesn't exist in some skeleton 
 2:20:15 [DZMS]: Running Major Mission SM3.
 2:20:17 [DZMS]: (DZMSUnitsMajor) 3 AI Spawned, 3 units in mission.
 2:20:23 [DZMS]: (DZMSUnitsMajor) 3 AI Spawned, 6 units in mission.
 2:20:28 [DZMS]: (DZMSUnitsMajor) 3 AI Spawned, 9 units in mission.
 2:20:33 [DZMS]: (DZMSUnitsMajor) 3 AI Spawned, 12 units in mission.
 2:20:33 [DZMS]: (DZMSUnitsMajor) Waiting for 12/12 Units or Less to be Alive and a Player to be Near the Objective.
 2:24:43 "TIME SYNC: Local Time set to [2013,8,3,21,24]"
 2:24:46 [DZMS]: Running Minor Mission SM2.
 2:24:51 [DZMS]: (DZMSUnitsMinor) 4 AI Spawned, 4 units in mission.
 2:24:54 [DZMS]: (DZMSUnitsMinor) 4 AI Spawned, 8 units in mission.
 2:24:57 [DZMS]: (DZMSUnitsMinor) 4 AI Spawned, 12 units in mission.
 2:25:00 [DZMS]: (DZMSUnitsMinor) 4 AI Spawned, 16 units in mission.
 2:25:03 [DZMS]: (DZMSUnitsMinor) Waiting for 16/16 Units or Less to be Alive and a Player to be Near the Objective.
 2:29:43 "TIME SYNC: Local Time set to [2013,8,3,21,29]"
 2:30:04 "RUNNING EVENT: crash_spawner on [2014,6,1,21,30]"
 2:30:04 "CRASHSPAWNER: 95.3086% chance to start a crashing UH-1Y with loot table 'HeliCrash'"
 2:30:04 "CRASHSPAWNER: UH-1Y started flying from [8582.35,14077.7,0] to [5019.71,15359.4] NOW!(TIME:821||LT:HeliCrash)"
 2:34:43 "TIME SYNC: Local Time set to [2013,8,3,21,34]"
 2:34:43 "CLEANUP: Deleted 1 Animals out of 6"
 2:35:35 "get: STRING (236588678), sent: STRING (236588678)"
 2:35:35 "DISCONNECT: Evil Homer (236588678) Object: B 1-1-B:1 (Evil Homer) REMOTE, _characterID: 5 at loc [9481.34,2003.46,0.00147152]"
 2:35:35 Client: Remote object 3:6 not found
 2:37:27 "CRASHSPAWNER: UH-1Y just exploded at [5040.57,15137.2,1.7691]!, "
 2:37:27 UH1Wreck_DZ: MainTurret - unknown animation source MainTurret
 2:37:27 UH1Wreck_DZ: MainGun - unknown animation source mainGun
 2:37:27 UH1Wreck_DZ: Gatling - unknown animation source Gatling
 2:37:27 "CRASHSPAWNER: Loot spawn at '[5044.8,15140.1,0]' with loot table 'HeliCrash'"
 2:37:27 "CRASHSPAWNER: Loot spawn at '[5035.59,15140.2,0]' with loot table 'HeliCrash'"
 2:37:27 "CRASHSPAWNER: Loot spawn at '[5036.36,15139.1,0]' with loot table 'HeliCrash'"
 2:37:27 "CRASHSPAWNER: Loot spawn at '[5036.45,15143.4,0]' with loot table 'HeliCrash'"
 2:37:27 "CRASHSPAWNER: Loot spawn at '[5042.57,15133.2,0]' with loot table 'HeliCrash'"
 2:37:27 "CRASHSPAWNER: Crash completed! Wreck at: [5040.57,15137.2,-0.133118] - Runtime: 443 Seconds || Distance from calculated POC: 228 meters"
 2:39:43 "TIME SYNC: Local Time set to [2013,8,3,21,39]"
 2:40:44 "CLEANUP: Deleted 1 Loot Piles out of 14"
Link to comment
Share on other sites

Works great! thank you!

 

My problem is the salvage script - cause you can completely salvage all items of the vehicle you deployed (glasses etc.)

is there a walkaround how to prevent those deployed vehicles of salvage option? sorry for my poor english :rolleyes:

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...