Files
DayZ-Epoch/SQF/dayz_code/compile/player_countMagazinesWBackpack.sqf
F507DMT 967abbdcd9 Update player_countMagazinesWBackpack.sqf
There may be too long pauses with low FPS.
2019-01-15 01:58:39 +06:00

75 lines
2.4 KiB
Plaintext

/*
count player magazines with ammo count
value = call player_countMagazines; //must be called from a spawned thread (or use spawn)
return all player magazines with ammo count
Modified to save backpack magazine count by icomrade - Base for fix by Ziellos2k
*/
private ["_control","_count","_dialog","_i","_item","_magazineArray","_max","_val"];
disableUserInput true;
disableUserInput true;
disableSerialization;
_magazineArray = [[],[]];
_dialog = ["0"] call gearDialog_create;
if ((isNil "_dialog") || {isNull _dialog}) exitWith {(findDisplay 106) closeDisplay 0; closeDialog 0; disableUserInput false; disableUserInput false; _magazineArray};
//Main inventory
for "_i" from 109 to 120 do {
_control = _dialog displayCtrl _i;
_item = gearSlotData _control;
_val = gearSlotAmmoCount _control;
_max = getNumber (configFile >> "CfgMagazines" >> _item >> "count");
if (_item != "") then {
if (_val != _max) then {
(_magazineArray select 0) set [count (_magazineArray select 0),[_item,_val]];
} else {
(_magazineArray select 0) set [count (_magazineArray select 0),_item];
};
};
};
//Pistol/secondary ammo
for "_i" from 122 to 129 do {
_control = _dialog displayCtrl _i;
_item = gearSlotData _control;
_val = gearSlotAmmoCount _control;
_max = getNumber (configFile >> "CfgMagazines" >> _item >> "count");
if (_item != "") then {
if (_val != _max) then {
(_magazineArray select 0) set [count (_magazineArray select 0),[_item,_val]];
} else {
(_magazineArray select 0) set [count (_magazineArray select 0),_item];
};
};
};
//backpack items
if ((typeOf (unitBackPack player)) != "") then {
_count = getNumber (configFile >> "CfgVehicles" >> (typeOf (unitBackpack Player)) >> "transportMaxMagazines");
ctrlActivate (_dialog displayCtrl 157);
if (gear_done) then {
waitUntil {ctrlShown (_dialog displayCtrl 159)};
uiSleep 0.001;
};
for "_i" from 5000 to (5000 + _count) do {
_control = _dialog displayCtrl _i;
_item = gearSlotData _control;
_val = gearSlotAmmoCount _control;
_max = getNumber (configFile >> "CfgMagazines" >> _item >> "count");
if (_item != "") then {
if (_val != _max) then {
(_magazineArray select 1) set [count (_magazineArray select 1),[_item,_val]];
} else {
(_magazineArray select 1) set [count (_magazineArray select 1),_item];
};
};
};
};
(findDisplay 106) closeDisplay 0;
if (gear_done) then {uiSleep 0.001;};
_magazineArray