Fix ammo refill when switching skins and ...

- allow player to switch with backpack on.
- player_countmagazines now returns backpack magazines with ammo count.
Do with this as you like.
- Make sure dead players do not have to wait the abort (after the 5
seconds).
- Update changelog
This commit is contained in:
icomrade
2014-03-18 15:48:45 -04:00
parent 058519c926
commit ad2642a5f9
8 changed files with 161 additions and 78 deletions

View File

@@ -1,55 +1,70 @@
/*
count player magazines with ammo count
value = call player_countmagazines;
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 ["_dialog","_control","_magazineArray","_item","_val","_max","_created"];
private ["_control","_item","_val","_max","_count","_magazineArray","_dialog"];
disableSerialization;
disableUserInput true;
_dialog = findDisplay 106;
_created = false;
if ( isNull _dialog ) then {
//startLoadingScreen [""];
createGearDialog [player, "RscDisplayGear"];
_dialog = findDisplay 106;
_created = true;
};
_magazineArray = [];
for "_i" from 109 to 120 do
{
_control = _dialog displayCtrl _i;
_item = gearSlotData _control;
_val = gearSlotAmmoCount _control;
_max = getNumber (configFile >> "CfgMagazines" >> _item >> "count");
_magazineArray = [[],[]];
_dialog = ["0"] call gearDialog_create;
if ((isNull _dialog) || (isNil "_dialog")) exitWith {disableUserInput false; (findDisplay 106) closeDisplay 0; closeDialog 0; _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 set [count _magazineArray,[_item,_val]];
(_magazineArray select 0) set [count (_magazineArray select 0),[_item,_val]];
} else {
_magazineArray set [count _magazineArray,_item];
(_magazineArray select 0) set [count (_magazineArray select 0),_item];
};
};
};
for "_i" from 122 to 129 do
{
_control = _dialog displayCtrl _i;
_item = gearSlotData _control;
_val = gearSlotAmmoCount _control;
_max = getNumber (configFile >> "CfgMagazines" >> _item >> "count");
//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 set [count _magazineArray,[_item,_val]];
(_magazineArray select 0) set [count (_magazineArray select 0),[_item,_val]];
} else {
_magazineArray set [count _magazineArray,_item];
(_magazineArray select 0) set [count (_magazineArray select 0),_item];
};
};
};
if ( _created ) then {
closeDialog 0;
//endLoadingScreen;
//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)};
sleep 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];
};
};
};
};
disableUserInput false;
dayz_Magazines=_magazineArray;
_magazineArray
(findDisplay 106) closeDisplay 0;
if (gear_done) then {sleep 0.001;};
_magazineArray