Jump to content

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


Recommended Posts

Hey guys! I want to only allow hero's to be able to deploy a motorcycle.  Any idea if thats possible?

 

 

This is what i was thinking - (sorry i'm new to scripting).

 

Edit the RC to do this:

		class BuildMotorcycle {
			text = "Deploy Motorcycle";
			script = "['TT650_Civ'] execVM 'custom\EVD\EVD_deploy_hero.sqf'";

Create EVD_Deploy_Hero.sqf and have it check if you are a hero and then deploy the motorcycle.

 

That should work, correct?

Link to comment
Share on other sites

I can make other vehicles at the same time and get two piles loot

use:

 

!!!NOT TESTED!!!

	//Pack Vehicles
	_cnt = {isPlayer _x && _x != player} count (player nearEntities [['CAManBase'], 5]);
	if (_typeOfCursorTarget in EVDVehicleArray and _hasToolbox and !(locked _cursorTarget) and (damage _cursorTarget < 1) and (player distance cursorTarget <= 2) ) then {
	if !(_cnt > 0) then  {	
		if (s_player_packvehicle < 0) then {
			s_player_packvehicle = player addAction ["Pack Vehicle", "SCRIPT_PATH\EVD\EVD_pack.sqf",_cursorTarget, 0, false, true, "",""];
		};
		};
	} else {
		player removeAction s_player_packvehicle;
		s_player_packvehicle = -1;
	};
Link to comment
Share on other sites

Can anyone help me? I use selfbloodbag as well as EVD, but only selfbloodbag is showing in the scroll menu.

 

Here's my extra_rc.hpp:

 

class ExtraRc {
class ItemBloodbag {
class Use {
text = "Use Bloodbag";
script = "execVM 'Scripts\player_selfbloodbag.sqf'";
}
}
class ItemToolbox {
class BuildBike {
text = "Deploy Bike";
script = "['MMT_Civ'] execVM 'Scripts\EVD\EVD_deploy.sqf'";
};
class BuildMotorcycle {
text = "Deploy Motorcycle";
script = "['TT650_Civ'] execVM 'Scripts\EVD\EVD_deploy.sqf'";
};
class BuildMozzie {
text = "Deploy Mozzie";
script = "['CSJ_GyroC'] execVM 'Scripts\EVD\EVD_deploy.sqf'";
};
};
};
Link to comment
Share on other sites

I can see the option to deploy when I right click the toolbox, but when I start deploying it just says I cancelled, and removes my toolbox without giving me a bike.

 

Is there a way to fix this and add it to the scroll-menu?

 

Cheers.

Link to comment
Share on other sites

I can see the option to deploy when I right click the toolbox, but when I start deploying it just says I cancelled, and removes my toolbox without giving me a bike.

 

Is there a way to fix this and add it to the scroll-menu?

 

Cheers.

 

Well...technically speaking, all the code you need are in admin tools scripts for spawning vehicles in...at least I think so. I'm sure it would take some tweaking for it to work as a player ability without any undesirable consequences. But maybe there is some scripting in one of those admin packs that would help get you started?

Link to comment
Share on other sites

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.

 

He has an extra bracket in there. This will work:

case "MMT_Civ": { _materials = []; };
Link to comment
Share on other sites

I can see the option to deploy when I right click the toolbox, but when I start deploying it just says I cancelled, and removes my toolbox without giving me a bike.

 

Is there a way to fix this and add it to the scroll-menu?

 

Cheers.

 

You're missing a couple semi-colons:

class Use {
text = "Use Bloodbag";
script = "execVM 'Scripts\player_selfbloodbag.sqf'";
}
}
Link to comment
Share on other sites

This script works great for me, besides the fact that everytime I deploy a mountain bike it kills me... :/ Anyone have any idea on how to fix this? Thanks! :)

 

The edit to variables.sqf in step 1 should prevent deaths like that..

Link to comment
Share on other sites

