mirror of
https://github.com/EpochModTeam/Epoch.git
synced 2024-08-30 18:22:13 +00:00
Handle not full mags in Trader
This commit is contained in:
parent
3bbf2de4f5
commit
2ccb006697
@ -1,32 +1,30 @@
|
|||||||
/*
|
/*
|
||||||
Author: Aaron Clark - EpochMod.com
|
Author: He-Man - Ignatz-Gaming
|
||||||
|
|
||||||
Contributors: He-Man
|
Contributors: Raimonds Virtoss
|
||||||
|
|
||||||
Description:
|
Description:
|
||||||
NPC trade filter code
|
Filter Items in Trader Dialog
|
||||||
|
|
||||||
Licence:
|
Licence:
|
||||||
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
|
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
|
||||||
|
|
||||||
Github:
|
Github:
|
||||||
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/traders/EPOCH_NPCTraderMenuFilter.sqf
|
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/traders/EPOCH_NPCTraderFilter.sqf
|
||||||
|
|
||||||
Example:
|
|
||||||
onLBSelChanged = "_this call EPOCH_NPCTraderMenuFilter";
|
|
||||||
|
|
||||||
Parameter(s):
|
|
||||||
_this select 0: CONTROL
|
|
||||||
_this select 1: NUMBER - Index ID
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
NOTHING
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
disableSerialization;
|
disableSerialization;
|
||||||
//[[[cog import generate_private_arrays ]]]
|
private [ "_PlayerFilerDropDown","_PlayerItemsBox","_PlayerItemsOutBox","_TraderItemsBox","_TraderItemsOutBox","_config","_MainCategoriearray","_FilterArray","_MainCategorie","_subcategories","_SubCategorieItems",
|
||||||
private ["_FilterArray","_MainCategorie","_MainCategoriearray","_SubCategorieItems","_aiItems","_config","_control","_display","_id","_isPlayerFilter","_item","_itemCount","_itemOfferCount","_items","_name","_offerArray","_picture","_playeritems","_qty","_qtys","_sizeOut","_slot","_sortarray","_subcategories","_type","_vehicles"];
|
"_slot","_isPlayerFilter","_item","_rounds","_maxrnd","_tooltip","_qty","_id","_vehicles","_VehOfferArray","_sizeOut","_type","_itemCount","_itemOfferCount","_name","_picture","_items","_qtys","_sortarray"
|
||||||
//[[[end]]]
|
];
|
||||||
params ["_control","_index"];
|
params ["_control","_index"];
|
||||||
|
|
||||||
|
_PlayerFilerDropDown = 42100;
|
||||||
|
_PlayerItemsBox = 41500;
|
||||||
|
_PlayerItemsOutBox = 41501;
|
||||||
|
_TraderItemsBox = 41503;
|
||||||
|
_TraderItemsOutBox = 41502;
|
||||||
|
|
||||||
_config = 'CfgItemSort' call EPOCH_returnConfig;
|
_config = 'CfgItemSort' call EPOCH_returnConfig;
|
||||||
_MainCategoriearray = getarray (_config >> "MainCategories" >> "Classes");
|
_MainCategoriearray = getarray (_config >> "MainCategories" >> "Classes");
|
||||||
_FilterArray = [];
|
_FilterArray = [];
|
||||||
@ -46,96 +44,109 @@ if (_index != 0) then {
|
|||||||
};
|
};
|
||||||
if !(isNull EPOCH_lastNPCtradeTarget) then {
|
if !(isNull EPOCH_lastNPCtradeTarget) then {
|
||||||
_slot = EPOCH_lastNPCtradeTarget getVariable["AI_SLOT", -1];
|
_slot = EPOCH_lastNPCtradeTarget getVariable["AI_SLOT", -1];
|
||||||
_isPlayerFilter = (ctrlIDC _control == 42100);
|
|
||||||
if (_slot != -1) then {
|
if (_slot != -1) then {
|
||||||
|
_isPlayerFilter = (ctrlIDC _control == _PlayerFilerDropDown);
|
||||||
if (_isPlayerFilter) then {
|
if (_isPlayerFilter) then {
|
||||||
_sizeOut = lbSize 41501;
|
lbClear _PlayerItemsBox;
|
||||||
_offerArray = [];
|
|
||||||
if (_sizeOut > 0) then {
|
|
||||||
for "_i" from 0 to (_sizeOut - 1) do {
|
|
||||||
_item = lbData [41501, _i];
|
|
||||||
_offerArray pushBack _item;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
lbClear 41500;
|
|
||||||
_playeritems = ((items player)+(magazines player));
|
|
||||||
if (primaryWeapon player != "") then {
|
|
||||||
_playeritems pushback primaryWeapon player;
|
|
||||||
};
|
|
||||||
if (count backpackItems player == 0 && count backpackmagazines player == 0 && backpack player != "") then {
|
|
||||||
_playeritems pushback backpack player;
|
|
||||||
};
|
|
||||||
|
|
||||||
{
|
{
|
||||||
_item = _x;
|
_item = _x;
|
||||||
|
_rounds = 1;
|
||||||
|
if (_item isequaltype []) then {
|
||||||
|
_item = _x select 0;
|
||||||
|
_rounds = _x select 1;
|
||||||
|
};
|
||||||
if !(_item isequalto "") then {
|
if !(_item isequalto "") then {
|
||||||
|
_maxrnd = 1;
|
||||||
|
_tooltip = "";
|
||||||
|
if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
|
||||||
|
};
|
||||||
|
_qty = _rounds/_maxrnd;
|
||||||
|
if (_qty < 1) then {
|
||||||
|
_tooltip = format ["%1 rounds left in Magazine",_rounds];
|
||||||
|
};
|
||||||
if (_index == 0 || (tolower _item) in _FilterArray) then {
|
if (_index == 0 || (tolower _item) in _FilterArray) then {
|
||||||
_itemCount = {_x == _item} count ((items player)+(magazines player)+[backpack player]+[primaryweapon player]);
|
_id = lbAdd [_PlayerItemsBox, _item call EPOCH_itemDisplayName];
|
||||||
_itemOfferCount = {_x == _item} count _offerArray;
|
lbSetData [_PlayerItemsBox, _id, _item];
|
||||||
if (_itemCount > _itemOfferCount) then {
|
lbSetValue [_PlayerItemsBox, _id, _rounds];
|
||||||
_offerArray pushBack _item;
|
lbSetPicture [_PlayerItemsBox, _id, _item call EPOCH_itemPicture];
|
||||||
_id = lbAdd [41500, _x call EPOCH_itemDisplayName];
|
if !(_tooltip isequalto "") then {
|
||||||
lbSetData [41500, _id, _x];
|
lbSetTooltip [_PlayerItemsBox, _id, _tooltip];
|
||||||
lbSetPicture [41500, _id, _x call EPOCH_itemPicture];
|
lbSetColor [_PlayerItemsBox,_id,[1,(_rounds/_maxrnd),0,1]];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} forEach _playeritems;
|
} forEach EPOCH_NpcTradePlayerItems;
|
||||||
|
|
||||||
_vehicles = player nearEntities [["LandVehicle","Ship","Air","Tank"], 30];
|
_vehicles = player nearEntities [["LandVehicle","Ship","Air","Tank"], 30];
|
||||||
|
if !(_vehicles isequalto []) then {
|
||||||
|
_VehOfferArray = [];
|
||||||
|
_sizeOut = lbSize _PlayerItemsOutBox;
|
||||||
|
if (_sizeOut > 0) then {
|
||||||
|
for "_i" from 0 to (_sizeOut - 1) do {
|
||||||
|
_item = lbData [_PlayerItemsOutBox, _i];
|
||||||
|
if (_item iskindof "Landvehicle" || _item iskindof "AIR" || _item iskindof "SHIP" || _item iskindof "TANK") then {
|
||||||
|
_VehOfferArray pushBack _item;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
{
|
{
|
||||||
if (local _x) then {
|
if (local _x) then {
|
||||||
_type = typeOf _x;
|
_type = typeOf _x;
|
||||||
if (_index == 0 || (tolower _type) in _FilterArray) then {
|
if (_index == 0 || (tolower _type) in _FilterArray) then {
|
||||||
_itemCount = { typeOf _x == _type } count _vehicles;
|
_itemCount = { typeOf _x == _type } count _vehicles;
|
||||||
_itemOfferCount = { _x == _type } count _offerArray;
|
_itemOfferCount = { _x == _type } count _VehOfferArray;
|
||||||
if (_itemCount > _itemOfferCount) then {
|
if (_itemCount > _itemOfferCount) then {
|
||||||
_offerArray pushBack _type;
|
|
||||||
_config = configFile >> "CfgVehicles" >> _type;
|
_config = configFile >> "CfgVehicles" >> _type;
|
||||||
_name = getText(_config >> "displayName");
|
_name = getText(_config >> "displayName");
|
||||||
_picture = getText(_config >> "picture");
|
_picture = getText(_config >> "picture");
|
||||||
_id = lbAdd[41500, _name];
|
_id = lbAdd[_PlayerItemsBox, _name];
|
||||||
lbSetData[41500, _id, _type];
|
lbSetData[_PlayerItemsBox, _id, _type];
|
||||||
lbSetPicture[41500, _id, _picture];
|
lbSetValue [_PlayerItemsBox, _id, 1];
|
||||||
|
lbSetPicture[_PlayerItemsBox, _id, _picture];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} forEach _vehicles;
|
} forEach _vehicles;
|
||||||
_display = (findDisplay -8);
|
};
|
||||||
_control = (_display displayCtrl 41500);
|
lbsort ((findDisplay -8) displayCtrl _PlayerItemsBox);
|
||||||
lbsort _control;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lbClear 41503;
|
lbClear _TraderItemsBox;
|
||||||
_sizeOut = lbSize 41502;
|
if ((count EPOCH_NpcTradeTraderItems) == 2) then {
|
||||||
_offerArray = [];
|
_items = EPOCH_NpcTradeTraderItems select 0;
|
||||||
if (_sizeOut > 0) then {
|
_qtys = EPOCH_NpcTradeTraderItems select 1;
|
||||||
for "_i" from 0 to (_sizeOut - 1) do {
|
|
||||||
_id = lbData [41502, _i];
|
|
||||||
_offerArray pushBack _id;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
_aiItems = EPOCH_lastNPCtradeTarget getVariable["AI_ITEMS", []];
|
|
||||||
if ((count _aiItems) == 2) then {
|
|
||||||
_items = _aiItems select 0;
|
|
||||||
_qtys = _aiItems select 1;
|
|
||||||
_sortarray = [];
|
_sortarray = [];
|
||||||
{
|
{
|
||||||
_sortarray pushback [_x call EPOCH_itemDisplayName,_x,_qtys select _foreachindex];
|
_sortarray pushback [_x call EPOCH_itemDisplayName,_x,_qtys select _foreachindex];
|
||||||
} foreach _items;
|
} foreach _items;
|
||||||
_sortarray sort true;
|
_sortarray sort true;
|
||||||
|
|
||||||
{
|
{
|
||||||
_item = _x select 1;
|
_x params ["_displayname","_item","_rounds"];
|
||||||
|
|
||||||
if !(_item isequalto "") then {
|
if !(_item isequalto "") then {
|
||||||
if (_index == 0 || (tolower _item) in _FilterArray) then {
|
if (_index == 0 || (tolower _item) in _FilterArray) then {
|
||||||
_qty = ((_x select 2) - ({_x == _item} count _offerArray));
|
_maxrnd = 1;
|
||||||
|
_tooltip = "";
|
||||||
|
if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
|
||||||
|
};
|
||||||
|
_qty = (_rounds/_maxrnd);
|
||||||
|
if (_qty >= 1) then {
|
||||||
|
_qty = floor _qty;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_qty = ceil _qty;
|
||||||
|
_tooltip = format ["%1 rounds left in Magazine",_rounds];
|
||||||
|
};
|
||||||
if (_qty > 0) then {
|
if (_qty > 0) then {
|
||||||
_id = lnbAddRow[41503, ["", str(_qty),_x select 0]];
|
_id = lnbAddRow [_TraderItemsBox, ["", str(_qty),_displayname]];
|
||||||
lnbSetData [41503, [_id,0], _item];
|
lnbSetData [_TraderItemsBox, [_id,0], _item];
|
||||||
lnbSetValue [41503, [_id,0], _qty];
|
lnbSetValue [_TraderItemsBox, [_id,0], _rounds];
|
||||||
lnbSetPicture [41503, [_id,0], _item call EPOCH_itemPicture];
|
lnbSetPicture [_TraderItemsBox, [_id,0], _item call EPOCH_itemPicture];
|
||||||
|
if !(_tooltip isequalto "") then {
|
||||||
|
lbSetTooltip [_TraderItemsBox, _id*3, _tooltip];
|
||||||
|
lnbSetColor [_TraderItemsBox,[_id,2],[1,(_rounds/_maxrnd),0,1]];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
Author: Aaron Clark - EpochMod.com
|
Author: Aaron Clark - EpochMod.com
|
||||||
|
|
||||||
Contributors: He-Man
|
Contributors: He-Man - Ignatz-Gaming
|
||||||
|
|
||||||
Description:
|
Description:
|
||||||
NPC trade code
|
NPC trade code
|
||||||
@ -22,7 +22,7 @@
|
|||||||
NOTHING
|
NOTHING
|
||||||
*/
|
*/
|
||||||
//[[[cog import generate_private_arrays ]]]
|
//[[[cog import generate_private_arrays ]]]
|
||||||
private ["_addWeaponToHands","_arrayIn","_arrayOut","_config","_current_crypto","_errorMsg","_item","_itemTax","_itemWorth","_sizeOut","_tax","_type","_vehSlot","_vehicle","_vehicles"];
|
private ["_addWeaponToHands","_item","_type"];
|
||||||
//[[[end]]]
|
//[[[end]]]
|
||||||
params [["_returnIn",[]],["_returnOut",[]],["_message",""]];
|
params [["_returnIn",[]],["_returnOut",[]],["_message",""]];
|
||||||
|
|
||||||
@ -31,8 +31,9 @@ if (isNil "EPOCH_TRADE_STARTED") exitWith{};
|
|||||||
if !(_returnOut isEqualTo[]) then {
|
if !(_returnOut isEqualTo[]) then {
|
||||||
// add purchased items
|
// add purchased items
|
||||||
{
|
{
|
||||||
if ([_x, "CfgWeapons"] call EPOCH_fnc_isAny) then {
|
_x params ["_item","_count"];
|
||||||
_type = getNumber(configfile >> "CfgWeapons" >> (_x) >> "type");
|
if ([_item, "CfgWeapons"] call EPOCH_fnc_isAny) then {
|
||||||
|
_type = getNumber(configfile >> "CfgWeapons" >> _item >> "type");
|
||||||
_addWeaponToHands = false;
|
_addWeaponToHands = false;
|
||||||
switch (_type) do {
|
switch (_type) do {
|
||||||
case 1: {
|
case 1: {
|
||||||
@ -52,15 +53,15 @@ if !(_returnOut isEqualTo[]) then {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
if (_addWeaponToHands) then {
|
if (_addWeaponToHands) then {
|
||||||
player addWeapon _x;
|
player addWeapon _item;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_x call EPOCH_fnc_addItemOverflow;
|
_item call EPOCH_fnc_addItemOverflow;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ([_x, "CfgMagazines"] call EPOCH_fnc_isAny) then {
|
if ([_item, "CfgMagazines"] call EPOCH_fnc_isAny) then {
|
||||||
_x call EPOCH_fnc_addItemOverflow;
|
[_item,_count] call EPOCH_fnc_addMagazineOverflow;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} forEach _returnOut;
|
} forEach _returnOut;
|
||||||
@ -71,3 +72,4 @@ if !(_message isequalto "") then {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EPOCH_TRADE_STARTED = nil;
|
EPOCH_TRADE_STARTED = nil;
|
||||||
|
|
||||||
|
@ -1,39 +1,91 @@
|
|||||||
//[[[cog import generate_private_arrays ]]]
|
/*
|
||||||
private ["_errormsg","_aiItems","_allowAdd","_array","_config","_cryptoCount","_index","_item","_itemClasses","_itemQtys","_itemTax","_itemWorth","_limit","_qtyIndex","_sizeOut","_slot","_stockLimit","_tax","_uiItem","_worth"];
|
Author: He-Man - Ignatz-Gaming
|
||||||
//[[[end]]]
|
|
||||||
|
Contributors: Raimonds Virtoss
|
||||||
|
|
||||||
|
Description:
|
||||||
|
Move Items in Tradermenu between Playerinventory <-> PlayerOut window
|
||||||
|
|
||||||
|
Licence:
|
||||||
|
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
|
||||||
|
|
||||||
|
Github:
|
||||||
|
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/traders/EPOCH_npcTraderAdd.sqf
|
||||||
|
*/
|
||||||
|
|
||||||
|
private [ "_PlayerFilerDropDown","_PlayerItemsBox","_PlayerItemsOutBox","_TraderItemsOutBox","_CryptoInCtrl","_CryptoOutCtrl","_allowAdd","_uiItem","_rounds","_itemIcon","_itemColor","_errormsg","_stockLimit","_config",
|
||||||
|
"_itemClasses","_itemQtys","_qtyIndex","_limit","_sizeOut","_item","_vehicle","_itemName","_index","_maxrnd","_ItemIndex","_cryptoCount","_worth","_itemTax","_tax"
|
||||||
|
];
|
||||||
params ["_control","_selected"];
|
params ["_control","_selected"];
|
||||||
|
_selected params ["_CurControl","_id"];
|
||||||
|
|
||||||
|
_PlayerFilerDropDown = 42100;
|
||||||
|
_PlayerItemsBox = 41500;
|
||||||
|
_PlayerItemsOutBox = 41501;
|
||||||
|
_TraderItemsOutBox = 41502;
|
||||||
|
_CryptoInCtrl = 41004;
|
||||||
|
_CryptoOutCtrl = 41005;
|
||||||
|
|
||||||
if !(isNull EPOCH_lastNPCtradeTarget) then {
|
if !(isNull EPOCH_lastNPCtradeTarget) then {
|
||||||
|
|
||||||
_allowAdd = true;
|
_allowAdd = true;
|
||||||
|
_uiItem = _CurControl lbData _id;
|
||||||
|
_rounds = _CurControl lbValue _id;
|
||||||
|
_itemIcon = _CurControl lbPicture _id;
|
||||||
|
_itemColor = _CurControl lbColor _id;
|
||||||
|
_errormsg = "";
|
||||||
_stockLimit = false;
|
_stockLimit = false;
|
||||||
_uiItem = (_selected select 0) lbData (_selected select 1);
|
|
||||||
_errormsg = "Limit one per trade";
|
|
||||||
|
|
||||||
_config = 'CfgPricing' call EPOCH_returnConfig;
|
_config = 'CfgPricing' call EPOCH_returnConfig;
|
||||||
if (isClass (_config >> _uiItem)) then {
|
if (isClass (_config >> _uiItem)) then {
|
||||||
|
if (_control == _PlayerItemsOutBox) then {
|
||||||
if !(_control in[41500, 41503]) then {
|
_itemClasses = EPOCH_NpcTradeTraderItems select 0;
|
||||||
|
_itemQtys = EPOCH_NpcTradeTraderItems select 1;
|
||||||
// limit adding more if item is over stocked
|
|
||||||
if (_control == 41501) then {
|
|
||||||
_slot = EPOCH_lastNPCtradeTarget getVariable["AI_SLOT", -1];
|
|
||||||
_aiItems = EPOCH_lastNPCtradeTarget getVariable["AI_ITEMS", [[], []] ];
|
|
||||||
_itemClasses = _aiItems select 0;
|
|
||||||
_itemQtys = _aiItems select 1;
|
|
||||||
|
|
||||||
// find item and get current qty
|
|
||||||
_qtyIndex = _itemClasses find _uiItem;
|
_qtyIndex = _itemClasses find _uiItem;
|
||||||
if (_qtyIndex != -1) then {
|
if (_qtyIndex != -1) then {
|
||||||
|
_itemQty = _itemQtys select _qtyIndex;
|
||||||
|
_maxrnd = 1;
|
||||||
|
if ([_uiItem,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _uiItem >> "count");
|
||||||
|
};
|
||||||
|
_itemQty = _itemQty / _maxrnd;
|
||||||
|
_sizeIn = lbSize _PlayerItemsOutBox;
|
||||||
|
if (_sizeIn > 0) then {
|
||||||
|
for "_i" from 0 to (_sizeIn - 1) do {
|
||||||
|
_InItem = lbData [_PlayerItemsOutBox, _i];
|
||||||
|
if ((lbData [_PlayerItemsOutBox, _i]) == _uiItem) then {
|
||||||
|
_itemQty = _itemQty + ((lbValue [_PlayerItemsOutBox, _i])/_maxrnd);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
_limit = ["CfgTraderLimits", _uiItem, 100] call EPOCH_fnc_returnConfigEntryV2;
|
_limit = ["CfgTraderLimits", _uiItem, 100] call EPOCH_fnc_returnConfigEntryV2;
|
||||||
if (_itemQtys select _qtyIndex >= _limit) then{
|
if (_itemQty >= _limit) then{
|
||||||
_stockLimit = true;
|
_stockLimit = true;
|
||||||
_allowAdd = false;
|
_allowAdd = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
if (_uiItem isKindOf "Air" || _uiItem isKindOf "Ship" || _uiItem isKindOf "LandVehicle" || _uiItem isKindOf "Tank") then {
|
if (_uiItem isKindOf "Air" || _uiItem isKindOf "Ship" || _uiItem isKindOf "LandVehicle" || _uiItem isKindOf "Tank") then {
|
||||||
|
_sizeOut = lbSize _PlayerItemsOutBox;
|
||||||
|
if (_sizeOut > 0) then {
|
||||||
|
for "_i" from 0 to(_sizeOut - 1) do {
|
||||||
|
_item = lbData [_PlayerItemsOutBox, _i];
|
||||||
|
if (_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle" || _item isKindOf "Tank") exitWith{
|
||||||
|
_allowAdd = false;
|
||||||
|
_errormsg = "Limit one per trade";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
if (!_allowAdd) exitwith {};
|
||||||
|
_sizeOut = lbSize _TraderItemsOutBox;
|
||||||
|
if (_sizeOut > 0) then {
|
||||||
|
for "_i" from 0 to(_sizeOut - 1) do {
|
||||||
|
_item = lbData[_TraderItemsOutBox, _i];
|
||||||
|
if (_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle" || _item isKindOf "Tank") exitWith{
|
||||||
|
_allowAdd = false;
|
||||||
|
_errormsg = "Limit one per trade";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
if (!_allowAdd) exitwith {};
|
||||||
if (["CfgEpochClient", "DisallowSellOnDamage", false] call EPOCH_fnc_returnConfigEntryV2) then {
|
if (["CfgEpochClient", "DisallowSellOnDamage", false] call EPOCH_fnc_returnConfigEntryV2) then {
|
||||||
{
|
{
|
||||||
_vehicle = _x;
|
_vehicle = _x;
|
||||||
@ -51,71 +103,85 @@ if !(isNull EPOCH_lastNPCtradeTarget) then {
|
|||||||
if (!_allowAdd) exitwith {};
|
if (!_allowAdd) exitwith {};
|
||||||
} foreach (EPOCH_lastNPCtradeTarget nearEntities [[_uiItem], 30]);
|
} foreach (EPOCH_lastNPCtradeTarget nearEntities [[_uiItem], 30]);
|
||||||
};
|
};
|
||||||
|
|
||||||
// check if a vehicle is already on the list
|
|
||||||
_sizeOut = lbSize 41501;
|
|
||||||
if (_sizeOut > 0) then {
|
|
||||||
for "_i" from 0 to(_sizeOut - 1) do {
|
|
||||||
_item = lbData[41501, _i];
|
|
||||||
if (_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle" || _item isKindOf "Tank") exitWith{
|
|
||||||
_allowAdd = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
_sizeOut = lbSize 41502;
|
|
||||||
if (_sizeOut > 0) then {
|
|
||||||
for "_i" from 0 to(_sizeOut - 1) do {
|
|
||||||
_item = lbData[41502, _i];
|
|
||||||
if (_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle" || _item isKindOf "Tank") exitWith{
|
|
||||||
_allowAdd = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
// disallow adding item to list of already one
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_allowAdd) then {
|
if (_allowAdd) then {
|
||||||
_index = lbAdd[_control, ((_selected select 0) lbText(_selected select 1))];
|
_itemName = _CurControl lbText _id;
|
||||||
|
_index = lbAdd [_control, _itemName];
|
||||||
lbSetData [_control, _index, _uiItem];
|
lbSetData [_control, _index, _uiItem];
|
||||||
|
lbSetValue [_control,_index, _rounds];
|
||||||
lbSetPicture[_control, _index, ((_selected select 0) lbPicture(_selected select 1))];
|
lbSetPicture [_control, _index, _itemIcon];
|
||||||
(_selected select 0) lbDelete(_selected select 1);
|
lbSetColor [_control,_index,_itemColor];
|
||||||
|
if (_control == _PlayerItemsBox && !(_uiItem iskindof "Landvehicle" || _uiItem iskindof "SHIP" || _uiItem iskindof "AIR" || _uiItem iskindof "TANK")) then {
|
||||||
|
EPOCH_NpcTradePlayerItems pushback [_uiItem,_rounds];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ([_uiItem,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _uiItem >> "count");
|
||||||
|
if !((_rounds/_maxrnd) >= 1) then {
|
||||||
|
_tooltip = format ["%1 rounds left in Magazine",_rounds];
|
||||||
|
lbSetTooltip [_control,_index,_tooltip];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
_ItemIndex = EPOCH_NpcTradePlayerItems find [_uiItem,_rounds];
|
||||||
|
if (_ItemIndex < 0) then {
|
||||||
|
_ItemIndex = EPOCH_NpcTradePlayerItems find _uiItem;
|
||||||
|
};
|
||||||
|
if (_ItemIndex > -1) then {
|
||||||
|
EPOCH_NpcTradePlayerItems deleteat _ItemIndex;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
_CurControl lbDelete _id;
|
||||||
_cryptoCount = 0;
|
_cryptoCount = 0;
|
||||||
_sizeOut = lbSize 41501;
|
_sizeOut = lbSize _PlayerItemsOutBox;
|
||||||
//_array = [];
|
|
||||||
if (_sizeOut > 0) then {
|
if (_sizeOut > 0) then {
|
||||||
for "_i" from 0 to (_sizeOut - 1) do {
|
for "_i" from 0 to (_sizeOut - 1) do {
|
||||||
_item = lbData[41501, _i];
|
_item = lbData [_PlayerItemsOutBox, _i];
|
||||||
//_array pushBack _item;
|
_rounds = lbValue [_PlayerItemsOutBox, _i];
|
||||||
_worth = getNumber (_config >> _item >> "price");
|
_worth = getNumber (_config >> _item >> "price");
|
||||||
|
_maxrnd = 1;
|
||||||
|
if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
|
||||||
|
};
|
||||||
|
_worth = round (_worth*(_rounds/_maxrnd));
|
||||||
_cryptoCount = _cryptoCount + _worth;
|
_cryptoCount = _cryptoCount + _worth;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
ctrlSetText[41004, (format["%1 Krypto", _cryptoCount])];
|
ctrlSetText [_CryptoInCtrl, (format["%1 Krypto", _cryptoCount])];
|
||||||
|
|
||||||
_cryptoCount = 0;
|
_cryptoCount = 0;
|
||||||
_sizeOut = lbSize 41502;
|
_sizeOut = lbSize _TraderItemsOutBox;
|
||||||
if (_sizeOut > 0) then {
|
if (_sizeOut > 0) then {
|
||||||
for "_i" from 0 to (_sizeOut - 1) do {
|
for "_i" from 0 to (_sizeOut - 1) do {
|
||||||
_item = lbData[41502, _i];
|
_item = lbData [_TraderItemsOutBox, _i];
|
||||||
_itemWorth = getNumber(_config >> _item >> "price");
|
_rounds = lbValue [_TraderItemsOutBox, _i];
|
||||||
|
_worth = getNumber (_config >> _item >> "price");
|
||||||
_itemTax = getNumber (_config >> _item >> "tax");
|
_itemTax = getNumber (_config >> _item >> "tax");
|
||||||
_tax = _itemWorth * (EPOCH_taxRate + _itemTax);
|
_tax = _worth * (EPOCH_taxRate + _itemTax);
|
||||||
_itemWorth = ceil(_itemWorth + _tax);
|
_worth = ceil(_worth + _tax);
|
||||||
_cryptoCount = _cryptoCount + _itemWorth;
|
_maxrnd = 1;
|
||||||
|
if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
|
||||||
|
};
|
||||||
|
_worth = round (_worth*(_rounds/_maxrnd));
|
||||||
|
_cryptoCount = _cryptoCount + _worth;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
ctrlSetText[41005, (format["%1 Krypto", _cryptoCount])];
|
ctrlSetText [_CryptoOutCtrl, (format["%1 Krypto", _cryptoCount])];
|
||||||
} else {
|
if (_control == _PlayerItemsBox) then {
|
||||||
|
lbSetCurSel [_PlayerFilerDropDown, 0];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (_stockLimit) then{
|
if (_stockLimit) then{
|
||||||
["Trader has the maximum amount of this item", 5] call Epoch_message;
|
["Trader has the maximum amount of this item", 5] call Epoch_message;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
[_errormsg, 5] call Epoch_message;
|
[_errormsg, 5] call Epoch_message;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
closeDialog 0;
|
closeDialog 0;
|
||||||
};
|
};
|
||||||
|
@ -1,88 +1,156 @@
|
|||||||
//[[[cog import generate_private_arrays ]]]
|
/*
|
||||||
private ["_allowAdd","_array","_config","_cryptoCount","_index","_item","_itemIcon","_itemName","_itemTax","_itemWorth","_qty","_sizeOut","_tax","_uiItem","_uiQty","_worth"];
|
Author: He-Man - Ignatz-Gaming
|
||||||
//[[[end]]]
|
|
||||||
|
Contributors: Raimonds Virtoss
|
||||||
|
|
||||||
|
Description:
|
||||||
|
Move Items in Tradermenu from Traderinventory to TraderOut window
|
||||||
|
|
||||||
|
Licence:
|
||||||
|
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
|
||||||
|
|
||||||
|
Github:
|
||||||
|
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/traders/EPOCH_npcTraderAdd2.sqf
|
||||||
|
*/
|
||||||
|
|
||||||
|
private [ "_PlayerItemsOutBox","_TraderItemsBox","_TraderItemsOutBox","_CryptoInCtrl","_CryptoOutCtrl","_allowAdd","_uiItem","_rounds","_itemIcon","_itemName","_itemColor","_errormsg","_soldrounds","_tooltip","_config",
|
||||||
|
"_ItemIndex","_sizeOut","_item","_maxrnd","_uiQty","_index","_cryptoCount","_worth","_itemTax","_tax"
|
||||||
|
];
|
||||||
params ["_control","_selected"];
|
params ["_control","_selected"];
|
||||||
|
_selected params ["_CurControl","_id"];
|
||||||
|
|
||||||
|
_PlayerItemsOutBox = 41501;
|
||||||
|
_TraderItemsBox = 41503;
|
||||||
|
_TraderItemsOutBox = 41502;
|
||||||
|
_CryptoInCtrl = 41004;
|
||||||
|
_CryptoOutCtrl = 41005;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if !(isNull EPOCH_lastNPCtradeTarget) then {
|
||||||
_allowAdd = true;
|
_allowAdd = true;
|
||||||
|
_uiItem = _CurControl lnbData [_id, 0];
|
||||||
|
_rounds = _CurControl lnbValue [_id, 0];
|
||||||
|
_itemIcon = _CurControl lnbPicture [_id, 0];
|
||||||
|
_itemName = _CurControl lnbText [_id, 2];
|
||||||
|
_itemColor = _CurControl lnbColor [_id, 2];
|
||||||
|
_errormsg = "";
|
||||||
|
_soldrounds = 0;
|
||||||
|
_tooltip = "";
|
||||||
|
|
||||||
_uiItem = (_selected select 0) lnbData[(_selected select 1), 0];
|
|
||||||
|
|
||||||
_config = 'CfgPricing' call EPOCH_returnConfig;
|
_config = 'CfgPricing' call EPOCH_returnConfig;
|
||||||
if (isClass (_config >> _uiItem)) then{
|
if (isClass (_config >> _uiItem)) then{
|
||||||
|
_ItemIndex = (EPOCH_NpcTradeTraderItems select 0) find _uiItem;
|
||||||
|
if (_ItemIndex > -1) then {
|
||||||
if (_uiItem isKindOf "Air" || _uiItem isKindOf "Ship" || _uiItem isKindOf "LandVehicle" || _uiItem isKindOf "Tank") then {
|
if (_uiItem isKindOf "Air" || _uiItem isKindOf "Ship" || _uiItem isKindOf "LandVehicle" || _uiItem isKindOf "Tank") then {
|
||||||
|
_sizeOut = lbSize _PlayerItemsOutBox;
|
||||||
// check if a vehicle is already on the list
|
|
||||||
_sizeOut = lbSize 41501;
|
|
||||||
//_array = [];
|
|
||||||
if (_sizeOut > 0) then {
|
if (_sizeOut > 0) then {
|
||||||
for "_i" from 0 to(_sizeOut - 1) do {
|
for "_i" from 0 to(_sizeOut - 1) do {
|
||||||
_item = lbData[41501, _i];
|
_item = lbData [_PlayerItemsOutBox, _i];
|
||||||
//_array pushBack _item;
|
|
||||||
if (_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle" || _item isKindOf "Tank") exitWith{
|
if (_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle" || _item isKindOf "Tank") exitWith{
|
||||||
_allowAdd = false;
|
_allowAdd = false;
|
||||||
|
_errormsg = "Limit one per trade";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
_sizeOut = lbSize 41502;
|
if (!_allowAdd) exitwith {};
|
||||||
//_array = [];
|
_sizeOut = lbSize _TraderItemsOutBox;
|
||||||
if (_sizeOut > 0) then {
|
if (_sizeOut > 0) then {
|
||||||
for "_i" from 0 to(_sizeOut - 1) do {
|
for "_i" from 0 to(_sizeOut - 1) do {
|
||||||
_item = lbData[41502, _i];
|
_item = lbData [_TraderItemsOutBox, _i];
|
||||||
if (_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle" || _item isKindOf "Tank") exitWith{
|
if (_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle" || _item isKindOf "Tank") exitWith{
|
||||||
_allowAdd = false;
|
_allowAdd = false;
|
||||||
|
_errormsg = "Limit one per trade";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
// disallow adding item to list of already one
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_allowAdd) then {
|
if (_allowAdd) then {
|
||||||
_itemName = (_selected select 0) lnbText[(_selected select 1), 2];
|
_maxrnd = 1;
|
||||||
|
if ([_uiItem,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _uiItem >> "count");
|
||||||
|
};
|
||||||
|
if ((_rounds/_maxrnd) >= 1) then {
|
||||||
|
_soldrounds = _maxrnd;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_soldrounds = _rounds;
|
||||||
|
};
|
||||||
|
_rounds = _rounds - _soldrounds;
|
||||||
|
if (_rounds < 1) then {
|
||||||
|
_CurControl lnbDeleteRow _id;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_uiQty = _rounds /_maxrnd;
|
||||||
|
if (_uiQty >= 1) then {
|
||||||
|
_uiQty = floor _uiQty;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_uiQty = ceil _uiQty;
|
||||||
|
_tooltip = format ["%1 rounds left in Magazine",_rounds];
|
||||||
|
};
|
||||||
|
lnbSetText [_TraderItemsBox, [_id, 1], str (_uiQty)];
|
||||||
|
lnbSetValue [_TraderItemsBox, [_id, 0], _rounds];
|
||||||
|
if !(_tooltip isequalto "") then {
|
||||||
|
lbSetTooltip [_TraderItemsBox, _id*3, _tooltip];
|
||||||
|
lnbSetColor [_TraderItemsBox,[_id,2],[1,(_rounds/_maxrnd),0,1]];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
if (_soldrounds > 0) then {
|
||||||
_index = lbAdd [_control, _itemName];
|
_index = lbAdd [_control, _itemName];
|
||||||
lbSetData [_control, _index, _uiItem];
|
lbSetData [_control, _index, _uiItem];
|
||||||
|
lbSetValue [_control,_index, _soldrounds];
|
||||||
_itemIcon = (_selected select 0) lnbPicture [(_selected select 1), 0];
|
|
||||||
lbSetPicture [_control, _index, _itemIcon];
|
lbSetPicture [_control, _index, _itemIcon];
|
||||||
|
lbSetColor [_control,_index,_itemColor];
|
||||||
_uiQty = (_selected select 0) lnbValue [(_selected select 1), 0];
|
if ([_uiItem,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
if (_uiQty <= 1) then {
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _uiItem >> "count");
|
||||||
(_selected select 0) lnbDeleteRow (_selected select 1);
|
if !((_soldrounds/_maxrnd) >= 1) then {
|
||||||
} else {
|
_tooltip = format ["%1 rounds left in Magazine",_soldrounds];
|
||||||
_qty = _uiQty - 1;
|
lbSetTooltip [_control,_index,_tooltip];
|
||||||
lnbSetText[41503, [(_selected select 1), 1], str(_qty)];
|
|
||||||
lnbSetValue[41503, [(_selected select 1), 0], _qty];
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
(EPOCH_NpcTradeTraderItems select 1) set [_ItemIndex,_rounds];
|
||||||
_cryptoCount = 0;
|
_cryptoCount = 0;
|
||||||
_sizeOut = lbSize 41501;
|
_sizeOut = lbSize _PlayerItemsOutBox;
|
||||||
//_array = [];
|
|
||||||
if (_sizeOut > 0) then {
|
if (_sizeOut > 0) then {
|
||||||
for "_i" from 0 to (_sizeOut - 1) do {
|
for "_i" from 0 to (_sizeOut - 1) do {
|
||||||
_item = lbData [41501, _i];
|
_item = lbData [_PlayerItemsOutBox, _i];
|
||||||
//_array pushBack _item;
|
_rounds = lbValue [_PlayerItemsOutBox, _i];
|
||||||
_worth = getNumber (_config >> _item >> "price");
|
_worth = getNumber (_config >> _item >> "price");
|
||||||
|
_maxrnd = 1;
|
||||||
|
if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
|
||||||
|
};
|
||||||
|
_worth = round (_worth*(_rounds/_maxrnd));
|
||||||
_cryptoCount = _cryptoCount + _worth;
|
_cryptoCount = _cryptoCount + _worth;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
ctrlSetText [41004, (format ["%1 Krypto", _cryptoCount])];
|
ctrlSetText [_CryptoInCtrl, (format["%1 Krypto", _cryptoCount])];
|
||||||
|
|
||||||
_cryptoCount = 0;
|
_cryptoCount = 0;
|
||||||
_sizeOut = lbSize 41502;
|
_sizeOut = lbSize _TraderItemsOutBox;
|
||||||
if (_sizeOut > 0) then {
|
if (_sizeOut > 0) then {
|
||||||
for "_i" from 0 to (_sizeOut - 1) do {
|
for "_i" from 0 to (_sizeOut - 1) do {
|
||||||
_item = lbData [41502, _i];
|
_item = lbData [_TraderItemsOutBox, _i];
|
||||||
_itemWorth = getNumber(_config >> _item >> "price");
|
_rounds = lbValue [_TraderItemsOutBox, _i];
|
||||||
|
_worth = getNumber (_config >> _item >> "price");
|
||||||
_itemTax = getNumber (_config >> _item >> "tax");
|
_itemTax = getNumber (_config >> _item >> "tax");
|
||||||
_tax = _itemWorth * (EPOCH_taxRate + _itemTax);
|
_tax = _worth * (EPOCH_taxRate + _itemTax);
|
||||||
_itemWorth = ceil(_itemWorth + _tax);
|
_worth = ceil(_worth + _tax);
|
||||||
_cryptoCount = _cryptoCount + _itemWorth;
|
_maxrnd = 1;
|
||||||
|
if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
|
||||||
|
};
|
||||||
|
_worth = round (_worth*(_rounds/_maxrnd));
|
||||||
|
_cryptoCount = _cryptoCount + _worth;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
ctrlSetText [41005, (format ["%1 Krypto", _cryptoCount])];
|
ctrlSetText [_CryptoOutCtrl, (format["%1 Krypto", _cryptoCount])];
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
["Limit one per trade", 5] call Epoch_message;
|
["Limit one per trade", 5] call Epoch_message;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
@ -1,41 +1,72 @@
|
|||||||
//[[[cog import generate_private_arrays ]]]
|
/*
|
||||||
private ["_array","_config","_cryptoCount","_item","_itemTax","_itemWorth","_sizeOut","_tax","_uiItem","_worth"];
|
Author: He-Man - Ignatz-Gaming
|
||||||
//[[[end]]]
|
|
||||||
params ["_control","_selected"];
|
|
||||||
|
|
||||||
_uiItem = (_selected select 0) lbData(_selected select 1);
|
Contributors: Raimonds Virtoss
|
||||||
|
|
||||||
|
Description:
|
||||||
|
Move Items in Tradermenu from TraderOut window to Traderinventory
|
||||||
|
|
||||||
|
Licence:
|
||||||
|
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
|
||||||
|
|
||||||
|
Github:
|
||||||
|
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/traders/EPOCH_npcTraderAdd3.sqf
|
||||||
|
*/
|
||||||
|
|
||||||
|
private ["_TraderFilerDropDown","_PlayerItemsOutBox","_TraderItemsOutBox","_CryptoInCtrl","_CryptoOutCtrl","_uiItem","_rounds","_config","_ItemIndex","_cryptoCount","_sizeOut","_item","_worth","_maxrnd","_itemTax","_tax"];
|
||||||
|
params ["_control","_selected"];
|
||||||
|
_selected params ["_CurControl","_id"];
|
||||||
|
|
||||||
|
_TraderFilerDropDown = 42101;
|
||||||
|
_PlayerItemsOutBox = 41501;
|
||||||
|
_TraderItemsOutBox = 41502;
|
||||||
|
_CryptoInCtrl = 41004;
|
||||||
|
_CryptoOutCtrl = 41005;
|
||||||
|
|
||||||
|
_uiItem = _CurControl lbData _id;
|
||||||
|
_rounds = _CurControl lbValue _id;
|
||||||
|
|
||||||
_config = 'CfgPricing' call EPOCH_returnConfig;
|
_config = 'CfgPricing' call EPOCH_returnConfig;
|
||||||
if (isClass (_config >> _uiItem)) then {
|
if (isClass (_config >> _uiItem)) then {
|
||||||
|
_ItemIndex = (EPOCH_NpcTradeTraderItems select 0) find _uiItem;
|
||||||
(_selected select 0) lbDelete (_selected select 1);
|
if (_ItemIndex >= 0) then {
|
||||||
|
(EPOCH_NpcTradeTraderItems select 1) set [_ItemIndex,(EPOCH_NpcTradeTraderItems select 1 select _ItemIndex) + _rounds];
|
||||||
lbSetCurSel[42101, 0];
|
};
|
||||||
|
_CurControl lbDelete _id;
|
||||||
|
lbSetCurSel [_TraderFilerDropDown, 0];
|
||||||
_cryptoCount = 0;
|
_cryptoCount = 0;
|
||||||
_sizeOut = lbSize 41501;
|
_sizeOut = lbSize _PlayerItemsOutBox;
|
||||||
//_array = [];
|
|
||||||
if (_sizeOut > 0) then {
|
if (_sizeOut > 0) then {
|
||||||
for "_i" from 0 to (_sizeOut - 1) do {
|
for "_i" from 0 to (_sizeOut - 1) do {
|
||||||
_item = lbData [41501, _i];
|
_item = lbData [_PlayerItemsOutBox, _i];
|
||||||
//_array pushBack _item;
|
_rounds = lbValue [_PlayerItemsOutBox, _i];
|
||||||
_worth = getNumber (_config >> _item >> "price");
|
_worth = getNumber (_config >> _item >> "price");
|
||||||
|
_maxrnd = 1;
|
||||||
|
if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
|
||||||
|
};
|
||||||
|
_worth = round (_worth*(_rounds/_maxrnd));
|
||||||
_cryptoCount = _cryptoCount + _worth;
|
_cryptoCount = _cryptoCount + _worth;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
ctrlSetText [41004, (format ["%1 Krypto", _cryptoCount])];
|
ctrlSetText [_CryptoInCtrl, (format["%1 Krypto", _cryptoCount])];
|
||||||
|
|
||||||
_cryptoCount = 0;
|
_cryptoCount = 0;
|
||||||
_sizeOut = lbSize 41502;
|
_sizeOut = lbSize _TraderItemsOutBox;
|
||||||
if (_sizeOut > 0) then {
|
if (_sizeOut > 0) then {
|
||||||
for "_i" from 0 to (_sizeOut - 1) do {
|
for "_i" from 0 to (_sizeOut - 1) do {
|
||||||
_item = lbData [41502, _i];
|
_item = lbData [_TraderItemsOutBox, _i];
|
||||||
_itemWorth = getNumber(_config >> _item >> "price");
|
_rounds = lbValue [_TraderItemsOutBox, _i];
|
||||||
|
_worth = getNumber (_config >> _item >> "price");
|
||||||
_itemTax = getNumber (_config >> _item >> "tax");
|
_itemTax = getNumber (_config >> _item >> "tax");
|
||||||
_tax = _itemWorth * (EPOCH_taxRate + _itemTax);
|
_tax = _worth * (EPOCH_taxRate + _itemTax);
|
||||||
_itemWorth = ceil(_itemWorth + _tax);
|
_worth = ceil (_worth + _tax);
|
||||||
_cryptoCount = _cryptoCount + _itemWorth;
|
_maxrnd = 1;
|
||||||
|
if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
|
||||||
|
};
|
||||||
|
_worth = round (_worth*(_rounds/_maxrnd));
|
||||||
|
_cryptoCount = _cryptoCount + _worth;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
ctrlSetText [41005, (format ["%1 Krypto", _cryptoCount])];
|
ctrlSetText [_CryptoOutCtrl, (format["%1 Krypto", _cryptoCount])];
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,19 @@
|
|||||||
//[[[cog import generate_private_arrays ]]]
|
/*
|
||||||
private ["_MainCategoriearray","_categorie","_config","_ok","_slot","_target"];
|
Author: He-Man - Ignatz-Gaming
|
||||||
//[[[end]]]
|
|
||||||
|
Contributors: Raimonds Virtoss
|
||||||
|
|
||||||
|
Description:
|
||||||
|
Start the Trader Trading Menu
|
||||||
|
|
||||||
|
Licence:
|
||||||
|
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
|
||||||
|
|
||||||
|
Github:
|
||||||
|
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/traders/EPOCH_startNPCTraderMenu.sqf
|
||||||
|
*/
|
||||||
|
|
||||||
|
private ["_config","_MainCategoriearray","_target","_slot","_index","_ok","_categorie"];
|
||||||
_config = 'CfgItemSort' call EPOCH_returnConfig;
|
_config = 'CfgItemSort' call EPOCH_returnConfig;
|
||||||
_MainCategoriearray = getarray (_config >> "MainCategories" >> "Classes");
|
_MainCategoriearray = getarray (_config >> "MainCategories" >> "Classes");
|
||||||
_target = cursorTarget;
|
_target = cursorTarget;
|
||||||
@ -8,6 +21,20 @@ if (alive _target) then {
|
|||||||
_slot = _target getVariable ["AI_SLOT",-1];
|
_slot = _target getVariable ["AI_SLOT",-1];
|
||||||
if (_slot != -1) then {
|
if (_slot != -1) then {
|
||||||
EPOCH_lastNPCtradeTarget = _target;
|
EPOCH_lastNPCtradeTarget = _target;
|
||||||
|
EPOCH_NpcTradePlayerItems = (items player)+(magazinesammo player);
|
||||||
|
if (primaryWeapon player != "") then {
|
||||||
|
EPOCH_NpcTradePlayerItems pushback primaryWeapon player;
|
||||||
|
};
|
||||||
|
if (count backpackItems player == 0 && count backpackmagazines player == 0 && backpack player != "") then {
|
||||||
|
EPOCH_NpcTradePlayerItems pushback backpack player;
|
||||||
|
};
|
||||||
|
EPOCH_NpcTradeTraderItems = [[],[]];
|
||||||
|
{
|
||||||
|
_index = _foreachindex;
|
||||||
|
{
|
||||||
|
(EPOCH_NpcTradeTraderItems select _index) pushback _x;
|
||||||
|
} foreach _x
|
||||||
|
} foreach (_target getvariable ["AI_Items",[[],[]]]);
|
||||||
closeDialog 0;
|
closeDialog 0;
|
||||||
_ok = createdialog "TradeNPCMenu";
|
_ok = createdialog "TradeNPCMenu";
|
||||||
if (!_ok) exitWith {};
|
if (!_ok) exitWith {};
|
||||||
|
@ -1,65 +1,64 @@
|
|||||||
/*
|
/*
|
||||||
Author: Aaron Clark - EpochMod.com
|
Author: He-Man - Ignatz-Gaming
|
||||||
|
|
||||||
Contributors: He-Man
|
Contributors: Raimonds Virtoss
|
||||||
|
|
||||||
Description:
|
Description:
|
||||||
NPC trade code
|
Move Items in Tradermenu from TraderOut window to Traderinventory
|
||||||
|
|
||||||
Licence:
|
Licence:
|
||||||
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
|
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
|
||||||
|
|
||||||
Github:
|
Github:
|
||||||
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/traders/EPOCH_startNpcTrade.sqf
|
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/traders/EPOCH_startNpcTrade.sqf
|
||||||
|
|
||||||
Example:
|
|
||||||
cursorTarget call EPOCH_startNpcTrade;
|
|
||||||
|
|
||||||
Parameter(s):
|
|
||||||
_this: OBJECT
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
NOTHING
|
|
||||||
*/
|
*/
|
||||||
//[[[cog import generate_private_arrays ]]]
|
|
||||||
private ["_addWeaponToHands","_arrayIn","_arrayOut","_config","_current_crypto","_errorMsg","_item","_itemTax","_itemWorth","_sizeOut","_tax","_type","_vehSlot","_vehicle","_vehicles"];
|
private ["_PlayerItemsOutBox","_TraderItemsOutBox","_config","_current_crypto","_sizeIn","_arrayIn","_item","_rounds","_mags","_itemMags","_index","_sizeOut","_arrayOut","_itemWorth","_itemTax","_tax","_maxrnd"];
|
||||||
//[[[end]]]
|
|
||||||
|
|
||||||
if (!isNil "EPOCH_TRADE_STARTED") exitWith{};
|
if (!isNil "EPOCH_TRADE_STARTED") exitWith{};
|
||||||
if (isNull _this) exitWith{};
|
if (isNull _this) exitWith{};
|
||||||
|
|
||||||
if (alive _this) then {
|
if (alive _this) then {
|
||||||
|
_PlayerItemsOutBox = 41501;
|
||||||
|
_TraderItemsOutBox = 41502;
|
||||||
_config = 'CfgPricing' call EPOCH_returnConfig;
|
_config = 'CfgPricing' call EPOCH_returnConfig;
|
||||||
|
|
||||||
_current_crypto = EPOCH_playerCrypto;
|
_current_crypto = EPOCH_playerCrypto;
|
||||||
|
_sizeIn = lbSize _PlayerItemsOutBox;
|
||||||
// _arrayIn = Sell Array
|
|
||||||
_sizeOut = lbSize 41501;
|
|
||||||
_arrayIn = [];
|
_arrayIn = [];
|
||||||
if (_sizeOut > 0) then {
|
if (_sizeIn > 0) then {
|
||||||
for "_i" from 0 to(_sizeOut - 1) do {
|
for "_i" from 0 to (_sizeIn - 1) do {
|
||||||
_item = lbData[41501, _i];
|
_item = lbData [_PlayerItemsOutBox, _i];
|
||||||
|
_rounds = lbValue [_PlayerItemsOutBox, _i];
|
||||||
if (isClass (_config >> _item)) then{
|
if (isClass (_config >> _item)) then{
|
||||||
|
_itemWorth = getNumber (_config >> _item >> "price");
|
||||||
// test remove items to be sold and add to array
|
_maxrnd = 1;
|
||||||
|
if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
|
||||||
|
};
|
||||||
|
_itemWorth = round (_itemWorth*(_rounds/_maxrnd));
|
||||||
|
_added = false;
|
||||||
if ([_item, "CfgWeapons"] call EPOCH_fnc_isAny) then {
|
if ([_item, "CfgWeapons"] call EPOCH_fnc_isAny) then {
|
||||||
if (_item in items player) then {
|
if (_item in items player) then {
|
||||||
player removeItem _item;
|
player removeItem _item;
|
||||||
_arrayIn pushBack _item;
|
_arrayIn pushBack [_item,_rounds];
|
||||||
} else {
|
_added = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (_item == primaryweapon player) then {
|
if (_item == primaryweapon player) then {
|
||||||
player removeweapon _item;
|
player removeweapon _item;
|
||||||
_arrayIn pushBack _item;
|
_arrayIn pushBack [_item,_rounds];
|
||||||
|
_added = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if ([_item, "CfgVehicles"] call EPOCH_fnc_isAny) then {
|
if ([_item, "CfgVehicles"] call EPOCH_fnc_isAny) then {
|
||||||
if (_item == backpack player) then {
|
if (_item == backpack player) then {
|
||||||
removeBackpack player;
|
removeBackpack player;
|
||||||
_arrayIn pushBack _item;
|
_arrayIn pushBack [_item,_rounds];
|
||||||
} else {
|
_added = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
_vehicles = _this nearEntities[[_item], 30];
|
_vehicles = _this nearEntities[[_item], 30];
|
||||||
if (!(_vehicles isEqualTo[])) then {
|
if (!(_vehicles isEqualTo[])) then {
|
||||||
_vehicle = _vehicles select 0;
|
_vehicle = _vehicles select 0;
|
||||||
@ -67,56 +66,66 @@ if (alive _this) then {
|
|||||||
if (local _vehicle) then {
|
if (local _vehicle) then {
|
||||||
_vehSlot = _vehicle getVariable["VEHICLE_SLOT", "ABORT"];
|
_vehSlot = _vehicle getVariable["VEHICLE_SLOT", "ABORT"];
|
||||||
if (_vehSlot != "ABORT") then {
|
if (_vehSlot != "ABORT") then {
|
||||||
_arrayIn pushBack _item;
|
_arrayIn pushBack [_item,_rounds];
|
||||||
// will be removed server side
|
_added = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} else {
|
}
|
||||||
if (_item in magazines player) then {
|
else {
|
||||||
player removeMagazine _item;
|
_mags = magazinesAmmo player;
|
||||||
_arrayIn pushBack _item;
|
_itemMags = [];
|
||||||
|
{
|
||||||
|
_x params ["_className","_count"];
|
||||||
|
if (_className isequalto _item) then {
|
||||||
|
_itemMags pushBack _x;
|
||||||
|
};
|
||||||
|
} forEach _mags;
|
||||||
|
_index = _itemMags find [_item,_rounds];
|
||||||
|
if (_index >= 0) then {
|
||||||
|
_arrayIn pushback (_itemMags deleteat _index);
|
||||||
|
_added = true;
|
||||||
|
player removemagazines _item;
|
||||||
|
{
|
||||||
|
player addmagazine _x;
|
||||||
|
} foreach _itemMags;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
// test
|
if (_added) then {
|
||||||
|
_current_crypto = _current_crypto + _itemWorth;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
// _arrayOut = Purchase Array
|
_sizeOut = lbSize _TraderItemsOutBox;
|
||||||
_sizeOut = lbSize 41502;
|
|
||||||
_arrayOut = [];
|
_arrayOut = [];
|
||||||
if (_sizeOut > 0) then {
|
if (_sizeOut > 0) then {
|
||||||
for "_i" from 0 to (_sizeOut - 1) do {
|
for "_i" from 0 to (_sizeOut - 1) do {
|
||||||
_item = lbData[41502, _i];
|
_item = lbData [_TraderItemsOutBox, _i];
|
||||||
|
_rounds = lbValue [_TraderItemsOutBox, _i];
|
||||||
if (isClass (_config >> _item)) then {
|
if (isClass (_config >> _item)) then {
|
||||||
_itemWorth = getNumber(_config >> "price");
|
_itemWorth = getNumber (_config >> _item >> "price");
|
||||||
_itemTax = getNumber(_config >> "tax");
|
_itemTax = getNumber (_config >> _item >> "tax");
|
||||||
_tax = _itemWorth * (EPOCH_taxRate + _itemTax);
|
_tax = _itemWorth * (EPOCH_taxRate + _itemTax);
|
||||||
_itemWorth = ceil (_itemWorth + _tax);
|
_itemWorth = ceil (_itemWorth + _tax);
|
||||||
|
_maxrnd = 1;
|
||||||
|
if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
|
||||||
|
};
|
||||||
|
_itemWorth = round (_itemWorth*(_rounds/_maxrnd));
|
||||||
if (_current_crypto >= _itemWorth) then {
|
if (_current_crypto >= _itemWorth) then {
|
||||||
_current_crypto = _current_crypto - _itemWorth;
|
_current_crypto = _current_crypto - _itemWorth;
|
||||||
_arrayOut pushBack _item;
|
_arrayOut pushBack [_item,_rounds];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
if !(_arrayIn isEqualTo[] && _arrayOut isEqualTo[]) then {
|
||||||
if (!(_arrayIn isEqualTo[]) || !(_arrayOut isEqualTo[])) then {
|
|
||||||
EPOCH_TRADE_STARTED = true;
|
EPOCH_TRADE_STARTED = true;
|
||||||
|
|
||||||
// make trade
|
|
||||||
[_this, _arrayIn, _arrayOut, player, Epoch_personalToken] remoteExec ["EPOCH_server_makeNPCTrade",2];
|
[_this, _arrayIn, _arrayOut, player, Epoch_personalToken] remoteExec ["EPOCH_server_makeNPCTrade",2];
|
||||||
|
|
||||||
// close menu
|
|
||||||
closeDialog 0;
|
closeDialog 0;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
disableSerialization;
|
|
||||||
//[[[cog import generate_private_arrays ]]]
|
|
||||||
private ["_array","_filterArray","_item","_items","_magazines","_sizeOut","_weapons","_xIndex"];
|
|
||||||
//[[[end]]]
|
|
||||||
params ["_control","_index"];
|
|
||||||
|
|
||||||
// [weapons, mags, items]
|
|
||||||
_filterArray = [
|
|
||||||
[true,true,true], // all
|
|
||||||
// [true,false,false], // weapons only
|
|
||||||
[false,true,false], // mags only
|
|
||||||
[false,false,true] // items only
|
|
||||||
];
|
|
||||||
|
|
||||||
lbClear 1500;
|
|
||||||
|
|
||||||
// _weapons = ((_filterArray select _index) select 0);
|
|
||||||
_magazines = ((_filterArray select _index) select 1);
|
|
||||||
_items = ((_filterArray select _index) select 2);
|
|
||||||
|
|
||||||
_sizeOut = lbSize 1501;
|
|
||||||
_array = [];
|
|
||||||
if (_sizeOut > 0) then {
|
|
||||||
for "_i" from 0 to (_sizeOut - 1) do {
|
|
||||||
_item = lbData [1501, _i];
|
|
||||||
_array pushBack _item;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/*
|
|
||||||
if (_weapons) then {
|
|
||||||
{
|
|
||||||
if !(_x in _array) then {
|
|
||||||
_xIndex = lbAdd [1500, _x call EPOCH_itemDisplayName];
|
|
||||||
lbSetData [1500, _xIndex, _x];
|
|
||||||
lbSetPicture [1500, _xIndex, _x call EPOCH_itemPicture];
|
|
||||||
} else {
|
|
||||||
_array set [_array find _x,nil];
|
|
||||||
};
|
|
||||||
} forEach weapons player;
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
if (_magazines) then {
|
|
||||||
{
|
|
||||||
if (getNumber(configfile >> "CfgMagazines" >> _x >> "count") == 1) then {
|
|
||||||
if !(_x in _array) then {
|
|
||||||
_xIndex = lbAdd[1500, _x call EPOCH_itemDisplayName];
|
|
||||||
lbSetData[1500, _xIndex, _x];
|
|
||||||
lbSetPicture[1500, _xIndex, _x call EPOCH_itemPicture];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_array set[_array find _x, nil];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
} forEach magazines player;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (_items) then {
|
|
||||||
{
|
|
||||||
if !(_x in _array) then {
|
|
||||||
_xIndex = lbAdd [1500, _x call EPOCH_itemDisplayName];
|
|
||||||
lbSetData [1500, _xIndex, _x];
|
|
||||||
lbSetPicture [1500, _xIndex, _x call EPOCH_itemPicture];
|
|
||||||
} else {
|
|
||||||
_array set [_array find _x,nil];
|
|
||||||
};
|
|
||||||
} forEach items player;
|
|
||||||
};
|
|
@ -79,7 +79,6 @@ class CfgClientFunctions
|
|||||||
class startNPCTraderMenu {};
|
class startNPCTraderMenu {};
|
||||||
class NPCTraderMenuFilter {};
|
class NPCTraderMenuFilter {};
|
||||||
class startNpcTrade {};
|
class startNpcTrade {};
|
||||||
class tradeFilter {};
|
|
||||||
class takeCrypto {};
|
class takeCrypto {};
|
||||||
class startBankTransfer {};
|
class startBankTransfer {};
|
||||||
class calcDamageCost {};
|
class calcDamageCost {};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
Author: Aaron Clark - EpochMod.com
|
Author: Aaron Clark - EpochMod.com
|
||||||
|
|
||||||
Contributors:
|
Contributors: He-Man - Ignatz-Gaming
|
||||||
|
|
||||||
Description:
|
Description:
|
||||||
NPC trade mech
|
NPC trade mech
|
||||||
@ -12,9 +12,13 @@
|
|||||||
Github:
|
Github:
|
||||||
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_trading/EPOCH_server_makeNPCTrade.sqf
|
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_trading/EPOCH_server_makeNPCTrade.sqf
|
||||||
*/
|
*/
|
||||||
//[[[cog import generate_private_arrays ]]]
|
|
||||||
private ["_MaxBankDebit","_SkipOut","_VAL","_aiItems","_bankBalance","_bankData","_cIndex","_config","_currQty","_current_crypto","_current_cryptoRaw","_errorMsg","_final_location","_foundSmoke","_group","_helipad","_helipads","_item","_itemClasses","_itemQty","_itemQtys","_itemTax","_itemWorth","_itemsIn","_itemsOut","_lockOwner","_makeTradeIn","_message","_nearByHolder","_objHiveKey","_objOwner","_playerCryptoLimit","_playerGroup","_playerNetID","_playerUID","_position","_qtyIndex","_response","_return","_returnIn","_returnOut","_road","_serverSettingsConfig","_slot","_smoke","_tax","_tmpposition","_tradeIn","_tradeOut","_tradeQtyTotal","_tradeTotal","_vars","_vehHiveKey","_vehObj","_vehSlot","_vehicle","_vehicleBought","_vehicleSold","_vehicles","_vehslot","_wH","_wHPos","_wp","_kIndex","_playerCStats","_playerKarma","_playerKarmaAdj"];
|
private [ "_MaxBankDebit","_SkipOut","_VAL","_aiItems","_bankBalance","_bankData","_cIndex","_config","_currQty","_current_crypto","_current_cryptoRaw","_errorMsg","_final_location","_foundSmoke",
|
||||||
//[[[end]]]
|
"_group","_helipad","_helipads","_item","_itemClasses","_itemQty","_itemQtys","_itemTax","_itemWorth","_itemsIn","_itemsOut","_lockOwner","_makeTradeIn","_message","_nearByHolder",
|
||||||
|
"_objHiveKey","_objOwner","_playerCryptoLimit","_playerGroup","_playerNetID","_playerUID","_position","_qtyIndex","_response","_return","_returnIn","_returnOut","_road",
|
||||||
|
"_serverSettingsConfig","_slot","_smoke","_tax","_tmpposition","_tradeIn","_tradeOut","_tradeQtyTotal","_tradeTotal","_vars","_vehHiveKey","_vehObj","_vehSlot","_vehicle","_vehicleBought",
|
||||||
|
"_vehicleSold","_vehicles","_vehslot","_wH","_wHPos","_wp","_kIndex","_playerCStats","_playerKarma","_playerKarmaAdj"
|
||||||
|
];
|
||||||
params ["_trader","_itemsIn","_itemsOut","_player",["_token","",[""]] ];
|
params ["_trader","_itemsIn","_itemsOut","_player",["_token","",[""]] ];
|
||||||
|
|
||||||
_playerUID = getplayeruid _player;
|
_playerUID = getplayeruid _player;
|
||||||
@ -54,56 +58,48 @@ if (_slot != -1) then {
|
|||||||
_itemClasses = _aiItems select 0;
|
_itemClasses = _aiItems select 0;
|
||||||
_itemQtys = _aiItems select 1;
|
_itemQtys = _aiItems select 1;
|
||||||
{
|
{
|
||||||
_item = _x;
|
_x params ["_item","_itemQty"];
|
||||||
_itemQty = 1;
|
|
||||||
|
|
||||||
if (isClass (_config >> _item)) then {
|
if (isClass (_config >> _item)) then {
|
||||||
_itemWorth = getNumber(_config >> _item >> "price");
|
_itemWorth = getNumber(_config >> _item >> "price");
|
||||||
|
_maxrnd = 1;
|
||||||
|
if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
|
||||||
|
};
|
||||||
|
_itemWorth = round (_itemWorth*(_itemQty/_maxrnd));
|
||||||
_makeTradeIn = false;
|
_makeTradeIn = false;
|
||||||
|
|
||||||
if (_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle" || _item isKindOf "Tank") then{
|
if (_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle" || _item isKindOf "Tank") then{
|
||||||
|
|
||||||
_vehicles = _trader nearEntities[[_item], 30];
|
_vehicles = _trader nearEntities[[_item], 30];
|
||||||
if !(_vehicles isEqualTo[]) then {
|
if !(_vehicles isEqualTo[]) then {
|
||||||
|
|
||||||
_vehicle = _vehicles select 0;
|
_vehicle = _vehicles select 0;
|
||||||
if (!isNull _vehicle) then {
|
if (!isNull _vehicle) then {
|
||||||
|
|
||||||
_playerNetID = owner _player;
|
_playerNetID = owner _player;
|
||||||
if (_playerNetID == (owner _vehicle)) then {
|
if (_playerNetID == (owner _vehicle)) then {
|
||||||
|
|
||||||
_vehSlot = _vehicle getVariable["VEHICLE_SLOT", "ABORT"];
|
_vehSlot = _vehicle getVariable["VEHICLE_SLOT", "ABORT"];
|
||||||
if (!_vehicleSold && _vehSlot != "ABORT") then {
|
if (!_vehicleSold && _vehSlot != "ABORT") then {
|
||||||
_BaseClass = _vehicle getvariable ["VEHICLE_BaseClass",""];
|
_BaseClass = _vehicle getvariable ["VEHICLE_BaseClass",""];
|
||||||
if !(_BaseClass isequalto "") then {
|
if !(_BaseClass isequalto "") then {
|
||||||
_item = _BaseClass;
|
_item = _BaseClass;
|
||||||
_itemsIn set [_foreachindex,_item];
|
_itemsIn set [_foreachindex,[_item,_itemQty]];
|
||||||
};
|
};
|
||||||
removeFromRemainsCollector [_vehicle];
|
removeFromRemainsCollector [_vehicle];
|
||||||
deleteVehicle _vehicle;
|
deleteVehicle _vehicle;
|
||||||
_vehicleSold = true;
|
_vehicleSold = true;
|
||||||
|
|
||||||
_vehHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _vehSlot];
|
_vehHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _vehSlot];
|
||||||
_VAL = [];
|
_VAL = [];
|
||||||
["Vehicle", _vehHiveKey, _VAL] call EPOCH_fnc_server_hiveSET;
|
["Vehicle", _vehHiveKey, _VAL] call EPOCH_fnc_server_hiveSET;
|
||||||
|
|
||||||
EPOCH_VehicleSlots pushBack _vehSlot;
|
EPOCH_VehicleSlots pushBack _vehSlot;
|
||||||
|
|
||||||
missionNamespace setVariable ['EPOCH_VehicleSlotCount', count EPOCH_VehicleSlots, true];
|
missionNamespace setVariable ['EPOCH_VehicleSlotCount', count EPOCH_VehicleSlots, true];
|
||||||
|
|
||||||
_makeTradeIn = true;
|
_makeTradeIn = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
_makeTradeIn = true;
|
_makeTradeIn = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_makeTradeIn) then {
|
if (_makeTradeIn) then {
|
||||||
|
_returnIn pushBack [_item,_itemQty];
|
||||||
_returnIn pushBack _item;
|
|
||||||
_tradeIn = _tradeIn + _itemWorth;
|
_tradeIn = _tradeIn + _itemWorth;
|
||||||
_current_crypto = _current_crypto + _itemWorth;
|
_current_crypto = _current_crypto + _itemWorth;
|
||||||
_tradeQtyTotal = _tradeQtyTotal + _itemQty;
|
_tradeQtyTotal = _tradeQtyTotal + _itemQty;
|
||||||
@ -127,7 +123,6 @@ if (_slot != -1) then {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
} forEach _itemsIn;
|
} forEach _itemsIn;
|
||||||
|
|
||||||
_response = ["Bank", _playerUID] call EPOCH_fnc_server_hiveGETRANGE;
|
_response = ["Bank", _playerUID] call EPOCH_fnc_server_hiveGETRANGE;
|
||||||
if ((_response select 0) == 1 && (_response select 1) isEqualType []) then {
|
if ((_response select 0) == 1 && (_response select 1) isEqualType []) then {
|
||||||
_bankData = _response select 1;
|
_bankData = _response select 1;
|
||||||
@ -154,53 +149,47 @@ if (_slot != -1) then {
|
|||||||
|
|
||||||
if (!_SkipOut) then {
|
if (!_SkipOut) then {
|
||||||
{
|
{
|
||||||
_item = _x;
|
_x params ["_item","_itemQty"];
|
||||||
_itemQty = 1;
|
|
||||||
if (isClass (_config >> _item)) then{
|
if (isClass (_config >> _item)) then{
|
||||||
_itemWorth = getNumber(_config >> _item >> "price");
|
_itemWorth = getNumber(_config >> _item >> "price");
|
||||||
_itemTax = getNumber(_config >> _item >> "tax");
|
_itemTax = getNumber(_config >> _item >> "tax");
|
||||||
_tax = _itemWorth * (EPOCH_taxRate + _itemTax);
|
_tax = _itemWorth * (EPOCH_taxRate + _itemTax);
|
||||||
_itemWorth = ceil (_itemWorth + _tax);
|
_itemWorth = ceil (_itemWorth + _tax);
|
||||||
|
_maxrnd = 1;
|
||||||
|
if ([_item,"cfgMagazines"] call Epoch_fnc_isAny) then {
|
||||||
|
_maxrnd = getnumber (configfile >> "cfgMagazines" >> _item >> "count");
|
||||||
|
};
|
||||||
|
_itemWorth = round (_itemWorth*(_itemQty/_maxrnd));
|
||||||
_qtyIndex = _itemClasses find _item;
|
_qtyIndex = _itemClasses find _item;
|
||||||
// add items to array
|
|
||||||
if (_qtyIndex != -1) then {
|
if (_qtyIndex != -1) then {
|
||||||
|
|
||||||
_currQty = _itemQtys select _qtyIndex;
|
_currQty = _itemQtys select _qtyIndex;
|
||||||
if (_currQty >= _itemQty) then {
|
if (_currQty >= _itemQty) then {
|
||||||
|
|
||||||
if (_current_crypto >= _itemWorth) then {
|
if (_current_crypto >= _itemWorth) then {
|
||||||
|
|
||||||
if (_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle" || _item isKindOf "Tank") then{
|
if (_item isKindOf "Air" || _item isKindOf "Ship" || _item isKindOf "LandVehicle" || _item isKindOf "Tank") then{
|
||||||
|
|
||||||
if (!_vehicleBought) then {
|
if (!_vehicleBought) then {
|
||||||
|
|
||||||
if !(EPOCH_VehicleSlots isEqualTo[]) then {
|
if !(EPOCH_VehicleSlots isEqualTo[]) then {
|
||||||
_position = getPosATL _player;
|
_position = getPosATL _player;
|
||||||
|
|
||||||
_helipad = nearestObjects[_player, ["Land_HelipadEmpty_F", "Land_HelipadCircle_F"], 100];
|
_helipad = nearestObjects[_player, ["Land_HelipadEmpty_F", "Land_HelipadCircle_F"], 100];
|
||||||
_helipads = [];
|
_helipads = [];
|
||||||
_smoke = nearestObject[_player, "SmokeShell"];
|
_smoke = nearestObject[_player, "SmokeShell"];
|
||||||
if (!isNull _smoke) then {
|
if (!isNull _smoke) then {
|
||||||
_helipad pushBack _smoke;
|
_helipad pushBack _smoke;
|
||||||
};
|
};
|
||||||
|
|
||||||
// water check
|
|
||||||
if (_item isKindOf "Ship") then {
|
if (_item isKindOf "Ship") then {
|
||||||
{
|
{
|
||||||
if (surfaceIsWater (getposATL _x)) then {
|
if (surfaceIsWater (getposATL _x)) then {
|
||||||
_helipads pushBack _x;
|
_helipads pushBack _x;
|
||||||
}
|
}
|
||||||
} forEach _helipad;
|
} forEach _helipad;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
{
|
{
|
||||||
if !(surfaceIsWater (getposATL _x)) then {
|
if !(surfaceIsWater (getposATL _x)) then {
|
||||||
_helipads pushBack _x;
|
_helipads pushBack _x;
|
||||||
}
|
}
|
||||||
} forEach _helipad;
|
} forEach _helipad;
|
||||||
};
|
};
|
||||||
|
|
||||||
if !(_helipads isEqualTo[]) then {
|
if !(_helipads isEqualTo[]) then {
|
||||||
|
|
||||||
_foundSmoke = false;
|
_foundSmoke = false;
|
||||||
{
|
{
|
||||||
if (_x isKindOf "SmokeShell") then {
|
if (_x isKindOf "SmokeShell") then {
|
||||||
@ -208,7 +197,8 @@ if (_slot != -1) then {
|
|||||||
if (_objOwner == owner _player) then {
|
if (_objOwner == owner _player) then {
|
||||||
_position = getPosATL _x;
|
_position = getPosATL _x;
|
||||||
_foundSmoke = true;
|
_foundSmoke = true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
{
|
{
|
||||||
if (_objOwner == owner _x) exitWith{
|
if (_objOwner == owner _x) exitWith{
|
||||||
_position = getPosATL _x;
|
_position = getPosATL _x;
|
||||||
@ -222,12 +212,14 @@ if (_slot != -1) then {
|
|||||||
if !(_foundSmoke) then {
|
if !(_foundSmoke) then {
|
||||||
_position = getPosATL (_helipads select 0);
|
_position = getPosATL (_helipads select 0);
|
||||||
};
|
};
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
_tmpposition = [];
|
_tmpposition = [];
|
||||||
if (_item isKindOf "Ship") then {
|
if (_item isKindOf "Ship") then {
|
||||||
_tmpposition = [_position, 20, 150, 5, 0, 1000, 1] call BIS_fnc_findSafePos;
|
_tmpposition = [_position, 20, 150, 5, 0, 1000, 1] call BIS_fnc_findSafePos;
|
||||||
_tmpposition = [_tmpposition, 0, 60, 10, 2, 1000, 0] call BIS_fnc_findSafePos;
|
_tmpposition = [_tmpposition, 0, 60, 10, 2, 1000, 0] call BIS_fnc_findSafePos;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
_tmpposition = [_position, 20, 120, 5, 0, 2000, 0] call BIS_fnc_findSafePos;
|
_tmpposition = [_position, 20, 120, 5, 0, 2000, 0] call BIS_fnc_findSafePos;
|
||||||
};
|
};
|
||||||
if ((count _tmpposition) == 2) then {
|
if ((count _tmpposition) == 2) then {
|
||||||
@ -244,29 +236,21 @@ if (_slot != -1) then {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
// select available slot
|
|
||||||
_vehslot = EPOCH_VehicleSlots select 0;
|
_vehslot = EPOCH_VehicleSlots select 0;
|
||||||
// Remove from available slots
|
|
||||||
EPOCH_VehicleSlots = EPOCH_VehicleSlots - [_vehslot];
|
EPOCH_VehicleSlots = EPOCH_VehicleSlots - [_vehslot];
|
||||||
missionNamespace setVariable ['EPOCH_VehicleSlotCount', count EPOCH_VehicleSlots, true];
|
missionNamespace setVariable ['EPOCH_VehicleSlotCount', count EPOCH_VehicleSlots, true];
|
||||||
_vehicleBought = true;
|
_vehicleBought = true;
|
||||||
|
|
||||||
// Group access
|
|
||||||
_lockOwner = getPlayerUID _player;
|
_lockOwner = getPlayerUID _player;
|
||||||
_playerGroup = _player getVariable["GROUP", ""];
|
_playerGroup = _player getVariable["GROUP", ""];
|
||||||
if (_playerGroup != "") then {
|
if (_playerGroup != "") then {
|
||||||
_lockOwner = _playerGroup;
|
_lockOwner = _playerGroup;
|
||||||
};
|
};
|
||||||
|
|
||||||
_vehObj = [_item,_position,random 360,true,_vehslot,_lockOwner,"NONE",false,false] call EPOCH_spawn_vehicle;
|
_vehObj = [_item,_position,random 360,true,_vehslot,_lockOwner,"NONE",false,false] call EPOCH_spawn_vehicle;
|
||||||
_final_location = getPosATL _vehObj;
|
_final_location = getPosATL _vehObj;
|
||||||
|
|
||||||
_group = group _player;
|
_group = group _player;
|
||||||
_wp = _group addWaypoint [_final_location, 0];
|
_wp = _group addWaypoint [_final_location, 0];
|
||||||
deleteWaypoint [_group, 0];
|
deleteWaypoint [_group, 0];
|
||||||
|
_returnOut pushBack [_item,_itemQty];
|
||||||
_returnOut pushBack _item;
|
|
||||||
|
|
||||||
_itemQtys set[_qtyIndex, (_currQty - _itemQty)];
|
_itemQtys set[_qtyIndex, (_currQty - _itemQty)];
|
||||||
_tradeOut = _tradeOut - _itemWorth;
|
_tradeOut = _tradeOut - _itemWorth;
|
||||||
_current_crypto = _current_crypto - _itemWorth;
|
_current_crypto = _current_crypto - _itemWorth;
|
||||||
@ -277,8 +261,8 @@ if (_slot != -1) then {
|
|||||||
[_errorMsg, 5] remoteExec ['Epoch_message',_player];
|
[_errorMsg, 5] remoteExec ['Epoch_message',_player];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (_item isKindOf "Bag_Base") then {
|
if (_item isKindOf "Bag_Base") then {
|
||||||
_wH = objNull;
|
_wH = objNull;
|
||||||
_nearByHolder = nearestObjects [_player,["groundWeaponHolder"],3];
|
_nearByHolder = nearestObjects [_player,["groundWeaponHolder"],3];
|
||||||
@ -288,12 +272,13 @@ if (_slot != -1) then {
|
|||||||
_wHPos = ASLToATL _wHPos;
|
_wHPos = ASLToATL _wHPos;
|
||||||
};
|
};
|
||||||
_wH = createVehicle ["groundWeaponHolder",_wHPos, [], 0, "CAN_COLLIDE"];
|
_wH = createVehicle ["groundWeaponHolder",_wHPos, [], 0, "CAN_COLLIDE"];
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
_wH = _nearByHolder select 0;
|
_wH = _nearByHolder select 0;
|
||||||
};
|
};
|
||||||
_wH addBackpackCargoGlobal [_item,1];
|
_wH addBackpackCargoGlobal [_item,1];
|
||||||
};
|
};
|
||||||
_returnOut pushBack _item;
|
_returnOut pushBack [_item,_itemQty];
|
||||||
_itemQtys set [_qtyIndex, (_currQty - _itemQty)];
|
_itemQtys set [_qtyIndex, (_currQty - _itemQty)];
|
||||||
_tradeOut = _tradeOut - _itemWorth;
|
_tradeOut = _tradeOut - _itemWorth;
|
||||||
_current_crypto = _current_crypto - _itemWorth;
|
_current_crypto = _current_crypto - _itemWorth;
|
||||||
@ -312,8 +297,6 @@ if (_slot != -1) then {
|
|||||||
};
|
};
|
||||||
} forEach _itemsOut;
|
} forEach _itemsOut;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if !(_itemsIn isEqualTo []) then {
|
if !(_itemsIn isEqualTo []) then {
|
||||||
if (_itemsIn isEqualTo _returnIn) then {
|
if (_itemsIn isEqualTo _returnIn) then {
|
||||||
_message = _message + "All Items sold";
|
_message = _message + "All Items sold";
|
||||||
@ -336,10 +319,7 @@ if (_slot != -1) then {
|
|||||||
_message = _message + "Not all Items purchased";
|
_message = _message + "Not all Items purchased";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
_tradeTotal = _tradeIn + _tradeOut;
|
_tradeTotal = _tradeIn + _tradeOut;
|
||||||
|
|
||||||
|
|
||||||
if !(_returnIn isequalto [] && _returnOut isEqualTo []) then {
|
if !(_returnIn isequalto [] && _returnOut isEqualTo []) then {
|
||||||
_trader setVariable["AI_ITEMS", [_itemClasses, _itemQtys], true];
|
_trader setVariable["AI_ITEMS", [_itemClasses, _itemQtys], true];
|
||||||
_objHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot];
|
_objHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot];
|
||||||
|
Loading…
Reference in New Issue
Block a user