diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf index e7886717f..12ccb1af7 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_sellItems.sqf @@ -135,6 +135,7 @@ if (Z_SellingFrom == 2) then { if (_type == "trade_weapons") then {_name = configFile >> "CfgWeapons" >> _name;}; if (_x select 0 == dayz_onBack) then { dayz_onBack = ""; // Remove from back + player setVariable ["dayz_onBack",dayz_onBack,true]; _localResult = 1; } else { _localResult = [player,_name,1] call BIS_fnc_invRemove; // Use config for BIS_fnc_invRemove diff --git a/SQF/dayz_code/actions/player_addToolbelt.sqf b/SQF/dayz_code/actions/player_addToolbelt.sqf index f2c494997..56f8bde78 100644 --- a/SQF/dayz_code/actions/player_addToolbelt.sqf +++ b/SQF/dayz_code/actions/player_addToolbelt.sqf @@ -38,6 +38,7 @@ call gear_ui_init; if (_item == dayz_onBack && carryClick) then { dayz_onBack = ""; + player setVariable ["dayz_onBack",dayz_onBack,true]; carryClick = false; ((findDisplay 106) displayCtrl 1209) ctrlSetText ""; _removed = true; diff --git a/SQF/dayz_code/actions/player_addtoBack.sqf b/SQF/dayz_code/actions/player_addtoBack.sqf index 066288672..fd63584f6 100644 --- a/SQF/dayz_code/actions/player_addtoBack.sqf +++ b/SQF/dayz_code/actions/player_addtoBack.sqf @@ -17,13 +17,12 @@ call gear_ui_init; if (_item in ["ItemHatchet","ItemCrowbar","ItemMachete","ItemFishingPole","ItemSledge"]) then { //free primary slot for new melee (remember item to add after) call { - if (_item == "ItemHatchet") exitwith {player removeWeapon "ItemHatchet"; dayz_onBack = "MeleeHatchet";}; - if (_item == "ItemCrowbar") exitwith {player removeWeapon "ItemCrowbar"; dayz_onBack = "MeleeCrowbar";}; - if (_item == "ItemMachete") exitwith {player removeWeapon "ItemMachete"; dayz_onBack = "MeleeMachete";}; - if (_item == "ItemFishingPole") exitwith {player removeWeapon "ItemFishingPole"; dayz_onBack = "MeleeFishingPole";}; - if (_item == "ItemSledge") exitwith {player removeWeapon "ItemSledge"; dayz_onBack = "MeleeSledge";}; + if (_item == "ItemHatchet") exitwith {player removeWeapon "ItemHatchet"; dayz_onBack = "MeleeHatchet";player setVariable ["dayz_onBack",dayz_onBack,true];}; + if (_item == "ItemCrowbar") exitwith {player removeWeapon "ItemCrowbar"; dayz_onBack = "MeleeCrowbar";player setVariable ["dayz_onBack",dayz_onBack,true];}; + if (_item == "ItemMachete") exitwith {player removeWeapon "ItemMachete"; dayz_onBack = "MeleeMachete";player setVariable ["dayz_onBack",dayz_onBack,true];}; + if (_item == "ItemFishingPole") exitwith {player removeWeapon "ItemFishingPole"; dayz_onBack = "MeleeFishingPole";player setVariable ["dayz_onBack",dayz_onBack,true];}; + if (_item == "ItemSledge") exitwith {player removeWeapon "ItemSledge"; dayz_onBack = "MeleeSledge";player setVariable ["dayz_onBack",dayz_onBack,true];}; }; disableSerialization; [[(findDisplay 106)],"onLBSelChanged"] spawn fn_handleGear; //update back - }; diff --git a/SQF/dayz_code/actions/player_dropWeapon.sqf b/SQF/dayz_code/actions/player_dropWeapon.sqf index 61f7256ef..cf06b28e8 100644 --- a/SQF/dayz_code/actions/player_dropWeapon.sqf +++ b/SQF/dayz_code/actions/player_dropWeapon.sqf @@ -1,3 +1,6 @@ +if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; }; +dayz_actionInProgress = true; + private ["_item","_config","_onLadder","_consume","_bag","_droppedType"]; disableSerialization; @@ -8,23 +11,22 @@ _droppedType = getText (_config >> "droppeditem"); //Make sure the player still has the tool this script was spawned with if ((dayz_onBack != _item && carryClick) or (!(player hasWeapon _item) && !carryClick)) exitWith { format[localize "str_player_30",getText (_config >> "displayName")] call dayz_rollingMessages; + dayz_actionInProgress = false; }; _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; -if (_onLadder) exitWith { localize "str_player_21" call dayz_rollingMessages; }; -if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; }; -dayz_actionInProgress = true; +if (_onLadder) exitWith {dayz_actionInProgress = false; localize "str_player_21" call dayz_rollingMessages; }; call gear_ui_init; _consume = ([] + getArray (_config >> "magazines")) select 0; if (_item == dayz_onBack && carryClick) then { - switch DayZ_onBack do { - case "MeleeHatchet": {_item = "ItemHatchet"; dayz_onBack = "";}; - case "MeleeCrowbar": {_item = "ItemCrowbar"; dayz_onBack = "";}; - case "MeleeMachete": {_item = "ItemMachete"; dayz_onBack = "";}; - case "MeleeSledge": {_item = "ItemSledge"; dayz_onBack = "";}; + call { + if (dayZ_onBack == "MeleeHatchet") exitWith {_item = "ItemHatchet"; dayz_onBack = ""; player setVariable ["dayz_onBack",dayz_onBack,true];}; + if (dayZ_onBack == "MeleeCrowbar") exitWith {_item = "ItemCrowbar"; dayz_onBack = "";player setVariable ["dayz_onBack",dayz_onBack,true];}; + if (dayZ_onBack == "MeleeMachete") exitWith {_item = "ItemMachete"; dayz_onBack = "";player setVariable ["dayz_onBack",dayz_onBack,true];}; + if (dayZ_onBack == "MeleeSledge") exitWith {_item = "ItemSledge"; dayz_onBack = "";player setVariable ["dayz_onBack",dayz_onBack,true];}; }; carryClick = false; ((findDisplay 106) displayCtrl 1209) ctrlSetText ""; diff --git a/SQF/dayz_code/actions/player_mineStone.sqf b/SQF/dayz_code/actions/player_mineStone.sqf index 8d842bf7b..99037d17a 100644 --- a/SQF/dayz_code/actions/player_mineStone.sqf +++ b/SQF/dayz_code/actions/player_mineStone.sqf @@ -1,12 +1,12 @@ +if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; }; +dayz_actionInProgress = true; + private ["_mineChance","_breaking","_counter","_rocks","_findNearestRock","_objName","_countOut","_isOk","_proceed","_finished","_itemOut","_weapons"]; _item = _this; call gear_ui_init; closeDialog 1; -if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; }; -dayz_actionInProgress = true; - // allowed rocks list move this later _rocks = ["r2_boulder1.p3d","r2_boulder2.p3d","r2_rock1.p3d","r2_rock2.p3d","r2_rocktower.p3d","r2_rockwall.p3d","r2_stone.p3d"]; _findNearestRock = objNull; @@ -37,7 +37,7 @@ if (!isNull _findNearestRock) then { _weapons set [count _weapons,dayz_onBack]; //Make sure player did not drop pickaxe - if (!_finished or !("MeleePickaxe" in _weapons or ("ItemPickaxe" in _weapons))) exitWith { + if (!_finished || !("ItemPickaxe" in _weapons)) exitWith { _isOk = false; _proceed = false; }; @@ -48,18 +48,9 @@ if (!isNull _findNearestRock) then { _breaking = false; if (dayz_toolBreaking && _mineChance) then { _breaking = true; - if ("MeleePickaxe" in weapons player) then { - player removeWeapon "MeleePickaxe"; - } else { - if ("ItemPickaxe" in weapons player) then { - player removeWeapon "ItemPickaxe"; - } else { - if (dayz_onBack == "MeleePickaxe") then { - dayz_onBack = ""; - if (!isNull findDisplay 106) then {findDisplay 106 displayCtrl 1209 ctrlSetText "";}; - }; - }; - }; + if ("ItemPickaxe" in weapons player) then { + player removeWeapon "ItemPickaxe"; + }; if (!("ItemPickaxeBroken" in weapons player)) then { player addWeapon "ItemPickaxeBroken"; }; diff --git a/SQF/dayz_code/actions/player_surrender.sqf b/SQF/dayz_code/actions/player_surrender.sqf index 2ef9fa5e4..d6eae7fd7 100644 --- a/SQF/dayz_code/actions/player_surrender.sqf +++ b/SQF/dayz_code/actions/player_surrender.sqf @@ -32,6 +32,7 @@ if (_canDo && !DZE_Surrender && !(player isKindOf "PZombie_VB")) then { if (dayz_onBack != "") then { [dayz_onBack,2,1] call fn_dropItem; dayz_onBack = ""; // Remove from back + player setVariable ["dayz_onBack",dayz_onBack,true]; if (!isNull findDisplay 106) then {findDisplay 106 displayCtrl 1209 ctrlSetText "";}; }; call player_forceSave; diff --git a/SQF/dayz_code/actions/player_switchWeapon.sqf b/SQF/dayz_code/actions/player_switchWeapon.sqf index 83abe06bf..f79efe88e 100644 --- a/SQF/dayz_code/actions/player_switchWeapon.sqf +++ b/SQF/dayz_code/actions/player_switchWeapon.sqf @@ -151,6 +151,8 @@ dz_fn_switchWeapon_swap = { dayz_onBack = [primaryWeapon player,player removeWeapon primaryWeapon player,player addWeapon dayz_onBack] select 0; }; + player setVariable ["dayz_onBack",dayz_onBack,true]; + if (_this) then { player selectWeapon primaryWeapon player; if (IS_MELEE(primaryWeapon player)) then { diff --git a/SQF/dayz_code/actions/remove.sqf b/SQF/dayz_code/actions/remove.sqf index bf35db7f3..9894537ba 100644 --- a/SQF/dayz_code/actions/remove.sqf +++ b/SQF/dayz_code/actions/remove.sqf @@ -137,6 +137,7 @@ if (_brokenTool) then { } else { if (dayz_onBack == "MeleeCrowbar") then { dayz_onBack = ""; // Remove + player setVariable ["dayz_onBack",dayz_onBack,true]; _success = true; if (!isNull (findDisplay 106)) then {((findDisplay 106) displayCtrl 1209) ctrlSetText "";}; }; diff --git a/SQF/dayz_code/compile/player_forceSave.sqf b/SQF/dayz_code/compile/player_forceSave.sqf index 9cde166e9..eccc222d0 100644 --- a/SQF/dayz_code/compile/player_forceSave.sqf +++ b/SQF/dayz_code/compile/player_forceSave.sqf @@ -8,7 +8,7 @@ That will interrupt actions like shooting. For loops use player_regularSave but local _magazineArray = [] call player_countMagazines; -PVDZ_plr_Save = [player, if (player isKindOf "PZombie_VB") then {nil} else {_magazineArray},dayz_onBack,weapons player]; +PVDZ_plr_Save = [player, if (player isKindOf "PZombie_VB") then {nil} else {_magazineArray}]; publicVariableServer "PVDZ_plr_Save"; //diag_log format["Player_forceSave with magazines: %1",_magazineArray]; diff --git a/SQF/dayz_code/compile/player_gearSet.sqf b/SQF/dayz_code/compile/player_gearSet.sqf index 6c3386cd8..37930558d 100644 --- a/SQF/dayz_code/compile/player_gearSet.sqf +++ b/SQF/dayz_code/compile/player_gearSet.sqf @@ -5,6 +5,7 @@ if (count _inventory > 0) then { _mags = _inventory select 1; dayz_onBack = if (count _inventory > 2) then { _inventory select 2 } else { "" }; + player setVariable ["dayz_onBack",dayz_onBack,true]; //Add inventory { diff --git a/SQF/dayz_code/compile/player_humanityMorph.sqf b/SQF/dayz_code/compile/player_humanityMorph.sqf index 008a6f504..2d81df18e 100644 --- a/SQF/dayz_code/compile/player_humanityMorph.sqf +++ b/SQF/dayz_code/compile/player_humanityMorph.sqf @@ -28,6 +28,7 @@ local _ConfirmedBanditKills = player getVariable ["ConfirmedBanditKills",0]; local _friendlies = player getVariable ["friendlies",[]]; local _tagSetting = player getVariable ["DZE_display_name",false]; local _radiostate = player getVariable ["radiostate",false]; +local _dayz_onBack = player getVariable ["dayz_onBack",""]; local _coins = 0; local _bankCoins = 0; local _globalCoins = 0; @@ -97,6 +98,7 @@ player setVariable ["ConfirmedBanditKills",_ConfirmedBanditKills,true]; player setVariable ["friendlies",_friendlies,true]; player setVariable ["DZE_display_name",_tagSetting,true]; player setVariable ["radiostate",_radiostate]; +player setVariable ["dayz_onBack",_dayz_onBack,true]; if (Z_SingleCurrency) then { player setVariable ["cashMoney",_coins,true]; diff --git a/SQF/dayz_code/compile/player_regularSave.sqf b/SQF/dayz_code/compile/player_regularSave.sqf index 09172e247..8aa0aae24 100644 --- a/SQF/dayz_code/compile/player_regularSave.sqf +++ b/SQF/dayz_code/compile/player_regularSave.sqf @@ -15,5 +15,5 @@ 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]; +PVDZ_plr_Save = [player,_magazineArray]; publicVariableServer "PVDZ_plr_Save"; \ No newline at end of file diff --git a/SQF/dayz_server/compile/server_playerSetup.sqf b/SQF/dayz_server/compile/server_playerSetup.sqf index 9f19e3278..44789b63e 100644 --- a/SQF/dayz_server/compile/server_playerSetup.sqf +++ b/SQF/dayz_server/compile/server_playerSetup.sqf @@ -239,7 +239,7 @@ _playerObj setVariable ["lastTime",diag_ticktime]; //set server-side inventory variable to monitor player gear if (count _inventory > 2) then { - _playerObj setVariable["ServerMagArray",[_inventory select 1,_inventory select 2,_inventory select 0], false]; + _playerObj setVariable["ServerMagArray",_inventory select 1, false]; }; //Record Player Login/LogOut diff --git a/SQF/dayz_server/compile/server_playerSync.sqf b/SQF/dayz_server/compile/server_playerSync.sqf index 90aeefb20..a0695a6b5 100644 --- a/SQF/dayz_server/compile/server_playerSync.sqf +++ b/SQF/dayz_server/compile/server_playerSync.sqf @@ -2,8 +2,7 @@ local _character = _this select 0; local _magazines = _this select 1; -local _dayz_onBack = _this select 2; -local _weaponsPlayer = _this select 3; +local _dayz_onBack = _character getVariable ["dayz_onBack",""]; local _characterID = _character getVariable ["characterID","0"]; local _playerUID = getPlayerUID _character; local _charPos = getPosATL _character; @@ -41,7 +40,7 @@ local _usec_Dead = _character getVariable ["USEC_isDead",false]; local _lastTime = _character getVariable ["lastTime",-1]; local _modelChk = _character getVariable ["model_CHK",""]; local _temp = round (_character getVariable ["temperature",100]); -local _lastMagazines = _character getVariable ["ServerMagArray",[[],"",[]]]; +local _lastMagazines = _character getVariable ["ServerMagArray",[]]; //Get difference between current stats and stats at last sync local _statsDiff = [_character,_playerUID] call server_getStatsDiff; _humanity = _statsDiff select 0; @@ -54,17 +53,12 @@ local _charPosLen = count _charPos; local _magTemp = []; if (!isNil "_magazines") then { - _playerGear = [_weaponsPlayer,_magazines,_dayz_onBack]; - _character setVariable["ServerMagArray",[_magazines,_dayz_onBack,_weaponsPlayer], false]; + _playerGear = [weapons _character,_magazines,_dayz_onBack]; + _character setVariable["ServerMagArray",_magazines, false]; } else { //check Magazines everytime they aren't sent by player_forceSave - _magTemp = (_lastMagazines select 0); - if (isNil "_dayz_onBack") then { - _dayz_onBack = _lastMagazines select 1; - }; - if (isNil "_weaponsPlayer") then { - _weaponsPlayer = _lastMagazines select 2; - }; + _magTemp = _lastMagazines; + if (count _magTemp > 0) then { _magazines = [(magazines _character),20] call array_reduceSize; { @@ -81,16 +75,15 @@ if (!isNil "_magazines") then { } else { _magTemp set [_forEachIndex, "0"]; }; - } forEach (_lastMagazines select 0); + } forEach _lastMagazines; _magazines = _magTemp - ["0"]; - _magazines = [_magazines,_dayz_onBack,_weaponsPlayer]; _character setVariable["ServerMagArray",_magazines, false]; - _playerGear = [_magazines select 2,_magazines select 0,_magazines select 1]; + _playerGear = [weapons _character,_magazines,_dayz_onBack]; } else { - _magazines = [_magTemp,_dayz_onBack,_weaponsPlayer]; + _magazines = _magTemp; }; _character setVariable["ServerMagArray",_magazines, false]; - _playerGear = [_magazines select 2,_magazines select 0,_magazines select 1]; + _playerGear = [weapons _character,_magazines,_dayz_onBack]; }; //Check if update is requested