Everything works great except for when I repack any of the built vehicles (MMT_Civ, TT650_Civ, CSJ_GyroC). When the script tries to create a loot pile in front of the player, half of the time some or all items disappear. I believe it may be an issue with the antihack (infistar) or battleye not allowing items to be spawned in front of them. How would I go about having the items placed direct into the player inventory instead? The script I'm trying to do away with does this for me (I edited it to do so), but it was much more basic in that it used a separate script for each type of vehicle being packed instead of one script which counted up the items to be returned. I'm fairly new to editing arma code, so any tips would be much appreciated!

 

Here is what it looks like right now:

call compile preprocessFileLineNumbers "spawnbike\spawnbikeMaterials.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 spawnbikeGetMaterials;

		//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;
		player addWeapon "ItemToolbox";

		// 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 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;

And here is the spawnbikeMaterials.sqf file that it calls to:

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

// Script Functions
spawnbikeGetMaterials = {
	private ["_type","_materials"];

	_type = _this select 0;

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

	_materials;
};

Cheers!

Link to comment
Share on other sites

this might sometimes kill the player, when spawning an object to his exact position, this is fixed in arma 3 however, but you can avoid it in arma 2 in a few ways tho:

_radius = 10;
_object = createVehicle [_type, getPosATL player, [], _radius, "NONE"];

or even better, make sure its always spawns infront of the player like this:

_pos = getPos player;
_dir = getDir player;
_infrontdist = 5;
_object = createVehicle [_type,[(_pos select 0)+_infrontdist*sin(_dir),(_pos select 1)+_infrontdist*cos(_dir),0],[], 0, "CAN_COLLIDE"];

i also added a check if the player is inside a building, since i got many complaints about players building a bike inside a building and not being able to enter it after.

Link to comment
Share on other sites

I didn't get a response from my last question, so I took a shot at it myself. It works... kind of. It does give me the correct amount of items in return when I pack the TT650, but not the correct amount when I pack the mozzie. I only receive one engine, one main rotor and one scrap metal (instead of 2 scrap metal).

 

Here is the section of the script I modified in order to return items directly to the player inventory rather than creating a loot pile:

// give refund items
		if((count _materials) > 0) then {
			{
				_itemOut = _x select 0;
				_countOut = _x select 1;
				if (typeName _countOut == "ARRAY") then {
					_countOut = round((random (_countOut select 1)) + (_countOut select 0));
				};
				player addMagazine [_itemOut,_countOut];
			} forEach _materials;
		};

And here is my code for the required materials of each vehicle:

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

// Script Functions
spawnbikeGetMaterials = {
	private ["_type","_materials"];

	_type = _this select 0;

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

	_materials;
};

That is my main concern right now. What I would LIKE to do is add somewhere in the packing script some code to check that the vehicle they are trying to pack is within 2m of the player once just before it deletes the vehicle, otherwise I want it to fail to pack. The reason being is currently a player can run up to, say, a mozzie and get the pack option on his scrollwheel, then he can run basically as far away as he likes and then click the 'pack vehicle' option that is still showing on the scrollwheel option and pack up the vehicle as if he were still right beside it.

 

Thank you in advance to anyone willing to help.

Link to comment
Share on other sites

Thanks for this nice script. I will give you a 'like' when I can (tomorrow!) :)

 

Here is my tiny contribution:

 

If you want colored "Pack Vehicle" text in the mouse wheel option when looking at the deployed vehicle, you can use the following in fn_selfActions.sqf.

