Fix potential magazine and weapon dupes

This reverts 4b171cb.

player_regularSave should only be used if player_forceSave would interrupt an action like fire a weapon since it opens a dialog. player_regularSave does not save the ammo count but all magazines. Do not use nil instead of the magazines player array since it makes duping possible.

Thx to mmrsz
This commit is contained in:
AirwavesMan
2021-04-16 13:24:18 +02:00
parent 4b171cb636
commit e8f2f3fcf0
7 changed files with 14 additions and 15 deletions

View File

@@ -1,16 +1,14 @@
/*
Opens player inventory to save
Do not use this in constant running loops or actions. force_Save opens the inventory with a dialog call.
That will interrupt actions like shooting. For loops use player_regularSave but keep in mind player_regularSave does not save the ammo count.
*/
local _magazineArray = [] call player_countMagazines;
if ((count _magazineArray) > 0) then {
PVDZ_plr_Save = [player, if (player isKindOf "PZombie_VB") then {nil} else {_magazineArray},dayz_onBack,weapons player];
} else {
PVDZ_plr_Save = [player,nil,dayz_onBack,weapons player];
};
PVDZ_plr_Save = [player, if (player isKindOf "PZombie_VB") then {nil} else {_magazineArray},dayz_onBack,weapons player];
publicVariableServer "PVDZ_plr_Save";
//diag_log format["Player_forceSave with magazines: %1",_magazineArray];