mirror of
https://github.com/Bones50/ammoSave.git
synced 2024-08-30 17:22:11 +00:00
Add files via upload
This commit is contained in:
parent
7da09db718
commit
12e6dc1587
@ -1,54 +1,35 @@
|
||||
private ["_currentLoadout", "_magClass", "_turretPath", "_ammoCount", "_inserted", "_magInserted", "_magData"];
|
||||
_OK = params
|
||||
[
|
||||
["_vehicle", objNull, [objNull]]
|
||||
];
|
||||
|
||||
if (!_OK) exitWith
|
||||
{
|
||||
diag_log format ["AVS Error: Calling AVS_fnc_getVehicleLoadout with invalid parameters: %1",_this];
|
||||
};
|
||||
|
||||
private ["_pylon", "_pylonRun", "_pylonList", "_magClass", "_currentLoadout", "_turretPath", "_ammoCount", "_magDetail"];
|
||||
_vehicle = _this;
|
||||
_currentLoadout = [];
|
||||
{ // forEach magazinesAllTurrets _vehicle;
|
||||
// [[<className>,<turretPath>,<ammoCount>,<id>,<creator>],...]
|
||||
_magDetail = magazinesAllTurrets _vehicle;
|
||||
_pylonList = getPylonMagazines _vehicle;
|
||||
_pylonRun = 1;
|
||||
{
|
||||
_magClass = _x select 0;
|
||||
_turretPath = _x select 1;
|
||||
_ammoCount = _x select 2;
|
||||
|
||||
_inserted = false;
|
||||
{ // forEach _currentLoadout
|
||||
// Check if we have this _turretPath in _currentLoadout
|
||||
if ((_x select 0) isEqualTo _turretPath) then
|
||||
{
|
||||
// _turretPath found in _currentLoadout
|
||||
// Now check if we have this _magClass in this _turretPath yet.
|
||||
_magInserted = false;
|
||||
for "_i" from 1 to ((count _x) - 1) do
|
||||
{
|
||||
_magData = _x select _i;
|
||||
|
||||
if ((_magData select 0) isEqualTo _magClass) then
|
||||
{
|
||||
// _magClass found, add the ammo to it.
|
||||
_magData set [1, ((_magData select 1) + _ammoCount)];
|
||||
_magInserted = true;
|
||||
};
|
||||
};
|
||||
if (!_magInserted) then
|
||||
{
|
||||
// _magClass not found, push it as a new element.
|
||||
_x pushBack [_magClass, _ammoCount];
|
||||
};
|
||||
_inserted = true;
|
||||
};
|
||||
} forEach _currentLoadout;
|
||||
|
||||
if (!_inserted) then
|
||||
_pylon = -1;
|
||||
if (_magclass in _pylonList) then
|
||||
{_pylon = _pylonRun;_pylonRun = _pylonRun + 1;
|
||||
_currentLoadout pushBack [_turretPath, _pylon, _magClass, _ammoCount];
|
||||
} else
|
||||
{
|
||||
// _turretPath not found in _currentLoadout, push it as a new element.
|
||||
_currentLoadout pushBack [_turretPath, [_magClass, _ammoCount]];
|
||||
private ["_tempAmmo", "_inserted"];
|
||||
_inserted = false;
|
||||
{
|
||||
if ((_x select 0) isEqualTo _turretPath && (_x select 2) isEqualTo _magClass) then
|
||||
{
|
||||
_tempAmmo = (_x select 3);
|
||||
_x set [3, (_tempAmmo + _ammoCount)];
|
||||
_inserted = true;
|
||||
};
|
||||
} forEach _currentLoadout;
|
||||
|
||||
if (!_inserted) then
|
||||
{
|
||||
_currentLoadout pushBack [_turretPath, _pylon, _magClass, _ammoCount];
|
||||
};
|
||||
};
|
||||
} forEach magazinesAllTurrets _vehicle;
|
||||
} forEach _magDetail;
|
||||
|
||||
_currentLoadout
|
@ -110,49 +110,66 @@ if (_vehicleObject call ExileClient_util_world_isInTraderZone) then
|
||||
{
|
||||
_vehicleObject allowDamage false;
|
||||
};
|
||||
|
||||
//Bones Ammo Save Addition
|
||||
_query = format["getVehicleAmmo:%1", _vehicleID] call ExileServer_system_database_query_selectSingle;
|
||||
_savedMagazines = _query select 0;
|
||||
|
||||
_vehicleobject setVehicleAmmoDef 0;
|
||||
_vehicleObject setVehicleAmmoDef 0;
|
||||
|
||||
if (typeName _savedMagazines isEqualTo "ARRAY") then
|
||||
{
|
||||
if (typeName (_savedMagazines select 0) isEqualTo "ARRAY") then
|
||||
private ["_turretPath", "_pylonIndex", "_magClass","_bulletAmount", "_magClass", "_maxMagAmmo", "_numMags"];
|
||||
_turretPath = _x select 0;
|
||||
_pylonIndex = _x select 1;
|
||||
_magClass = _x select 2;
|
||||
_bulletAmount = _x select 3;
|
||||
|
||||
if (["120mm",_magClass] call BIS_fnc_inString || ["125mm",_magClass] call BIS_fnc_inString || ["105mm",_magClass] call BIS_fnc_inString || ["L30A1_Cannon",_magClass] call BIS_fnc_inString || ["2A46",_magClass] call BIS_fnc_inString || ["100mm",_magClass] call BIS_fnc_inString) then
|
||||
{
|
||||
_vehicleObject removeMagazinesTurret [_magClass, _turretPath];
|
||||
_vehicleObject addMagazineTurret [_magClass,_turretPath,_bulletAmount];
|
||||
} else
|
||||
{
|
||||
//DO THIS IF SMOKE
|
||||
if (["smoke",_magclass] call BIS_fnc_inString) then
|
||||
{
|
||||
_turretPath = _x select 0;
|
||||
for "_i" from (count _x - 1) to 1 step -1 do
|
||||
_vehicleObject removeMagazinesTurret [_magClass, _turretPath];
|
||||
_vehicleObject removeWeaponTurret ["SmokeLauncher", _turretPath];
|
||||
_vehicleObject addMagazineTurret [_magClass,_turretPath,_bulletAmount];
|
||||
_vehicleObject addWeaponTurret ["SmokeLauncher", _turretPath];
|
||||
} else
|
||||
{
|
||||
//DO THIS IF CHAFF
|
||||
if (["chaff",_magclass] call BIS_fnc_inString) then
|
||||
{
|
||||
_magData = _x select _i;
|
||||
_magClass = _magData select 0;
|
||||
_ammoCount = _magData select 1;
|
||||
if (["120mm",_magClass] call BIS_fnc_inString || ["125mm",_magClass] call BIS_fnc_inString || ["105mm",_magClass] call BIS_fnc_inString || ["L30A1_Cannon",_magClass] call BIS_fnc_inString || ["2A46",_magClass] call BIS_fnc_inString || ["100mm",_magClass] call BIS_fnc_inString) then
|
||||
_vehicleObject removeMagazinesTurret [_magClass, _turretPath];
|
||||
_vehicleObject removeWeaponTurret ["CMFlareLauncher", _turretPath];
|
||||
_vehicleObject addMagazineTurret [_magClass,_turretPath,_bulletAmount];
|
||||
_vehicleObject addWeaponTurret ["CMFlareLauncher", _turretPath];
|
||||
} else
|
||||
{
|
||||
//DO THIS IF PYLON
|
||||
if (["pylon",_magclass] call BIS_fnc_inString) then
|
||||
{
|
||||
_vehicleobject addMagazineTurret [_magClass,_turretPath,_ammoCount];
|
||||
}
|
||||
else
|
||||
_vehicleObject setAmmoOnPylon [_pylonIndex,_bulletAmount];
|
||||
} else
|
||||
{
|
||||
//FOR EVERYTHING ELSE
|
||||
_maxMagAmmo = (configFile >> "CfgMagazines" >> _magClass >> "count") call BIS_fnc_getCfgData;
|
||||
_numMags = ceil (_ammoCount / _maxMagAmmo);
|
||||
_numMags = ceil (_bulletAmount / _maxMagAmmo);
|
||||
|
||||
while {_numMags > 1} do
|
||||
{
|
||||
_vehicleobject addMagazineTurret [_magClass, _turretPath];
|
||||
_numMags = _numMags - 1;
|
||||
_ammoCount = _ammoCount - _maxMagAmmo;
|
||||
_bulletAmount = _bulletAmount - _maxMagAmmo;
|
||||
};
|
||||
_vehicleobject setMagazineTurretAmmo [_magClass, _ammoCount, _turretPath];
|
||||
_vehicleobject setMagazineTurretAmmo [_magClass, _bulletAmount, _turretPath];
|
||||
};
|
||||
};
|
||||
} forEach _savedMagazines;
|
||||
};
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
diag_log format["AMMO ERROR - INVALID MAGAZINE SAVED IN DATABASE: %1", _savedMagazines];
|
||||
diag_log format["AMMO ERROR - Magazines should be saved an array. Blank entries should be: [] Verify your database."];
|
||||
};
|
||||
}forEach _savedMagazines;
|
||||
|
||||
//End Custom Ammo Save
|
||||
_vehicleObject
|
||||
_vehicleObject
|
Loading…
Reference in New Issue
Block a user