Vehicle selling for advanced trading

This should work fairly okay but I expect there may be a couple exploits
and glitches
This commit is contained in:
icomrade
2016-04-28 18:35:03 -04:00
parent d2ba027863
commit 55f3a9dc79
6 changed files with 210 additions and 44 deletions

View File

@@ -6,13 +6,28 @@
Author:
Zupa 2014-09-30
---------------------------------------------------------------------------- */
private ["_unit", "_items","_weaps","_normalItems","_normalWeaps", "_count", "_i", "_unit_allItems", "_unit_allItems_types", "_unit_allItems_count", "_item_type", "_item_count", "__returnVar"];
private ["_unit","_items","_weaps","_normalItems","_normalWeaps","_unit_allItems","_unit_allItems_types","_unit_allItems_count","_bags","_vehInfo","_keyID","_counter","_normalBagss","_inCargo","_deleteVeh","_normalBags","_unit_allWeaps","_unit_allWeaps_types","_unit_allWeaps_count","_unit_allBags","_unit_allBags_types","_unit_allBags_count","_returnVar","_returnMag","_returnWeap","_returnBag"];
_unit = _this select 0;
_items = _this select 1;
_weaps = _this select 2;
_bags = [];
if(count _this > 3)then{
_bags = _this select 3;
_vehInfo = [];
_keyID = 0;
_deleteVeh = false;
if(count _this > 3) then {
if (count (_this select 3) > 0) then {
if (typeName ((_this select 3) select 0) == "STRING") then {
_bags = _this select 3;
} else {
_vehInfo = (_this select 3) select 0;
_keyID = _vehInfo select 0;
};
};
if (count _this == 5) then {
_vehInfo = (_this select 4) select 0;
_keyID = _vehInfo select 0;
};
};
_normalItems = [];
@@ -78,20 +93,6 @@ _normalItems = _normalItems - ["soldItem"];
_unit addMagazineCargoGlobal [_x, 1];
}count _normalItems;
{
_inCargo = _normalWeaps find _x;
if(_inCargo > -1)then{
_normalWeaps set [_inCargo, "soldItem"];
_returnWeap set [count(_returnWeap),1];
}else{
_returnWeap set [count(_returnWeap),0];
};
}count _weaps;
_normalWeaps = _normalWeaps - ["soldItem"];
{
_unit addWeaponCargoGlobal [_x, 1];
}count _normalWeaps;
{
_inCargo = _normalBags find _x;
if(_inCargo > -1)then{
@@ -101,12 +102,49 @@ _normalWeaps = _normalWeaps - ["soldItem"];
_returnBag set [count(_returnBag),0];
};
}count _bags;
_normalWeaps = _normalWeaps - ["soldItem"];
{
_unit addBackpackCargoGlobal [_x, 1];
}count _normalBags;
if (count _vehInfo > 0) then {
{
if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]) then {
if (str(getNumber(configFile >> "CfgWeapons" >> _x >> "keyid")) == _keyID) then {
_weaps set [count _weaps, _x];
_deleteVeh = True;
};
};
} count _normalWeaps;
};
{
_inCargo = _normalWeaps find _x;
if(_inCargo > -1)then{
_normalWeaps set [_inCargo, "soldItem"];
if (!_deleteVeh && {(!(configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"]))}) then {
_returnWeap set [count(_returnWeap),1];
};
}else{
_returnWeap set [count(_returnWeap),0];
};
}count _weaps;
_normalWeaps = _normalWeaps - ["soldItem"];
{
_unit addWeaponCargoGlobal [_x, 1];
}count _normalWeaps;
_normalWeaps = _normalWeaps - ["soldItem"];
_returnVar set [0,_returnMag];
_returnVar set [1,_returnWeap];
_returnVar set [2,_returnBag];
_returnVar
if (_deleteVeh) then {
_returnVar set [3,[1]];
PVDZ_obj_Destroy = [(_vehInfo select 2),(_vehInfo select 3),player];
publicVariableServer "PVDZ_obj_Destroy";
deleteVehicle (_vehInfo select 1);
};
_returnVar;