From 4b171cb63646660f6a33ba9f48d5fe1094794967 Mon Sep 17 00:00:00 2001 From: AirwavesMan Date: Thu, 15 Apr 2021 20:56:53 +0200 Subject: [PATCH 1/2] Fix possible weapon dupe Thx to mmrsz --- SQF/dayz_code/compile/player_forceSave.sqf | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/SQF/dayz_code/compile/player_forceSave.sqf b/SQF/dayz_code/compile/player_forceSave.sqf index 8259f8ba5..15ce83c8c 100644 --- a/SQF/dayz_code/compile/player_forceSave.sqf +++ b/SQF/dayz_code/compile/player_forceSave.sqf @@ -4,12 +4,14 @@ Opens player inventory to save */ -_magazineArray = [] call player_countMagazines; +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]; - publicVariableServer "PVDZ_plr_Save"; + 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]; }; +publicVariableServer "PVDZ_plr_Save"; //diag_log format["Player_forceSave with magazines: %1",_magazineArray]; From e8f2f3fcf0505cbe9b6d605da71a6090dbaadc06 Mon Sep 17 00:00:00 2001 From: AirwavesMan Date: Fri, 16 Apr 2021 13:24:18 +0200 Subject: [PATCH 2/2] 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 --- SQF/dayz_code/actions/pickupActions/object_pickup.sqf | 2 +- SQF/dayz_code/actions/player_sleep.sqf | 2 +- SQF/dayz_code/actions/pzombie/pz_feed.sqf | 2 +- SQF/dayz_code/compile/keyboard.sqf | 2 +- SQF/dayz_code/compile/player_forceSave.sqf | 8 +++----- SQF/dayz_code/compile/player_humanityMorph.sqf | 5 ++--- SQF/dayz_code/compile/player_regularSave.sqf | 8 +++++--- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/SQF/dayz_code/actions/pickupActions/object_pickup.sqf b/SQF/dayz_code/actions/pickupActions/object_pickup.sqf index 39410c9a3..49657e19a 100644 --- a/SQF/dayz_code/actions/pickupActions/object_pickup.sqf +++ b/SQF/dayz_code/actions/pickupActions/object_pickup.sqf @@ -53,7 +53,7 @@ if (_classname isKindOf "Bag_Base_EP1") exitWith { waitUntil { !isNull (unitBackpack player) }; uiSleep 0.03; - call player_regularSave; + call player_forceSave; }; _config = (configFile >> _type >> _classname); diff --git a/SQF/dayz_code/actions/player_sleep.sqf b/SQF/dayz_code/actions/player_sleep.sqf index 49f4f127a..79765008c 100644 --- a/SQF/dayz_code/actions/player_sleep.sqf +++ b/SQF/dayz_code/actions/player_sleep.sqf @@ -115,5 +115,5 @@ player setVariable ["sleeping",false]; dayz_actionInProgress = false; //Removed due to player sync returning [] -//call player_regularSave; +//call player_forceSave; R3F_TIRED_Accumulator = 0; \ No newline at end of file diff --git a/SQF/dayz_code/actions/pzombie/pz_feed.sqf b/SQF/dayz_code/actions/pzombie/pz_feed.sqf index dcc3f2a6f..7f5b22b9d 100644 --- a/SQF/dayz_code/actions/pzombie/pz_feed.sqf +++ b/SQF/dayz_code/actions/pzombie/pz_feed.sqf @@ -63,7 +63,7 @@ if !(alive _item) then { dayz_lastMeal = time; dayz_hunger = 0; - call player_regularSave; + call player_forceSave; [player,"eat",0,false] call dayz_zombieSpeak; diff --git a/SQF/dayz_code/compile/keyboard.sqf b/SQF/dayz_code/compile/keyboard.sqf index ddfc3083d..b57304c7b 100644 --- a/SQF/dayz_code/compile/keyboard.sqf +++ b/SQF/dayz_code/compile/keyboard.sqf @@ -20,7 +20,7 @@ if (isNil "keyboard_keys") then { }; local _dze_q = { if (!_ctrlState && !_altState) then {DZE_Q = true;}; - if (!_ctrlState && {_altState}) then {DZE_Q_alt = true;}; + if (!_ctrlState && _altState) then {DZE_Q_alt = true;}; if (_ctrlState && !_altState) then {DZE_Q_ctrl = true;}; }; local _dze_z = { diff --git a/SQF/dayz_code/compile/player_forceSave.sqf b/SQF/dayz_code/compile/player_forceSave.sqf index 15ce83c8c..9cde166e9 100644 --- a/SQF/dayz_code/compile/player_forceSave.sqf +++ b/SQF/dayz_code/compile/player_forceSave.sqf @@ -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]; diff --git a/SQF/dayz_code/compile/player_humanityMorph.sqf b/SQF/dayz_code/compile/player_humanityMorph.sqf index 50494bddc..71a8c2a43 100644 --- a/SQF/dayz_code/compile/player_humanityMorph.sqf +++ b/SQF/dayz_code/compile/player_humanityMorph.sqf @@ -1,5 +1,5 @@ private ["_charID","_model","_old","_humanity","_medical","_worldspace","_zombieKills","_headShots","_humanKills","_combattimeout","_inCombat","_banditKills","_fractures","_survivalTime","_coins","_bankCoins","_globalCoins","_ConfirmedHumanKills","_ConfirmedBanditKills","_friendlies","_tagSetting"]; -//_playerUID = _this select 0; +closeDialog 0; _charID = _this select 1; _model = _this select 2; @@ -13,7 +13,6 @@ _old removeAllEventHandlers "Fired"; _old allowDamage false; _old AddEventHandler ["HandleDamage", {False}]; -dayz_unsaved = true; //Logout _humanity = player getVariable ["humanity",0]; _medical = player call player_sumMedical; @@ -111,4 +110,4 @@ player allowDamage true; uiSleep 0.1; if !(isNull _old) then {deleteVehicle _old;}; -call player_forceSave; +call player_forceSave; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_regularSave.sqf b/SQF/dayz_code/compile/player_regularSave.sqf index 1f63a5bca..09172e247 100644 --- a/SQF/dayz_code/compile/player_regularSave.sqf +++ b/SQF/dayz_code/compile/player_regularSave.sqf @@ -4,14 +4,16 @@ Email: N/A Creation date: 2020-12-30 17:20:00 - Last modified time: 2021-03-08 14:04:00 + Last modified time: 2021-04-16 09:20:00 Description: - Requests a simple save for the player object. + Requests a simple save for the player object. Does not save the ammo count but it does not interrupt actions like shooting. Example: call player_regularSave; Return: Nothing */ -PVDZ_plr_Save = [player,nil,dayz_onBack,weapons player]; +local _magazineArray = (magazines player) - ["CSGAS","Hatchet_Swing","Crowbar_Swing","Machete_Swing","Bat_Swing","BatBarbed_Swing","BatNails_Swing","Fishing_Swing","Sledge_Swing"]; + +PVDZ_plr_Save = [player,_magazineArray,dayz_onBack,weapons player]; publicVariableServer "PVDZ_plr_Save"; \ No newline at end of file