mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 04:02:37 +03:00
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:
@@ -135,6 +135,7 @@ if (Z_SellingFrom == 2) then {
|
|||||||
if (_type == "trade_weapons") then {_name = configFile >> "CfgWeapons" >> _name;};
|
if (_type == "trade_weapons") then {_name = configFile >> "CfgWeapons" >> _name;};
|
||||||
if (_x select 0 == dayz_onBack) then {
|
if (_x select 0 == dayz_onBack) then {
|
||||||
dayz_onBack = ""; // Remove from back
|
dayz_onBack = ""; // Remove from back
|
||||||
|
player setVariable ["dayz_onBack",dayz_onBack,true];
|
||||||
_localResult = 1;
|
_localResult = 1;
|
||||||
} else {
|
} else {
|
||||||
_localResult = [player,_name,1] call BIS_fnc_invRemove; // Use config for BIS_fnc_invRemove
|
_localResult = [player,_name,1] call BIS_fnc_invRemove; // Use config for BIS_fnc_invRemove
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ call gear_ui_init;
|
|||||||
|
|
||||||
if (_item == dayz_onBack && carryClick) then {
|
if (_item == dayz_onBack && carryClick) then {
|
||||||
dayz_onBack = "";
|
dayz_onBack = "";
|
||||||
|
player setVariable ["dayz_onBack",dayz_onBack,true];
|
||||||
carryClick = false;
|
carryClick = false;
|
||||||
((findDisplay 106) displayCtrl 1209) ctrlSetText "";
|
((findDisplay 106) displayCtrl 1209) ctrlSetText "";
|
||||||
_removed = true;
|
_removed = true;
|
||||||
|
|||||||
@@ -17,13 +17,12 @@ call gear_ui_init;
|
|||||||
if (_item in ["ItemHatchet","ItemCrowbar","ItemMachete","ItemFishingPole","ItemSledge"]) then {
|
if (_item in ["ItemHatchet","ItemCrowbar","ItemMachete","ItemFishingPole","ItemSledge"]) then {
|
||||||
//free primary slot for new melee (remember item to add after)
|
//free primary slot for new melee (remember item to add after)
|
||||||
call {
|
call {
|
||||||
if (_item == "ItemHatchet") exitwith {player removeWeapon "ItemHatchet"; dayz_onBack = "MeleeHatchet";};
|
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";};
|
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";};
|
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";};
|
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";};
|
if (_item == "ItemSledge") exitwith {player removeWeapon "ItemSledge"; dayz_onBack = "MeleeSledge";player setVariable ["dayz_onBack",dayz_onBack,true];};
|
||||||
};
|
};
|
||||||
disableSerialization;
|
disableSerialization;
|
||||||
[[(findDisplay 106)],"onLBSelChanged"] spawn fn_handleGear; //update back
|
[[(findDisplay 106)],"onLBSelChanged"] spawn fn_handleGear; //update back
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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"];
|
private ["_item","_config","_onLadder","_consume","_bag","_droppedType"];
|
||||||
|
|
||||||
disableSerialization;
|
disableSerialization;
|
||||||
@@ -8,23 +11,22 @@ _droppedType = getText (_config >> "droppeditem");
|
|||||||
//Make sure the player still has the tool this script was spawned with
|
//Make sure the player still has the tool this script was spawned with
|
||||||
if ((dayz_onBack != _item && carryClick) or (!(player hasWeapon _item) && !carryClick)) exitWith {
|
if ((dayz_onBack != _item && carryClick) or (!(player hasWeapon _item) && !carryClick)) exitWith {
|
||||||
format[localize "str_player_30",getText (_config >> "displayName")] call dayz_rollingMessages;
|
format[localize "str_player_30",getText (_config >> "displayName")] call dayz_rollingMessages;
|
||||||
|
dayz_actionInProgress = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
|
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
|
||||||
if (_onLadder) exitWith { localize "str_player_21" call dayz_rollingMessages; };
|
if (_onLadder) exitWith {dayz_actionInProgress = false; localize "str_player_21" call dayz_rollingMessages; };
|
||||||
if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; };
|
|
||||||
dayz_actionInProgress = true;
|
|
||||||
|
|
||||||
call gear_ui_init;
|
call gear_ui_init;
|
||||||
|
|
||||||
_consume = ([] + getArray (_config >> "magazines")) select 0;
|
_consume = ([] + getArray (_config >> "magazines")) select 0;
|
||||||
|
|
||||||
if (_item == dayz_onBack && carryClick) then {
|
if (_item == dayz_onBack && carryClick) then {
|
||||||
switch DayZ_onBack do {
|
call {
|
||||||
case "MeleeHatchet": {_item = "ItemHatchet"; dayz_onBack = "";};
|
if (dayZ_onBack == "MeleeHatchet") exitWith {_item = "ItemHatchet"; dayz_onBack = ""; player setVariable ["dayz_onBack",dayz_onBack,true];};
|
||||||
case "MeleeCrowbar": {_item = "ItemCrowbar"; dayz_onBack = "";};
|
if (dayZ_onBack == "MeleeCrowbar") exitWith {_item = "ItemCrowbar"; dayz_onBack = "";player setVariable ["dayz_onBack",dayz_onBack,true];};
|
||||||
case "MeleeMachete": {_item = "ItemMachete"; dayz_onBack = "";};
|
if (dayZ_onBack == "MeleeMachete") exitWith {_item = "ItemMachete"; dayz_onBack = "";player setVariable ["dayz_onBack",dayz_onBack,true];};
|
||||||
case "MeleeSledge": {_item = "ItemSledge"; dayz_onBack = "";};
|
if (dayZ_onBack == "MeleeSledge") exitWith {_item = "ItemSledge"; dayz_onBack = "";player setVariable ["dayz_onBack",dayz_onBack,true];};
|
||||||
};
|
};
|
||||||
carryClick = false;
|
carryClick = false;
|
||||||
((findDisplay 106) displayCtrl 1209) ctrlSetText "";
|
((findDisplay 106) displayCtrl 1209) ctrlSetText "";
|
||||||
|
|||||||
@@ -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"];
|
private ["_mineChance","_breaking","_counter","_rocks","_findNearestRock","_objName","_countOut","_isOk","_proceed","_finished","_itemOut","_weapons"];
|
||||||
|
|
||||||
_item = _this;
|
_item = _this;
|
||||||
call gear_ui_init;
|
call gear_ui_init;
|
||||||
closeDialog 1;
|
closeDialog 1;
|
||||||
|
|
||||||
if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; };
|
|
||||||
dayz_actionInProgress = true;
|
|
||||||
|
|
||||||
// allowed rocks list move this later
|
// 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"];
|
_rocks = ["r2_boulder1.p3d","r2_boulder2.p3d","r2_rock1.p3d","r2_rock2.p3d","r2_rocktower.p3d","r2_rockwall.p3d","r2_stone.p3d"];
|
||||||
_findNearestRock = objNull;
|
_findNearestRock = objNull;
|
||||||
@@ -37,7 +37,7 @@ if (!isNull _findNearestRock) then {
|
|||||||
_weapons set [count _weapons,dayz_onBack];
|
_weapons set [count _weapons,dayz_onBack];
|
||||||
|
|
||||||
//Make sure player did not drop pickaxe
|
//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;
|
_isOk = false;
|
||||||
_proceed = false;
|
_proceed = false;
|
||||||
};
|
};
|
||||||
@@ -48,18 +48,9 @@ if (!isNull _findNearestRock) then {
|
|||||||
_breaking = false;
|
_breaking = false;
|
||||||
if (dayz_toolBreaking && _mineChance) then {
|
if (dayz_toolBreaking && _mineChance) then {
|
||||||
_breaking = true;
|
_breaking = true;
|
||||||
if ("MeleePickaxe" in weapons player) then {
|
if ("ItemPickaxe" in weapons player) then {
|
||||||
player removeWeapon "MeleePickaxe";
|
player removeWeapon "ItemPickaxe";
|
||||||
} 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 (!("ItemPickaxeBroken" in weapons player)) then {
|
if (!("ItemPickaxeBroken" in weapons player)) then {
|
||||||
player addWeapon "ItemPickaxeBroken";
|
player addWeapon "ItemPickaxeBroken";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ if (_canDo && !DZE_Surrender && !(player isKindOf "PZombie_VB")) then {
|
|||||||
if (dayz_onBack != "") then {
|
if (dayz_onBack != "") then {
|
||||||
[dayz_onBack,2,1] call fn_dropItem;
|
[dayz_onBack,2,1] call fn_dropItem;
|
||||||
dayz_onBack = ""; // Remove from back
|
dayz_onBack = ""; // Remove from back
|
||||||
|
player setVariable ["dayz_onBack",dayz_onBack,true];
|
||||||
if (!isNull findDisplay 106) then {findDisplay 106 displayCtrl 1209 ctrlSetText "";};
|
if (!isNull findDisplay 106) then {findDisplay 106 displayCtrl 1209 ctrlSetText "";};
|
||||||
};
|
};
|
||||||
call player_forceSave;
|
call player_forceSave;
|
||||||
|
|||||||
@@ -151,6 +151,8 @@ dz_fn_switchWeapon_swap = {
|
|||||||
dayz_onBack = [primaryWeapon player,player removeWeapon primaryWeapon player,player addWeapon dayz_onBack] select 0;
|
dayz_onBack = [primaryWeapon player,player removeWeapon primaryWeapon player,player addWeapon dayz_onBack] select 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
player setVariable ["dayz_onBack",dayz_onBack,true];
|
||||||
|
|
||||||
if (_this) then {
|
if (_this) then {
|
||||||
player selectWeapon primaryWeapon player;
|
player selectWeapon primaryWeapon player;
|
||||||
if (IS_MELEE(primaryWeapon player)) then {
|
if (IS_MELEE(primaryWeapon player)) then {
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ if (_brokenTool) then {
|
|||||||
} else {
|
} else {
|
||||||
if (dayz_onBack == "MeleeCrowbar") then {
|
if (dayz_onBack == "MeleeCrowbar") then {
|
||||||
dayz_onBack = ""; // Remove
|
dayz_onBack = ""; // Remove
|
||||||
|
player setVariable ["dayz_onBack",dayz_onBack,true];
|
||||||
_success = true;
|
_success = true;
|
||||||
if (!isNull (findDisplay 106)) then {((findDisplay 106) displayCtrl 1209) ctrlSetText "";};
|
if (!isNull (findDisplay 106)) then {((findDisplay 106) displayCtrl 1209) ctrlSetText "";};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ That will interrupt actions like shooting. For loops use player_regularSave but
|
|||||||
|
|
||||||
local _magazineArray = [] call player_countMagazines;
|
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";
|
publicVariableServer "PVDZ_plr_Save";
|
||||||
|
|
||||||
//diag_log format["Player_forceSave with magazines: %1",_magazineArray];
|
//diag_log format["Player_forceSave with magazines: %1",_magazineArray];
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ if (count _inventory > 0) then {
|
|||||||
_mags = _inventory select 1;
|
_mags = _inventory select 1;
|
||||||
|
|
||||||
dayz_onBack = if (count _inventory > 2) then { _inventory select 2 } else { "" };
|
dayz_onBack = if (count _inventory > 2) then { _inventory select 2 } else { "" };
|
||||||
|
player setVariable ["dayz_onBack",dayz_onBack,true];
|
||||||
|
|
||||||
//Add inventory
|
//Add inventory
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ local _ConfirmedBanditKills = player getVariable ["ConfirmedBanditKills",0];
|
|||||||
local _friendlies = player getVariable ["friendlies",[]];
|
local _friendlies = player getVariable ["friendlies",[]];
|
||||||
local _tagSetting = player getVariable ["DZE_display_name",false];
|
local _tagSetting = player getVariable ["DZE_display_name",false];
|
||||||
local _radiostate = player getVariable ["radiostate",false];
|
local _radiostate = player getVariable ["radiostate",false];
|
||||||
|
local _dayz_onBack = player getVariable ["dayz_onBack",""];
|
||||||
local _coins = 0;
|
local _coins = 0;
|
||||||
local _bankCoins = 0;
|
local _bankCoins = 0;
|
||||||
local _globalCoins = 0;
|
local _globalCoins = 0;
|
||||||
@@ -97,6 +98,7 @@ player setVariable ["ConfirmedBanditKills",_ConfirmedBanditKills,true];
|
|||||||
player setVariable ["friendlies",_friendlies,true];
|
player setVariable ["friendlies",_friendlies,true];
|
||||||
player setVariable ["DZE_display_name",_tagSetting,true];
|
player setVariable ["DZE_display_name",_tagSetting,true];
|
||||||
player setVariable ["radiostate",_radiostate];
|
player setVariable ["radiostate",_radiostate];
|
||||||
|
player setVariable ["dayz_onBack",_dayz_onBack,true];
|
||||||
|
|
||||||
if (Z_SingleCurrency) then {
|
if (Z_SingleCurrency) then {
|
||||||
player setVariable ["cashMoney",_coins,true];
|
player setVariable ["cashMoney",_coins,true];
|
||||||
|
|||||||
@@ -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"];
|
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";
|
publicVariableServer "PVDZ_plr_Save";
|
||||||
@@ -239,7 +239,7 @@ _playerObj setVariable ["lastTime",diag_ticktime];
|
|||||||
|
|
||||||
//set server-side inventory variable to monitor player gear
|
//set server-side inventory variable to monitor player gear
|
||||||
if (count _inventory > 2) then {
|
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
|
//Record Player Login/LogOut
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
local _character = _this select 0;
|
local _character = _this select 0;
|
||||||
local _magazines = _this select 1;
|
local _magazines = _this select 1;
|
||||||
local _dayz_onBack = _this select 2;
|
local _dayz_onBack = _character getVariable ["dayz_onBack",""];
|
||||||
local _weaponsPlayer = _this select 3;
|
|
||||||
local _characterID = _character getVariable ["characterID","0"];
|
local _characterID = _character getVariable ["characterID","0"];
|
||||||
local _playerUID = getPlayerUID _character;
|
local _playerUID = getPlayerUID _character;
|
||||||
local _charPos = getPosATL _character;
|
local _charPos = getPosATL _character;
|
||||||
@@ -41,7 +40,7 @@ local _usec_Dead = _character getVariable ["USEC_isDead",false];
|
|||||||
local _lastTime = _character getVariable ["lastTime",-1];
|
local _lastTime = _character getVariable ["lastTime",-1];
|
||||||
local _modelChk = _character getVariable ["model_CHK",""];
|
local _modelChk = _character getVariable ["model_CHK",""];
|
||||||
local _temp = round (_character getVariable ["temperature",100]);
|
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
|
//Get difference between current stats and stats at last sync
|
||||||
local _statsDiff = [_character,_playerUID] call server_getStatsDiff;
|
local _statsDiff = [_character,_playerUID] call server_getStatsDiff;
|
||||||
_humanity = _statsDiff select 0;
|
_humanity = _statsDiff select 0;
|
||||||
@@ -54,17 +53,12 @@ local _charPosLen = count _charPos;
|
|||||||
local _magTemp = [];
|
local _magTemp = [];
|
||||||
|
|
||||||
if (!isNil "_magazines") then {
|
if (!isNil "_magazines") then {
|
||||||
_playerGear = [_weaponsPlayer,_magazines,_dayz_onBack];
|
_playerGear = [weapons _character,_magazines,_dayz_onBack];
|
||||||
_character setVariable["ServerMagArray",[_magazines,_dayz_onBack,_weaponsPlayer], false];
|
_character setVariable["ServerMagArray",_magazines, false];
|
||||||
} else {
|
} else {
|
||||||
//check Magazines everytime they aren't sent by player_forceSave
|
//check Magazines everytime they aren't sent by player_forceSave
|
||||||
_magTemp = (_lastMagazines select 0);
|
_magTemp = _lastMagazines;
|
||||||
if (isNil "_dayz_onBack") then {
|
|
||||||
_dayz_onBack = _lastMagazines select 1;
|
|
||||||
};
|
|
||||||
if (isNil "_weaponsPlayer") then {
|
|
||||||
_weaponsPlayer = _lastMagazines select 2;
|
|
||||||
};
|
|
||||||
if (count _magTemp > 0) then {
|
if (count _magTemp > 0) then {
|
||||||
_magazines = [(magazines _character),20] call array_reduceSize;
|
_magazines = [(magazines _character),20] call array_reduceSize;
|
||||||
{
|
{
|
||||||
@@ -81,16 +75,15 @@ if (!isNil "_magazines") then {
|
|||||||
} else {
|
} else {
|
||||||
_magTemp set [_forEachIndex, "0"];
|
_magTemp set [_forEachIndex, "0"];
|
||||||
};
|
};
|
||||||
} forEach (_lastMagazines select 0);
|
} forEach _lastMagazines;
|
||||||
_magazines = _magTemp - ["0"];
|
_magazines = _magTemp - ["0"];
|
||||||
_magazines = [_magazines,_dayz_onBack,_weaponsPlayer];
|
|
||||||
_character setVariable["ServerMagArray",_magazines, false];
|
_character setVariable["ServerMagArray",_magazines, false];
|
||||||
_playerGear = [_magazines select 2,_magazines select 0,_magazines select 1];
|
_playerGear = [weapons _character,_magazines,_dayz_onBack];
|
||||||
} else {
|
} else {
|
||||||
_magazines = [_magTemp,_dayz_onBack,_weaponsPlayer];
|
_magazines = _magTemp;
|
||||||
};
|
};
|
||||||
_character setVariable["ServerMagArray",_magazines, false];
|
_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
|
//Check if update is requested
|
||||||
|
|||||||
Reference in New Issue
Block a user