Jump to content
  • 0

Trader removed keys when selling vehicle.


theduke

Question

I use master key on our servers.  When a player sells a key, it takes the key.  So, tried putting it in backpack. still takes the key. Tried with copies, one on toolbelt, one in backpack, took both keys lol

I found that in trade_any_vehicle.sqf there is a block of code that removes the keys and would like  to comment t that out to try if the key stays in the inventory

// remove Key
						_temp_keys = [];
						_keyColor = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
						{
							if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _keyColor) then {
								if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == _objectCharacterId) then {
									[_activatingPlayer,_x] call BIS_fnc_invRemove;
								};
							};
						} count (items _activatingPlayer);

I wanted to bring that mission sided (as its found in the dayz_code\actions), but im not able to find it in the compiles. So i looked through the dayz_code again to find that

player_hivetrading.sqf calls these actions, based on a string?!?! it seems lol.  

 

// Action file to use for trade
		_afile = _x select 7;
		_File = "\z\addons\dayz_code\actions\" + _afile + ".sqf";

any advice would be awesome

Thanks

Duke

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
4 hours ago, theduke said:

I use master key on our servers.  When a player sells a key, it takes the key.  So, tried putting it in backpack. still takes the key. Tried with copies, one on toolbelt, one in backpack, took both keys lol

I found that in trade_any_vehicle.sqf there is a block of code that removes the keys and would like  to comment t that out to try if the key stays in the inventory


// remove Key
						_temp_keys = [];
						_keyColor = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
						{
							if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _keyColor) then {
								if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == _objectCharacterId) then {
									[_activatingPlayer,_x] call BIS_fnc_invRemove;
								};
							};
						} count (items _activatingPlayer);

I wanted to bring that mission sided (as its found in the dayz_code\actions), but im not able to find it in the compiles. So i looked through the dayz_code again to find that

player_hivetrading.sqf calls these actions, based on a string?!?! it seems lol.  

 


// Action file to use for trade
		_afile = _x select 7;
		_File = "\z\addons\dayz_code\actions\" + _afile + ".sqf";

any advice would be awesome

Thanks

Duke

That's the old trading system. If you are using Advanced Trading it is different.

Advanced trading uses a file called DZE_deleteTradedVehicle.sqf, I think if you want to disable keys getting removed you would need to overwrite that file and remove the following lines (maybe, untested) https://github.com/EpochModTeam/DayZ-Epoch/blob/master/SQF/dayz_code/actions/AdvancedTrading/functions/DZE_deleteTradedVehicle.sqf#L5-L60

I have tested this code block as working, selling keyed and non keyed vehicles:

private ["_localResult2","_VehKey2"];
_VehKey2 = (_this select 0) select 0;

if ((count _VehKey2) > 0) then {
	_localResult2 = 1;
	PVDZ_obj_Destroy = [(_VehKey2 select 2),(_VehKey2 select 3),player];
	publicVariableServer "PVDZ_obj_Destroy";
	deleteVehicle (_VehKey2 select 1);
} else {
	_localResult2 = 0;
};
_localResult2;

To overwrite this, you will also need to overwrite your init.sqf for advanced trading.

Link to comment
Share on other sites

  • 0
16 hours ago, salival said:

That's the old trading system. If you are using Advanced Trading it is different.

Advanced trading uses a file called DZE_deleteTradedVehicle.sqf, I think if you want to disable keys getting removed you would need to overwrite that file and remove the following lines (maybe, untested) https://github.com/EpochModTeam/DayZ-Epoch/blob/master/SQF/dayz_code/actions/AdvancedTrading/functions/DZE_deleteTradedVehicle.sqf#L5-L60

I have tested this code block as working, selling keyed and non keyed vehicles:


private ["_localResult2","_VehKey2"];
_VehKey2 = (_this select 0) select 0;

if ((count _VehKey2) > 0) then {
	_localResult2 = 1;
	PVDZ_obj_Destroy = [(_VehKey2 select 2),(_VehKey2 select 3),player];
	publicVariableServer "PVDZ_obj_Destroy";
	deleteVehicle (_VehKey2 select 1);
} else {
	_localResult2 = 0;
};
_localResult2;

To overwrite this, you will also need to overwrite your init.sqf for advanced trading.

I had a feeling i was editing the wrong file lol

This worked great. Many thanks Salival!

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