Jump to content

[RELEASE] TradeFromVehicle - Version 2.0 is here!


Csus

Recommended Posts

If you want to use CfgServerTrader instead of Hive you should do this:
Open TradeFromVehicle Version 2.0\system\functions.sqf and find this block of code:
 

TFV_traderGetWeaponsMagazinesPrices =
{
...
...
...
};

You should replace it completely with this:

 

TFV_traderGetWeaponsMagazinesPrices =
{
	private ["_trader","_traderData","_tids","_typeOfHumanityWeaponsMagazinesPrices","_typeOfHumanityWeaponsMagazinesPricesRAW","_physicalPrice","_intPrice","_currencyItem","_currencyItemWorth","_humanityNeed","_typeOfTrader","_badItems"];
	_trader = _this select 0;
	_intPrice = 0;
	_traderData = call TFV_tradersGetTypeOfTIDSHumanity;
	_badItems = ["USBasicBag","Tripod_Bag","M2StaticMG_US_Bag_EP1","M2HD_mini_TriPod_US_Bag_EP1","DSHKM_TK_GUE_Bag_EP1","DSHKM_TK_INS_Bag_EP1","DSHkM_Mini_TriPod_TK_GUE_Bag_EP1",
				 "DSHkM_Mini_TriPod_TK_INS_Bag_EP1","KORD_high_TK_Bag_EP1","KORD_high_UN_Bag_EP1","KORD_TK_Bag_EP1","KORD_UN_Bag_EP1","MK19_TriPod_US_Bag_EP1",
				 "AGS_TK_Bag_EP1","AGS_TK_GUE_Bag_EP1","AGS_TK_INS_Bag_EP1","AGS_UN_Bag_EP1","M252_US_Bag_EP1","2b14_82mm_TK_Bag_EP1","2b14_82mm_TK_GUE_Bag_EP1",
				 "2b14_82mm_TK_INS_Bag_EP1","Metis_TK_Bag_EP1","TOW_TriPod_US_Bag_EP1","SPG9_TK_GUE_Bag_EP1","SPG9_TK_INS_Bag_EP1","US_UAV_Pack_EP1","US_Assault_Pack_EP1",
				 "US_Patrol_Pack_EP1","US_Backpack_EP1","CZ_Backpack_EP1","CZ_VestPouch_EP1","TK_RPG_Backpack_EP1","TK_ALICE_Pack_EP1","TK_Assault_Pack_EP1","DZ_Patrol_Pack_EP1",
				 "DZ_Assault_Pack_EP1","DZ_Czech_Vest_Puch","DZ_ALICE_Pack_EP1","DZ_TK_Assault_Pack_EP1","DZ_British_ACU","DZ_CivilBackpack_EP1","DZ_Backpack_EP1",
				 "DZ_LargeGunBag_EP1","DZ_GunBag_EP1","DZ_CompactPack_EP1","DZ_TerminalPack_EP1","BAF_L2A1_ACOG_tripod_bag","BAF_L2A1_ACOG_minitripod_bag",
				 "BAF_GPMG_Minitripod_D_bag","BAF_GMG_ACOG_minitripod_bag"];
	
	if (!isNil "TFV_ATIS") then {
		if (!TFV_ATIS) then {
			_badItems = (_badItems + ["ItemToolbox","ItemEtool","ItemMatchbox","ItemHatchet","ItemKnife","ItemFlashlight","ItemFlashlightRed","Binocular","NVGoggles","Laserdesignator","Kostey_photos","Kostey_map_case","Kostey_notebook","CDF_dogtags","Moscow_Bombing_File","Cobalt_File","ItemWatch","ItemCompass","ItemGPS","ItemRadio","ItemMap","EvPhoto","EvMap","EvMoscow","EvKobalt","EvMoney","EvDogTags","ItemMatchbox_DZE","ItemMachete","ItemHatchet_DZE","ItemCrowbar","ItemMap_Debug","ItemShovel","ItemFishingPole","ItemSledge","ItemKeyKit","Binocular_Vector"]);
		};
	};
	
	{
	    if ((_x select 0) == _trader) exitWith {
		    _tids = _x select 1;
			_typeOfTrader = _x select 0;
			_humanityNeed = _x select 2;
		};
	} forEach _traderData;
	
	_typeOfHumanityWeaponsMagazinesPrices = [_typeOfTrader,_humanityNeed,[]];	

	{
	
	_cfgTraderCategory = missionConfigFile >> "CfgTraderCategory" >> (format["Category_%1",_x]);	

	PVDZE_plr_TradeMenuResult = [];
	
	for "_i" from 0 to ((count _cfgTraderCategory) - 1) do {
		_class = configName (_cfgTraderCategory select _i);
					
		_type  = getText ((_cfgTraderCategory select _i) >> "type");	
		_buy  = getArray ((_cfgTraderCategory select _i) >> "buy");	
		_sell = getArray ((_cfgTraderCategory select _i) >> "sell");
		
		_buy set [2,1];
		_sell set [2,1];

		_typeNum = 1;
		if (_type == "trade_weapons") then {
			_typeNum = 3;
		} else { 
			if (_type in ["trade_backpacks", "trade_any_vehicle", "trade_any_vehicle_free", "trade_any_boat", "trade_any_bicycle"]) then {
				_typeNum = 2;
			};
		};
		
		_data = [9999,[_class,_typeNum],99999,_buy,_sell,0,_trader_id,_type];
		
		PVDZE_plr_TradeMenuResult set [count PVDZE_plr_TradeMenuResult, _data];
	};
		
		if ((count(PVDZE_plr_TradeMenuResult)) > 0) then {
		    _typeOfHumanityWeaponsMagazinesPricesRAW = PVDZE_plr_TradeMenuResult;
		};
	
		{
		    if (!(((_x select 1) select 0) isKindOf 'AllVehicles') && !(((_x select 1) select 0) in _badItems)) then {
				_physicalPrice = [];
				_intPrice = 0;
				for "_i" from 0 to (((_x select 4) select 0) - 1) do {
					_physicalPrice set [(count _physicalPrice),((_x select 4) select 1)];
				};			
		
				{
					_currencyItem = (configFile >> "CfgMagazines" >> _x);
					_currencyItemWorth = (_currencyItem >> "worth");
					if (isNumber _currencyItemWorth) then {
						_intPrice = (_intPrice + getNumber(_currencyItemWorth));
					};
				} forEach _physicalPrice;
			    
				(_typeOfHumanityWeaponsMagazinesPrices select 2) set [(count (_typeOfHumanityWeaponsMagazinesPrices select 2)),[((_x select 1) select 0),((_x select 1) select 1),_intPrice]];
		    };
		} forEach _typeOfHumanityWeaponsMagazinesPricesRaw;
	} forEach _tids;

	_typeOfHumanityWeaponsMagazinesPrices
};

