Fix weapon dupe with server_playerSync

This reverts all the last changes to server_playerSync and creates a new global variable for dayz_onBack. This should be the best way to save the gear correct and still get dayz_onBack if the player leaves the server. This change removes the constant sending of the whole player inventory over the network from force or regluar_save. It should no longer be needed since the server does the counting now.
This commit is contained in:
A Man
2021-08-19 16:46:06 +02:00
parent 032e09c03e
commit 9852778ba9
14 changed files with 44 additions and 50 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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
};

View File

@@ -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 "";

View File

@@ -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";
};

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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 "";};
};