The first line (commented out with //) is the default one.

The 2nd line is the one I added, based on the forum posts here and other colored items I have (I think I copied bloodbag's color format and changed the color). Remember the color is html code so you can just google html color codes and change to whatever you'd like to see. (the one below is very dark/clear blue).

 

// s_player_packvehicle = player addAction ["Pack Vehicle", "custom\EVD\EVD_pack.sqf",_cursorTarget, 0, false, true, "",""];
s_player_packvehicle = player addaction[("<t color="#0000c7"">" + ("Pack Vehicle") +"</t>"),"custom\EVD\EVD_pack.sqf",_cursorTarget,0,false,true,"","];
Link to comment
Share on other sites

 

In EVD_pack.sqf

Add this:

player addWeapon "ItemToolbox";

After this

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

In EVD_deploy.sqf

Add this:

player removeWeapon "ItemToolbox";

After this:

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

Thank you Bambit, I used this modification - working like a charm.

Link to comment
Share on other sites

@Enzyme

 

 

Enzyme, on 17 Jun 2014 - 09:58 AM, said:

I didn't get a response from my last question, so I took a shot at it myself. It works... kind of. It does give me the correct amount of items in return when I pack the TT650, but not the correct amount when I pack the mozzie. I only receive one engine, one main rotor and one scrap metal (instead of 2 scrap metal).

Here is the section of the script I modified in order to return items directly to the player inventory rather than creating a loot pile:

// give refund items
if((count _materials) > 0) then {
{
_itemOut = _x select 0;
_countOut = _x select 1;
if (typeName _countOut == "ARRAY") then {
_countOut = round((random (_countOut select 1)) + (_countOut select 0));
};
player addMagazine [_itemOut,_countOut];
} forEach _materials;
};

And here is my code for the required materials of each vehicle:

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

// Script Functions
spawnbikeGetMaterials = {
private ["_type","_materials"];

_type = _this select 0;

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

_materials;
};

That is my main concern right now. What I would LIKE to do is add somewhere in the packing script some code to check that the vehicle they are trying to pack is within 2m of the player once just before it deletes the vehicle, otherwise I want it to fail to pack. The reason being is currently a player can run up to, say, a mozzie and get the pack option on his scrollwheel, then he can run basically as far away as he likes and then click the 'pack vehicle' option that is still showing on the scrollwheel option and pack up the vehicle as if he were still right beside it.

Thank you in advance to anyone willing to help.

I think the number 1 in brackets is supposed to tell the game that it is an item, just like in the database.

 

for example ["PartGeneric", 1] <-here

 

 2 would mean it's a vehicle and 3 would mean it's a weapon

 

so change it from ["PartGeneric", 2] to ["PartGeneric", 1], ["PartGeneric", 1] for multiple scrap metal

Link to comment
Share on other sites

@Enzyme

 

I think the number 1 in brackets is supposed to tell the game that it is an item, just like in the database.

 

for example ["PartGeneric", 1] <-here

 

 2 would mean it's a vehicle and 3 would mean it's a weapon

 

so change it from ["PartGeneric", 2] to ["PartGeneric", 1], ["PartGeneric", 1] for multiple scrap metal

 

Doh! Such an easy fix. Don't know why I didn't try that. Thank you.

Link to comment
Share on other sites

The only problem I have left to solve is that players are able to walk up to a vehicle, scroll wheel and get the option to pack vehicle, then run away as far as they like and then click 'pack vehicle' and successfully pack up the vehicle. I would like to add some code in to double check before packing that the vehicle is within 5m of the player. Here is the code I currently have, but it is not working. If I walk up to the vehicle, I get the option to pack it. It then does the animation, but the vehicle doesn't get deleted and the player doesn't get any items back. After that, you no longer get a 'pack vehicle' option. Anybody able to tell me where I went wrong and how I might fix it?

if (_finished) then {
		if ((player nearObjects ["EVDVehicleArray", 5]) && (!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];
				};
				player addWeapon "ItemToolbox";

				// give refund items
				if((count _materials) > 0) then {
					{
						_itemOut = _x select 0;
						_countOut = _x select 1;
						if (typeName _countOut == "ARRAY") then {
							_countOut = round( (_countOut select 1) + (_countOut select 0));
						};
						player addMagazine [_itemOut,_countOut];
					} forEach _materials;
				};
				
			};
			else {
		cutText [(localize "str_epoch_player_91"), "PLAIN DOWN"];
				};
} else {
	r_interrupt = false;
	player switchMove "";
	player playActionNow "stop";
	cutText ["Canceled packing vehicle", "PLAIN DOWN"];
};
Link to comment
Share on other sites

 

The only problem I have left to solve is that players are able to walk up to a vehicle, scroll wheel and get the option to pack vehicle, then run away as far as they like and then click 'pack vehicle' and successfully pack up the vehicle. I would like to add some code in to double check before packing that the vehicle is within 5m of the player. Here is the code I currently have, but it is not working. If I walk up to the vehicle, I get the option to pack it. It then does the animation, but the vehicle doesn't get deleted and the player doesn't get any items back. After that, you no longer get a 'pack vehicle' option. Anybody able to tell me where I went wrong and how I might fix it?

if (_finished) then {
		if ((player nearObjects ["EVDVehicleArray", 5]) && (!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];
				};
				player addWeapon "ItemToolbox";

				// give refund items
				if((count _materials) > 0) then {
					{
						_itemOut = _x select 0;
						_countOut = _x select 1;
						if (typeName _countOut == "ARRAY") then {
							_countOut = round( (_countOut select 1) + (_countOut select 0));
						};
						player addMagazine [_itemOut,_countOut];
					} forEach _materials;
				};
				
			};
			else {
		cutText [(localize "str_epoch_player_91"), "PLAIN DOWN"];
				};
} else {
	r_interrupt = false;
	player switchMove "";
	player playActionNow "stop";
	cutText ["Canceled packing vehicle", "PLAIN DOWN"];
};

 

You missed adding something in your fn_selfActions.

 

please post you fn_selfActions.

Link to comment
Share on other sites

You missed adding something in your fn_selfActions.

 

please post you fn_selfActions.

//Pack Vehicles
	if (_typeOfCursorTarget in EVDVehicleArray and !(locked _cursorTarget) and (damage _cursorTarget < 1)) then {
		if (s_player_packvehicle < 0) then {
			s_player_packvehicle = player addAction [("<t color=""#C86700"">" + ("Pack Vehicle") +"</t>"),"spawnbike\EVD_Pack.sqf",_cursorTarget,0,false,true,"",""];
		};
	} else {
		player removeAction s_player_packvehicle;
		s_player_packvehicle = -1;
	};
Link to comment
Share on other sites

It looks fine to me.  But did you put that block of code in the right spot?  Mine is at about line 800 so maybe double check if it's in the right spot.

 

Thank you for your time looking it over, Brockie.

 

I believe the spot it's in is fine because if I remove the check to see if the vehicle is within 5m, everything works just fine. But, once I add in the check to verify the vehicle is within 5m, it breaks the script. I get the option to pack, it does the animation, but instead of deleting the vehicle and refunding the parts the vehicle stays right there, no parts get refunded and I no longer get an option to pack the vehicle  :huh:

 

ie. script works if

if (_finished) then {
	if(!isNull(_obj)) then {

script does not work if

if (_finished) then {
		if ((player nearObjects ["EVDVehicleArray", 5]) && (!isNull(_obj))) then {

Anybody else have any ideas?  :unsure:

Link to comment
Share on other sites

Thank you for your time looking it over, Brockie.

 

I believe the spot it's in is fine because if I remove the check to see if the vehicle is within 5m, everything works just fine. But, once I add in the check to verify the vehicle is within 5m, it breaks the script. I get the option to pack, it does the animation, but instead of deleting the vehicle and refunding the parts the vehicle stays right there, no parts get refunded and I no longer get an option to pack the vehicle  :huh:

 

ie. script works if

if (_finished) then {
	if(!isNull(_obj)) then {

script does not work if

if (_finished) then {
		if ((player nearObjects ["EVDVehicleArray", 5]) && (!isNull(_obj))) then {

Anybody else have any ideas?  :unsure:

 

This is different then the problem you said before.  You said before that the problem was people could pack vehicle from anywhere that the option would not go away.  That would typically be an issue with fn_selfActions.

 

As a reference here is what my fn_selfActions looks like.  Obviously I have renamed things a bit to fit my desire but it works like a charm. 

 

//Pack Vehicles

if (_typeOfCursorTarget in StaticVehicleArray and _hasToolbox and !(locked _cursorTarget) and (damage _cursorTarget < 1)) then {

if (s_player_packvehicle < 0) then {

s_player_packvehicle = player addAction ["Pack Vehicle", "Scripts\static_pack.sqf",_cursorTarget, 0, false, true, "",""];

};

} else {

player removeAction s_player_packvehicle;

s_player_packvehicle = -1;

};

// All Traders

 

But you said now the problem is the vehicle doesn't disapear, no refund, and don't get an option to pack, then there's something wrong with your script.  I'm going to guess in the common file?

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
×
×
  • Create New...