And here it is - now script uses config data. Do not forget, that trading actionmenu appears only with "canbuild = false".

Link to comment
Share on other sites

Semezky

This is the way I have it working :-) however I have added a couple of IF statements to make it automatically detect if you have it enabled or not. Also with a coin selector I will be uploading a version to GitHub shortly.  :-)

 

I also have two new option. Backpack TAX and Car Tax :-)... Selling in bulk we like to add a TAX to this.. Not sure how well it will work without coins so will add TRUE and False :-)

Link to comment
Share on other sites

OK, I was able to fix my own issue which was totally unrelated to this script ofc and I got the new version by swarfer working just fine, except it is still reading prices from the hive and not my custom traders.

 

If there is anything I can do to help you get this working with cfgtraders please let me know.

 

 

EDIT: I've been looking over the github and I do not see some of the modifications you made in the files I got from the zip, is it possible the zip on the main page is not directed to the proper files?

 

2nd EDIT: MY FAULT! i may have confused the zips from csus' version to yours..... my bad

Link to comment
Share on other sites

Hmm Weird i have mine working with Config Traders no problem.. If you look at the function file around line 51 "if(DZE_ConfigTrader) then {" after that put somethings like

 

diag_log format["[TFV] _CHECK TO SEE IF DZE_ConfigTrader is set"];

 

Then look in your ArmA2OA.RPT file for DZE_ConfigTrader.

 

Just check to make sure its actually loading the DZE_ConfigTrader variable.  NOTE* I take it DZE_ConfigTrader is set to "DZE_ConfigTrader = true;" in your custom variables or init file ?

Link to comment
Share on other sites

If you want to use CfgServerTrader instead of Hive you should do this:

Open TradeFromVehicle Version 2.0\system\functions.sqf and find this block of code:

 

TFV_traderGetWeaponsMagazinesPrices =
{
...
...
...
};

You should replace it completely with this:

 

