Skip to content

Commit

Permalink
Merge pull request #226 from SilenceIsFatto/forbiddenItems-sell-fix
Browse files Browse the repository at this point in the history
Add forbiddenItems sale checks
  • Loading branch information
AUC-bot authored Jul 3, 2024
2 parents 01eb90d + 73efab6 commit a8d43e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions A3A/addons/hals/Addons/store/functions/server/fn_sell.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,21 @@ try {
private _trader = _unit getVariable ["HALs_store_trader_current", objNull];
if (isNull _trader) then {throw [""]};

private _forbiddenItem_is_unlimited = 0;

if (_classname in A3U_forbiddenItems) then {
private _is_forbiddenItem = isClass (configFile >> "A3U" >> "forbiddenItems" >> _classname);

diag_log format["%1 is a forbidden item.", _classname];

if (_is_forbiddenItem) then {
_is_forbiddenItemUnlimited = (getNumber (configFile >> "A3U" >> "forbiddenItems" >> _classname >> "unlimited"));
};
};

// Check if the trader will buy this item
private _stock = [_trader, _classname] call HALs_store_fnc_getTraderStock;
if (_stock isEqualTo -1) then {
if (_stock isEqualTo -1) then { // && {_is_forbiddenItem isEqualTo false}
// Try parent
_parent = _classname call HALs_store_fnc_getParentClassname;
_stock = [_trader, _parent] call HALs_store_fnc_getTraderStock;
Expand Down Expand Up @@ -76,7 +88,9 @@ try {
(jna_dataList select IDC_RSCDISPLAYARSENAL_TAB_NVGS) +
(jna_dataList select IDC_RSCDISPLAYARSENAL_TAB_HEADGEAR) +
(jna_dataList select IDC_RSCDISPLAYARSENAL_TAB_VEST)
) select {(_x select 1) == -1 || {(_x select 1) >= minWeaps}}) apply {_x select 0};
) select {(_x select 1) == -1 || {(_x select 1) >= minWeaps && {_is_forbiddenItemUnlimited isEqualTo 0}}}) apply {_x select 0};

diag_log (format["%1 unlock state: %2", _classname, (_classname in _unlockedItems)]);

if (_classname in _unlockedItems) then {
throw ["The trader is not interested in this item, no deal."]
Expand Down
2 changes: 1 addition & 1 deletion A3A/addons/ultimate/config/cfgForbiddenItems.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class forbiddenItems
#include "cfgForbiddenItemsSMA.hpp"
#include "cfgForbiddenItemsTOW.hpp"
#include "cfgForbiddenItemsUns.hpp"
};
};

0 comments on commit a8d43e4

Please sign in to comment.