TFV_traderGetWeaponsMagazinesPrices =
{
	private ["_trader","_traderData","_tids","_typeOfHumanityWeaponsMagazinesPrices","_typeOfHumanityWeaponsMagazinesPricesRAW","_physicalPrice","_intPrice","_currencyItem","_currencyItemWorth","_humanityNeed","_typeOfTrader","_badItems"];
	_trader = _this select 0;
	_intPrice = 0;
	_traderData = call TFV_tradersGetTypeOfTIDSHumanity;
	_badItems = ["USBasicBag","Tripod_Bag","M2StaticMG_US_Bag_EP1","M2HD_mini_TriPod_US_Bag_EP1","DSHKM_TK_GUE_Bag_EP1","DSHKM_TK_INS_Bag_EP1","DSHkM_Mini_TriPod_TK_GUE_Bag_EP1",
				 "DSHkM_Mini_TriPod_TK_INS_Bag_EP1","KORD_high_TK_Bag_EP1","KORD_high_UN_Bag_EP1","KORD_TK_Bag_EP1","KORD_UN_Bag_EP1","MK19_TriPod_US_Bag_EP1",
				 "AGS_TK_Bag_EP1","AGS_TK_GUE_Bag_EP1","AGS_TK_INS_Bag_EP1","AGS_UN_Bag_EP1","M252_US_Bag_EP1","2b14_82mm_TK_Bag_EP1","2b14_82mm_TK_GUE_Bag_EP1",
				 "2b14_82mm_TK_INS_Bag_EP1","Metis_TK_Bag_EP1","TOW_TriPod_US_Bag_EP1","SPG9_TK_GUE_Bag_EP1","SPG9_TK_INS_Bag_EP1","US_UAV_Pack_EP1","US_Assault_Pack_EP1",
				 "US_Patrol_Pack_EP1","US_Backpack_EP1","CZ_Backpack_EP1","CZ_VestPouch_EP1","TK_RPG_Backpack_EP1","TK_ALICE_Pack_EP1","TK_Assault_Pack_EP1","DZ_Patrol_Pack_EP1",
				 "DZ_Assault_Pack_EP1","DZ_Czech_Vest_Puch","DZ_ALICE_Pack_EP1","DZ_TK_Assault_Pack_EP1","DZ_British_ACU","DZ_CivilBackpack_EP1","DZ_Backpack_EP1",
				 "DZ_LargeGunBag_EP1","DZ_GunBag_EP1","DZ_CompactPack_EP1","DZ_TerminalPack_EP1","BAF_L2A1_ACOG_tripod_bag","BAF_L2A1_ACOG_minitripod_bag",
				 "BAF_GPMG_Minitripod_D_bag","BAF_GMG_ACOG_minitripod_bag"];
	
	if (!isNil "TFV_ATIS") then {
		if (!TFV_ATIS) then {
			_badItems = (_badItems + ["ItemToolbox","ItemEtool","ItemMatchbox","ItemHatchet","ItemKnife","ItemFlashlight","ItemFlashlightRed","Binocular","NVGoggles","Laserdesignator","Kostey_photos","Kostey_map_case","Kostey_notebook","CDF_dogtags","Moscow_Bombing_File","Cobalt_File","ItemWatch","ItemCompass","ItemGPS","ItemRadio","ItemMap","EvPhoto","EvMap","EvMoscow","EvKobalt","EvMoney","EvDogTags","ItemMatchbox_DZE","ItemMachete","ItemHatchet_DZE","ItemCrowbar","ItemMap_Debug","ItemShovel","ItemFishingPole","ItemSledge","ItemKeyKit","Binocular_Vector"]);
		};
	};
	
	{
	    if ((_x select 0) == _trader) exitWith {
		    _tids = _x select 1;
			_typeOfTrader = _x select 0;
			_humanityNeed = _x select 2;
		};
	} forEach _traderData;
	
	_typeOfHumanityWeaponsMagazinesPrices = [_typeOfTrader,_humanityNeed,[]];	

	{
	
	_cfgTraderCategory = missionConfigFile >> "CfgTraderCategory" >> (format["Category_%1",_x]);	

	PVDZE_plr_TradeMenuResult = [];
	
	for "_i" from 0 to ((count _cfgTraderCategory) - 1) do {
		_class = configName (_cfgTraderCategory select _i);
					
		_type  = getText ((_cfgTraderCategory select _i) >> "type");	
		_buy  = getArray ((_cfgTraderCategory select _i) >> "buy");	
		_sell = getArray ((_cfgTraderCategory select _i) >> "sell");
		
		_buy set [2,1];
		_sell set [2,1];

		_typeNum = 1;
		if (_type == "trade_weapons") then {
			_typeNum = 3;
		} else { 
			if (_type in ["trade_backpacks", "trade_any_vehicle", "trade_any_vehicle_free", "trade_any_boat", "trade_any_bicycle"]) then {
				_typeNum = 2;
			};
		};
		
		_data = [9999,[_class,_typeNum],99999,_buy,_sell,0,_trader_id,_type];
		
		PVDZE_plr_TradeMenuResult set [count PVDZE_plr_TradeMenuResult, _data];
	};
		
		if ((count(PVDZE_plr_TradeMenuResult)) > 0) then {
		    _typeOfHumanityWeaponsMagazinesPricesRAW = PVDZE_plr_TradeMenuResult;
		};
	
		{
		    if (!(((_x select 1) select 0) isKindOf 'AllVehicles') && !(((_x select 1) select 0) in _badItems)) then {
				_physicalPrice = [];
				_intPrice = 0;
				for "_i" from 0 to (((_x select 4) select 0) - 1) do {
					_physicalPrice set [(count _physicalPrice),((_x select 4) select 1)];
				};			
		
				{
					_currencyItem = (configFile >> "CfgMagazines" >> _x);
					_currencyItemWorth = (_currencyItem >> "worth");
					if (isNumber _currencyItemWorth) then {
						_intPrice = (_intPrice + getNumber(_currencyItemWorth));
					};
				} forEach _physicalPrice;
			    
				(_typeOfHumanityWeaponsMagazinesPrices select 2) set [(count (_typeOfHumanityWeaponsMagazinesPrices select 2)),[((_x select 1) select 0),((_x select 1) select 1),_intPrice]];
		    };
		} forEach _typeOfHumanityWeaponsMagazinesPricesRaw;
	} forEach _tids;

	_typeOfHumanityWeaponsMagazinesPrices
};

And here it is - now script uses config data. Do not forget, that trading actionmenu appears only with "canbuild = false"

Thank you!

Link to comment
Share on other sites

So I've taken the time to test this script out. I haven't tried the original but I tried Dwarfer's Single Currency version. I'm not sure how different these scripts are but I'm assuming the only difference is the currency + tax. If that's the case I think you should consider my thoughts:

 

Trading from vehicle has a glitch in it. You can sell from your vehicle no matter how far it is as long as you were the last one to sit in the driver seat. This can be an issue if you have smart enough players. For example let's say there's a group of 4: one driver and three looters. They go to the nearest military camp, park their vehicle in front of a barracks. The driver runs back to the trader city. Meanwhile the three looters are filling the vehicle up with weapons. When the vehicle is full the driver at the trader city sells everything instantly. Looters start filling up the vehicle again and driver sells and so on... Repeat this and you'll be rich in no time.

 

Another thing I think should be added is something that hints what you're about to sell and for how much. Right now you have no idea what you sell, how many of them and for how much. It just says "trading stuff from vehicle...".

 

If I have the time I'll do both of these things myself (for the single currency version at least).

Link to comment
Share on other sites

Trading from vehicle has a glitch in it. You can sell from your vehicle no matter how far it is as long as you were the last one to sit in the driver seat. 

 

As I mentioned in Dwarfer's topic I made a simple fix for that:

 

Open system\trade.sqf

 

Find:

_validMagazines = []; 

Add below:

_tooFar=false;
if (TFV_VEHICLE != objNull) then {
	if (_object == "vehicle") then {
		if ((player distance TFV_VEHICLE) > 50) exitWith {_tooFar=true;};
	};
};

if(_tooFar) exitWith {
	TFV_INWORK = false; systemChat "You're too far from your vehicle.";
}; 

 

Again I should mention I made this fix specifically for the Single Currency version. Thought the core script is pretty much the same so it should be okay for any version.

Csus I think it's a fix you should include it in your next patch.

Link to comment
Share on other sites

I just tried this, but it locked the Ural and there is no key for it. It was one found on the map

It did this to me too. It takes the weapon, locks the car, don't give any goldbars and the option to sale from car and backpack disappears. I haven't try with car that i own, but it needs to work with this, any solution to this you think.

Link to comment
Share on other sites

It did this to me too. It takes the weapon, locks the car, don't give any goldbars and the option to sale from car and backpack disappears. I haven't try with car that i own, but it needs to work with this, any solution to this you think.

 

Yeah my options went as well! I've just put backpack trading on for the moment, so will test that...

Link to comment
Share on other sites

I think the issue here is that you would not want your vehicle unlocked while at a trader so I am ok with a free vehicle that I would find and just sell it through my backpack. If you do not get in the drivers seat you will not be able to sell from the vehicle so if you have someone with you and they attempt to help you sell you will each need to get into the drivers seat in order to sell which would be a pain. Best bet is to have the other player load into the backpack and the other sell from the vehicle.

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