Jump to content
  • 0

Sometimes character stops updating after skin change


f3cuk

Question

Since updating to 1051 several people have been complaining that sometimes their character seemed to go back in time after they had logged in. Untill today I couldn't pinpoint what was happening but now i think i found it. Sometimes when a player changes skin, his or her character stops updating from that point on. Resulting in progress loss when they logout and log back in, even simply going in and out the lobby will "reset" their character to the state they were in just before they changed clothes.

 

One user even reported that he died » ragequit » after logging back in a few hours later, was alive and had most of his gear back. He asked me if i did a rollback on the database, which we did not. It did not make sense to me but now i'm figuring he had probably just changed skins before and got reset to that.
 

Could anyone confirm this issue? Or did i mess it up all by myself :P

Link to comment
Share on other sites

Recommended Posts

  • 0

Ah okay. You should know that player_switchmodel.sqf is also run when you login (without the humanitymorph.sqf). This is why i had to put in _charidchanged stuff which you have taken out again.

Try something like this.

 

player_humanityMorph.sqf

 

private ["_updates","_playerUID","_charID","_humanity","_worldspace","_model","_friendlies","_fractures","_old","_medical","_zombieKills","_headShots","_humanKills","_banditKills","_tagList","_display"];

_playerUID     = _this select 0;
_charID     = _this select 1;
_model         = _this select 2;

if (typeOF player == _model) exitWith {cutText ['You already wear this Skin!', 'PLAIN'];};

player setVariable ["inTransit",true,true];

_old = player;
player allowDamage false;

player removeEventHandler ["FiredNear",eh_player_killed];
player removeEventHandler ["HandleDamage",mydamage_eh1];
player removeEventHandler ["Killed",mydamage_eh3];
player removeEventHandler ["Fired",mydamage_eh2];

_updates =         player getVariable["updatePlayer",[false,false,false,false,false]];
_updates set [0,true];
player setVariable["updatePlayer",_updates,true];
dayz_unsaved = true;
//Logout
_humanity        = player getVariable["humanity",0];
_medical         = player call player_sumMedical;
_worldspace     = [round(direction player),getPosATL player];
_zombieKills     = player getVariable ["zombieKills",0];
_headShots         = player getVariable ["headShots",0];
_humanKills     = player getVariable ["humanKills",0];
_banditKills     = player getVariable ["banditKills",0];
_friendlies        = player getVariable ["friendlies",[]];
_tagList        = player getVariable ["tagList",[]];

//Switch
    _model call player_switchModel;

//Login

//set medical values
if (count _medical > 0) then {
    player setVariable["USEC_isDead",(_medical select 0),true];
    player setVariable["NORRN_unconscious", (_medical select 1), true];
    player setVariable["USEC_infected",(_medical select 2),true];
    player setVariable["USEC_injured",(_medical select 3),true];
    player setVariable["USEC_inPain",(_medical select 4),true];
    player setVariable["USEC_isCardiac",(_medical select 5),true];
    player setVariable["USEC_lowBlood",(_medical select 6),true];
    player setVariable["USEC_BloodQty",(_medical select 7),true];
    player setVariable["unconsciousTime",(_medical select 10),true];
    
    //Add Wounds
    {
        player setVariable[_x,true,true];
        //["usecBleed",[player,_x,_hit]] call broadcastRpcCallAll;
        usecBleed = [player,_x,0];
        publicVariable "usecBleed";
    } count (_medical select 8);
    
    //Add fractures
    _fractures = (_medical select 9);
//    player setVariable ["hit_legs",(_fractures select 0),true];
//    player setVariable ["hit_hands",(_fractures select 1),true];
    [player,"legs", (_fractures select 0)] call object_setHit;
    [player,"hands", (_fractures select 1)] call object_setHit;
} else {
    //Reset Fractures
    player setVariable ["hit_legs",0,true];
    player setVariable ["hit_hands",0,true];
    player setVariable ["USEC_injured",false,true];
    player setVariable ["USEC_inPain",false,true];    
};


//General Stats
player setVariable["humanity",_humanity,true];
player setVariable["zombieKills",_zombieKills,true];
player setVariable["headShots",_headShots,true];
player setVariable["humanKills",_humanKills,true];
player setVariable["banditKills",_banditKills,true];
player setVariable["CharacterID",_charID,true];
player setVariable["worldspace",_worldspace,true];
player setVariable["friendlies",_friendlies,true];
player setVariable["tagList",_tagList,true];
player setVariable["inTransit",false,true];

//code for this on the server is missing
//["PVDZE_plr_Morph",[_charID,player,_playerUID,[_zombieKills,_headShots,_humanKills,_banditKills],_humanity]] call callRpcProcedure;

call dayz_resetSelfActions;

eh_player_killed = player addeventhandler ["FiredNear",{_this call player_weaponFiredNear;} ];

[player] call fnc_usec_damageHandle;
player allowDamage true;

player addWeapon "Loot";
player addWeapon "Flare";

//melee check
    _wpnType = primaryWeapon player;
    _ismelee = (gettext (configFile >> "CfgWeapons" >> _wpnType >> "melee"));
        if (_ismelee == "true") then {
                call dayz_meleeMagazineCheck;
        };

sleep 0.1;

if (!isNull _old) then {
    // this should not be needed as player is deleted in player_switchModel?
    deleteVehicle _old;
};

sleep 0.1;

 

player_switchmodel.sqf

private ["_cId","_weapons","_backpackWpn","_backpackMag","_currentWpn","_backpackWpnTypes","_backpackWpnQtys","_countr","_class","_position","_dir","_currentAnim","_tagSetting","_playerUID","_countMags","_magazines","_primweapon","_secweapon","_newBackpackType","_muzzles","_oldUnit","_group","_newUnit","_playerObjName","_wpnType","_ismelee"];

_class             = _this;
_position         = getPosATL player;
_dir             = getDir player;
_currentAnim     = animationState player;
_tagSetting = player getVariable["DZE_display_name",false];
_playerUID = getPlayerUID player;
_weapons     = weapons player;
_countMags = call player_countMagazines;
_magazines = _countMags select 0;
_cashMoney = player getVariable["cashMoney",0];
_bankMoney = player getVariable["bankMoney",0];

if ((_playerUID == dayz_playerUID) && (count _magazines == 0) && (count (magazines player) > 0 )) exitWith {cutText [(localize "str_epoch_player_17"), "PLAIN DOWN"]};

_primweapon    = primaryWeapon player;
_secweapon    = secondaryWeapon player;

if(!(_primweapon in _weapons) && _primweapon != "") then {
    _weapons = _weapons + [_primweapon];
};

if(!(_secweapon in _weapons) && _secweapon != "") then {
    _weapons = _weapons + [_secweapon];
};

//BackUp Backpack
dayz_myBackpack = unitBackpack player;
_newBackpackType = (typeOf dayz_myBackpack);
if(_newBackpackType != "") then {
    _backpackWpn = getWeaponCargo unitBackpack player;
    _backpackMag = _countMags select 1;
};

//Get Muzzle
_currentWpn = currentWeapon player;
_muzzles = getArray(configFile >> "cfgWeapons" >> _currentWpn >> "muzzles");
if (count _muzzles > 1) then {
    _currentWpn = currentMuzzle player;
};

//Secure Player for Transformation
player setPosATL dayz_spawnPos;

//BackUp Player Object
_oldUnit = player;
_cId = player getVariable["CharacterID",0]; // or : _oldUnit getVariable["CharacterID",0];

/**********************************/
//DONT USE player AFTER THIS POINT//
/**********************************/

//Create New Character
_group = createGroup WEST;
_newUnit = _group createUnit [_class,dayz_spawnPos,[],0,"NONE"];
_newUnit setPosATL _position;
_newUnit setDir _dir;
[_newUnit] joinSilent createGroup WEST;
_newUnit setVariable ["CharacterID",_cId,true];

//Soul start: SC Edit >>> readding variables used by single currency mod.
_newUnit setVariable ["cashMoney",_cashMoney,true];
_newUnit setVariable ["bankMoney",_bankMoney];
//Soul end: SC Edit

//Clear New Character
{_newUnit removeMagazine _x;} count  magazines _newUnit;
removeAllWeapons _newUnit;    

//Equip New Charactar
{
    if (typeName _x == "ARRAY") then {if ((count _x) > 0) then {_newUnit addMagazine [(_x select 0), (_x select 1)]; }; } else { _newUnit addMagazine _x; };
} count _magazines;

{
    _newUnit addWeapon _x;
} count _weapons;

//Check && Compare it
if(str(_weapons) != str(weapons _newUnit)) then {
    //Get Differecnce
    {
        _weapons = _weapons - [_x];
    } count (weapons _newUnit);
    
    //Add the Missing
    {
        _newUnit addWeapon _x;
    } count _weapons;
};

if(_primweapon !=  (primaryWeapon _newUnit)) then {
    _newUnit addWeapon _primweapon;        
};
if (_primweapon == "MeleeCrowbar") then {
    _newUnit addMagazine 'crowbar_swing';
};
if (_primweapon == "MeleeSledge") then {
    _newUnit addMagazine 'sledge_swing';
};
if (_primweapon == "MeleeHatchet_DZE") then {
    _newUnit addMagazine 'Hatchet_Swing';
};
if (_primweapon == "MeleeMachete") then {
    _newUnit addMagazine 'Machete_swing';
};
if (_primweapon == "MeleeFishingPole") then {
    _newUnit addMagazine 'Fishing_Swing';
};

if(_secweapon != (secondaryWeapon _newUnit) && _secweapon != "") then {
    _newUnit addWeapon _secweapon;        
};
_switchUnit = {
    addSwitchableUnit _newUnit;
    setPlayable _newUnit;
    selectPlayer _newUnit;
        
    removeAllWeapons _oldUnit;
    {_oldUnit removeMagazine _x;} count  magazines _oldUnit;
    deleteVehicle _oldUnit;
    if(_currentWpn != "") then {_newUnit selectWeapon _currentWpn;};
};
//Add && Fill BackPack
if (!isNil "_newBackpackType") then {
    if (_newBackpackType != "") then {
        _newUnit addBackpack _newBackpackType;
        dayz_myBackpack = unitBackpack _newUnit;
        //Weapons
        _backpackWpnTypes = [];
        _backpackWpnQtys = [];
        if (count _backpackWpn > 0) then {
            _backpackWpnTypes = _backpackWpn select 0;
            _backpackWpnQtys = _backpackWpn select 1;
        };
        [] call _switchUnit;
        if (gear_done) then {sleep 0.001;};
        ["1"] call gearDialog_create;
        //magazines
        _countr = 0;
        {
            if (!(isClass(configFile >> "CfgWeapons" >> _x))) then {
                _countr = _countr + 1;
                if ((typeName _x) != "STRING") then {
                    (unitBackpack player) addMagazineCargoGlobal [(_x select 0), 1];
                    _idc = 4999 + _countr;
                    _idc setIDCAmmoCount (_x select 1);
                } else {
                    (unitBackpack player) addMagazineCargoGlobal [_x, 1];
                };
            };
        } count _backpackMag;
        (findDisplay 106) closeDisplay 0;
        _countr = 0;
        {
            (unitBackpack player) addWeaponCargoGlobal [_x,(_backpackWpnQtys select _countr)];
            _countr = _countr + 1;
        } count _backpackWpnTypes;
    } else { [] call _switchUnit; };
} else { [] call _switchUnit; };
[objNull, player, rSwitchMove,_currentAnim] call RE;
player disableConversation true;

//player setVariable ["bodyName",dayz_playerName,true]; //Outcommit (Issue #991) - Also removed in DayZ Mod 1.8

if (_tagSetting) then {
    DZE_ForceNameTags = true;
};

_playerUID = getPlayerUID player;
_playerObjName = format["PVDZE_player%1",_playerUID];
call compile format["%1 = player;",_playerObjName];
publicVariableServer _playerObjName; //Outcommit in DayZ 1.8 No clue for what this is - Skaronator

//melee check
_wpnType = primaryWeapon player;
_ismelee = (gettext (configFile >> "CfgWeapons" >> _wpnType >> "melee"));
if (_ismelee == "true") then {
    call dayz_meleeMagazineCheck;
};

//reveal the same objects we do on login
{player reveal _x} count (nearestObjects [getPosATL player, dayz_reveal, 50]);

 

That should work better.

Link to comment
Share on other sites

  • 0

I thought of that myself but I figured that charidchanged was the equivalent of Zupa's fix. That's what I get for assuming things before reassuring I guess. Anyway thanks for the fix, will give it a try right now.

 

Edit// Yup, seems to be doing the trick. Thanks!

Link to comment
Share on other sites

  • 0

I didnt mean any disrespect, could be an older version, but i had that issue with dzgm, which i quicly fixed.

 

It didnt made the whole array a null. But sometimes ( i dont knwo what triggered it), probably somebody changes clothes while being in a group. Then for example u had this 

 

["35","36",<null>]

 

The 201 call fails to execute that, so your character never updated it.

 

SOme modifications to the dzgm fixed that issue for me.

 

Maybe it's some other script interfering, but mainly that was the only script using the friendly array ( plotMagement uses a different array).

 

For example the following guy had the same problem:

 

http://epochmod.com/forum/index.php?/topic/16113-force-update-on-logout/?hl=%2Bdze_friendlysaving+%2Bfalse%3B#entry121723

 

Look at the friendly array in his 201 call.

Link to comment
Share on other sites

  • 0

Yeah the current fix i posted is overly complicated, but there is no part you should leave out. I'll do a new - more simple - one tonight. It only involves changing 4 files (player_wearclothes.sqf, player_humanitymorph and player_switchmodel.sqf and server_playersync.sqf). I'll use the default 1051 files as a reference.

so in message #101 you mentioned you were gonna do a write up later tonight. that is still happening right?

still looking forward to a complete solution to this issue...

Link to comment
Share on other sites

  • 0

Find

[_newUnit] joinSilent createGroup WEST;

Add below

_newUnit setVariable["CharacterID",_charID,true];

 

Just to clarify, you probably picked this up from my file. The original player_switchModel.sqf doesn't have that line:

[_newUnit] joinSilent createGroup WEST;

But it doesn't hurt to add either. I added it because my clothing script had the slight possibility of changing sides from BLUFOR to something else when changing skins.

 

 

For guys missing the joinSilent line you can just add the "_newUnit setVariable["CharacterID",_charID,true];" line under:

_newUnit setDir _dir;
Link to comment
Share on other sites

  • 0

Also another thing is that you put the _inTransit calls in player_wearClothes.sqf. This works fine for regular players and not very heavily modified Epoch but if you're an admin and don't actually use the clothing items to change skins but instead a menu of some sort then the _inTransit method won't work. That's because admin menus and scripts like that don't call out player_wearClothes to change skins. They go straight for the humanityMorph. The way you helped me with my files should work the best I think.

Link to comment
Share on other sites

  • 0

Sorry mate, kinda got sidetracked tonight by a friend tonight. Really tired right now so I'll do a quick writeup which should fix the issues. (@ebaydayz: Like you i feel this is a workaround, but it is a decent working one and debugging the backpack drove me crazy).

<snip>

 

Just to clarify, you probably picked this up from my file. The original player_switchModel.sqf doesn't have that line:

<snip>

 

Thanks a lot guys! I will try this ASAP. Expect question bombardment if it doesn't work :D

Link to comment
Share on other sites

  • 0

@Rocu: Thanks for noticing :), updated my post.

 

Thanks a lot guys! I will try this ASAP. Expect question bombardment if it doesn't work :D

 

Good luck, needless to say -> Test this on a dev server first :)

Link to comment
Share on other sites

  • 0

You will need to modify scripts.txt if you have this filter: 5 "call player_humanityMorph"

I haven't done so yet but just noticed while testing.

Also getting errors following your instructions.

11:27:27 Error in expression <_name) + " as no characterID");

};

if (_inTransit) exitWith {

diag_log ("NOTICE>

11:27:27 Error position: <_inTransit) exitWith {

diag_log ("NOTICE>

11:27:27 Error Undefined variable in expression: _intransit

11:27:27 File z\addons\dayz_server\compile\server_playerSync.sqf, line 39

11:27:29 Error in expression <_name) + " as no characterID");

};

Link to comment
Share on other sites

  • 0

Okay i have asked our players and none have experienced issues the last couple of days. Although I'm still not confident if the changes really fix the issue, I'm pretty sure they won't do any harm either. If anyone wants to test here goes.

--

Files that are changed with this.

  • player_humanityMorph.sqf
  • player_switchModel.sqf
  • player_monitor.sqf (/dayz_code/system/player_monitor.sqf)
  • player_monitor.fsm (/dayz_code/system/player_monitor.fsm)
  • server_playerSync.sqf (/dayz_server/compile/server_playerSync.sqf)
  • compiles.sqf (/dayz_code/init/compiles.sqf)
  • init.sqf
1.) In your mission folder create a folder called "reset_fix" inside your custom folder.

 

2.) Copy over the following files into that folder (Skip if you already have these in your mission pbo)

  • player_monitor.sqf (/dayz_code/system/player_monitor.sqf)
  • player_monitor.fsm (/dayz_code/system/player_monitor.fsm)
  • compiles.sqf (/dayz_code/init/compiles.sqf)
3.) Open your init.sqf

 

Find

call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf";
Replace

call compile preprocessFileLineNumbers "custom\reset_fix\compiles.sqf";
4.) Open compiles.sqf

 

Find

player_switchModel =        compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_switchModel.sqf";
 

Replace with

player_switchModel =        compile preprocessFileLineNumbers "custom\reset_fix\player_switchModel.sqf";
 

Find

player_humanityMorph =        compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_humanityMorph.sqf";
 

Replace with

player_humanityMorph =        compile preprocessFileLineNumbers "custom\reset_fix\player_humanityMorph.sqf";
 

Find

_model call player_switchModel;
 

Replace with

[_model] call player_switchModel;

5.) Open player_monitor.sqf

Find

_id = [] execFSM "\z\addons\dayz_code\system\player_monitor.fsm";
Replace with

_id = [] execFSM "custom\reset_fix\player_monitor.fsm";

6.) Open player_monitor.fsm

Find

"_model call player_switchModel;" \n
 

Replace with

"[_model] call player_switchModel;" \n
 

7.) Create a file called player_humanityMorph.sqf and place it in the reset_fix folder

 

Add this

private ["_updates","_playerUID","_charID","_humanity","_worldspace","_model","_friendlies","_fractures","_old","_medical","_zombieKills","_headShots","_humanKills","_banditKills","_tagList"];

_playerUID     = _this select 0;
_charID     = _this select 1;
_model         = _this select 2;

diag_log format["DEBUG: PUID: %1 | CHARID: %2 | MODEL: %3 | CURRENTMODEL: %4",_playerUID,_charID,_model,typeOF player];

if (typeOF player == _model) exitWith {cutText ['You already wear this Skin!', 'PLAIN'];};

player allowDamage false;

player removeEventHandler ["FiredNear",eh_player_killed];
player removeEventHandler ["HandleDamage",mydamage_eh1];
player removeEventHandler ["Killed",mydamage_eh3];
player removeEventHandler ["Fired",mydamage_eh2];

_updates =         player getVariable["updatePlayer",[false,false,false,false,false]];
_updates set [0,true];
player setVariable["updatePlayer",_updates,true];
dayz_unsaved = true;

//Logout
_humanity        = player getVariable["humanity",0];
_medical         = player call player_sumMedical;
_worldspace     = [round(direction player),getPosATL player];
_zombieKills     = player getVariable ["zombieKills",0];
_headShots         = player getVariable ["headShots",0];
_humanKills     = player getVariable ["humanKills",0];
_banditKills     = player getVariable ["banditKills",0];
_friendlies        = player getVariable ["friendlies",[]];
_tagList        = player getVariable ["tagList",[]];

//Switch
    [_model,_charID] call player_switchModel;

//Login

//set medical values
if (count _medical > 0) then {
    player setVariable["USEC_isDead",(_medical select 0),true];
    player setVariable["NORRN_unconscious", (_medical select 1), true];
    player setVariable["USEC_infected",(_medical select 2),true];
    player setVariable["USEC_injured",(_medical select 3),true];
    player setVariable["USEC_inPain",(_medical select 4),true];
    player setVariable["USEC_isCardiac",(_medical select 5),true];
    player setVariable["USEC_lowBlood",(_medical select 6),true];
    player setVariable["USEC_BloodQty",(_medical select 7),true];
    player setVariable["unconsciousTime",(_medical select 10),true];
    
    //Add Wounds
    {
        player setVariable[_x,true,true];
        usecBleed = [player,_x,0];
        publicVariable "usecBleed";
    } count (_medical select 8);
    
    //Add fractures
    _fractures = (_medical select 9);
    [player,"legs", (_fractures select 0)] call object_setHit;
    [player,"hands", (_fractures select 1)] call object_setHit;
} else {
    //Reset Fractures
    player setVariable ["hit_legs",0,true];
    player setVariable ["hit_hands",0,true];
    player setVariable ["USEC_injured",false,true];
    player setVariable ["USEC_inPain",false,true];    
};


//General Stats
player setVariable["humanity",_humanity,true];
player setVariable["zombieKills",_zombieKills,true];
player setVariable["headShots",_headShots,true];
player setVariable["humanKills",_humanKills,true];
player setVariable["banditKills",_banditKills,true];
player setVariable["worldspace",_worldspace,true];
player setVariable["friendlies",_friendlies,true];
player setVariable["tagList",_tagList,true];
player setVariable["BIS_noCoreConversations",true];
player setVariable["inTransit",false,true];

call dayz_resetSelfActions;

eh_player_killed = player addeventhandler ["FiredNear",{_this call player_weaponFiredNear;} ];

[player] call fnc_usec_damageHandle;

player allowDamage true;

player addWeapon "Loot";
player addWeapon "Flare";

//melee check
    _wpnType = primaryWeapon player;
    _ismelee = (gettext (configFile >> "CfgWeapons" >> _wpnType >> "melee"));
        if (_ismelee == "true") then {
                call dayz_meleeMagazineCheck;
        };

sleep 0.1;

 

8.) Create a file called player_switchModel.sqf in your reset_fix folder

 

Add this

 

private ["_charidchanged","_weapons","_backpackWpn","_backpackMag","_currentWpn","_isWeapon","_backpackWpnTypes","_backpackWpnQtys","_countr","_class","_position","_dir","_currentAnim","_tagSetting","_playerUID","_countMags","_magazines","_primweapon","_secweapon","_newBackpackType","_muzzles","_oldUnit","_group","_newUnit","_playerObjName","_wpnType","_ismelee"];

if (gear_done) then { disableUserInput true; };

_class             = _this select 0;

if(count _this > 1) then {
    _charID            = _this select 1;
    _charidchanged     = true;
} else {
    _charidchanged     = false;
};

_position         = getPosATL player;
_dir             = getDir player;
_currentAnim     = animationState player;
_tagSetting     = player getVariable["DZE_display_name",false];
_playerUID         = getPlayerUID player;
_weapons         = weapons player;
_countMags         = call player_countMagazines;
_magazines         = _countMags select 0;
_backpackMag    = [];

diag_log _countMags;

if ((_playerUID == dayz_playerUID) && (count _magazines == 0) && (count (magazines player) > 0 )) exitWith {cutText [(localize "str_epoch_player_17"), "PLAIN DOWN"]};

_primweapon    = primaryWeapon player;
_secweapon    = secondaryWeapon player;

if(!(_primweapon in _weapons) && _primweapon != "") then {
    _weapons set [(count _weapons), _primweapon];
};

if(!(_secweapon in _weapons) && _secweapon != "") then {
    _weapons set [(count _weapons), _secweapon];
};

//BackUp Backpack
dayz_myBackpack = unitBackpack player;
_newBackpackType = (typeOf dayz_myBackpack);
if(_newBackpackType != "") then {
    _backpackWpn = getWeaponCargo unitBackpack player;
    _backpackMag = _countMags select 1;
};

//Get Muzzle
_currentWpn = currentWeapon player;
_muzzles = getArray(configFile >> "cfgWeapons" >> _currentWpn >> "muzzles");
if (count _muzzles > 1) then {
    _currentWpn = currentMuzzle player;
};

//Secure Player for Transformation
player setPosATL dayz_spawnPos;

//BackUp Player Object
_oldUnit = player;

/**********************************/
//DONT USE player AFTER THIS POINT//
/**********************************/

//Create New Character
_group         = createGroup WEST;
_newUnit     = _group createUnit [_class,dayz_spawnPos,[],0,"NONE"];

_newUnit     setPosATL _position;
_newUnit     setDir _dir;

//Clear New Character
{_newUnit removeMagazine _x;} count  magazines _newUnit;
removeAllWeapons _newUnit;    

//Equip New Charactar
{
    if (typeName _x == "ARRAY") then {if ((count _x) > 0) then {_newUnit addMagazine [(_x select 0), (_x select 1)]; }; } else { _newUnit addMagazine _x; };
} count _magazines;

{
    _newUnit addWeapon _x;
} count _weapons;

//Check && Compare it
if(str(_weapons) != str(weapons _newUnit)) then {
    //Get Differecnce
    {
        _weapons = _weapons - [_x];
    } count (weapons _newUnit);
    
    //Add the Missing
    {
        _newUnit addWeapon _x;
    } count _weapons;
};

if(_primweapon !=  (primaryWeapon _newUnit)) then {
    _newUnit addWeapon _primweapon;        
};
if (_primweapon == "MeleeCrowbar") then {
    _newUnit addMagazine 'crowbar_swing';
};
if (_primweapon == "MeleeSledge") then {
    _newUnit addMagazine 'sledge_swing';
};
if (_primweapon == "MeleeHatchet_DZE") then {
    _newUnit addMagazine 'Hatchet_Swing';
};
if (_primweapon == "MeleeMachete") then {
    _newUnit addMagazine 'Machete_swing';
};
if (_primweapon == "MeleeFishingPole") then {
    _newUnit addMagazine 'Fishing_Swing';
};

if(_secweapon != (secondaryWeapon _newUnit) && _secweapon != "") then {
    _newUnit addWeapon _secweapon;        
};

_switchUnit = {

    private["_charidchanged","_charID"];

    _charID            = _this select 0;
    _charidchanged    = _this select 1;

    addSwitchableUnit        _newUnit;
    setPlayable             _newUnit;
    selectPlayer             _newUnit;
    
    if(_charidchanged) then {
        player setVariable["CharacterID",_charID,true];
        player setVariable["inTransit",true,true];
    };
    
    removeAllWeapons         _oldUnit;
    {
        _oldUnit removeMagazine _x;
    } count magazines         _oldUnit;

    deleteVehicle             _oldUnit;
    removeSwitchableUnit     _oldUnit;

    if(_currentWpn != "") then {
        _newUnit selectWeapon _currentWpn;
    };
};

//Add && Fill BackPack
if (_newBackpackType != "") then {

    _newUnit         addBackpack _newBackpackType;

    //Weapons
    _backpackWpnTypes     = [];
    _backpackWpnQtys     = [];

    if (count _backpackWpn > 0) then {
        _backpackWpnTypes = _backpackWpn select 0;
        _backpackWpnQtys = _backpackWpn select 1;
    };

    diag_log format["DSM: Initialising switchover | charID: %1 | changeID: %2",_charID,_charidchanged];

    [_charID,_charidchanged] call _switchUnit;

    diag_log "DSM: Switchunit succes";

    if (gear_done) then {sleep 0.001;};
    ["1"] call gearDialog_create;
    if (gear_done) then {sleep 0.001;};
    
    diag_log "DSM: Geardialog succes";

    //magazines
    _countr = 0;
    {
        if ((typeName _x) != "STRING") then {
            _isWeapon = (isClass(configFile >> "CfgWeapons" >> (_x select 0)));
        } else {
            _isWeapon = (isClass(configFile >> "CfgWeapons" >> _x));
        };
        
        if (!_isWeapon) then {
            _countr = _countr + 1;
            if ((typeName _x) != "STRING") then {
                (unitBackpack player) addMagazineCargoGlobal [(_x select 0), 1];
                _idc = 4999 + _countr;
                _idc setIDCAmmoCount (_x select 1);
            } else {
                (unitBackpack player) addMagazineCargoGlobal [_x, 1];
            };
        };
    } foreach _backpackMag;
    
    diag_log "DSM: Backpackmag succes";
    
    (findDisplay 106) closeDisplay 0;
    
    if (gear_done) then {
        sleep 0.001;
        disableUserInput false;
    };
    
    _countr = 0;
    {
        (unitBackpack player) addWeaponCargoGlobal [_x,(_backpackWpnQtys select _countr)];
        _countr = _countr + 1;
    } foreach _backpackWpnTypes;

   diag_log "DSM: Backpackwpn succes";
    
} else {
    [_charID,_charidchanged] call _switchUnit;
};

[objNull, player, rSwitchMove,_currentAnim] call RE;

player disableConversation true;

if (_tagSetting) then {
    DZE_ForceNameTags = true;
};

_wpnType = primaryWeapon player;
_ismelee = (gettext (configFile >> "CfgWeapons" >> _wpnType >> "melee"));

if (_ismelee == "true") then {
    call dayz_meleeMagazineCheck;
};

{
    player reveal _x
} count (nearestObjects [getPosATL player, dayz_reveal, 50]);

 

9.) Open your /dayz_server/compile/server_playerSync.sqf

Replace with

 

private ["_inTransit","_empty","_name","_playerwasNearby","_character","_magazines","_force","_characterID","_charPos","_isInVehicle","_timeSince","_humanity","_debug","_distance","_isNewMed","_isNewPos","_isNewGear","_playerPos","_playerGear","_playerBackp","_medical","_distanceFoot","_lastPos","_backpack","_kills","_killsB","_killsH","_headShots","_lastTime","_timeGross","_timeLeft","_currentWpn","_currentAnim","_config","_onLadder","_isTerminal","_currentModel","_modelChk","_muzzles","_temp","_currentState","_array","_key","_pos","_forceGear","_friendlies"];

_character             = _this select 0;
_magazines             = _this select 1;
_force                 = _this select 2;
_forceGear             = _this select 3;
_playerwasNearby     = false;

if ((count _this) > 4) then {
    _playerwasNearby =    _this select 4;
};

if (isNull _character) exitWith {
    diag_log ("Player is Null FAILED: Exiting, player sync: " + str(_character));
};

_characterID         = _character getVariable ["CharacterID","0"];
_charPos            = getPosATL _character;
_isInVehicle         = vehicle _character != _character;
_timeSince             = 0;
_humanity             = 0;
_inTransit             = _character getVariable ["inTransit", false];

_name = if (alive _character) then { name _character; } else { "Dead Player"; };

if (_character isKindOf "Animal") exitWith {
    diag_log ("ERROR: Cannot Sync Character " + (_name) + " is an Animal class");
};

if (isnil "_characterID") exitWith {
    diag_log ("ERROR: Cannot Sync Character " + (_name) + " has nil characterID");    
};

if (_characterID == "0") exitWith {
    diag_log ("ERROR: Cannot Sync Character " + (_name) + " as no characterID");
};

if (_inTransit) exitWith {
    diag_log ("NOTICE: Cannot update " + (_name) + ", player is in transit");
};

_debug = getMarkerpos "respawn_west";
_distance = _debug distance _charPos;

if (_distance < 2000) exitWith {
    diag_log format["ERROR: server_playerSync: Cannot Sync Player %1 [%2]. Position in debug! %3",_name,_characterID,_charPos];
};

//Check for server initiated updates
_isNewMed =        _character getVariable["medForceUpdate",false];        //Med Update is forced when a player receives some kind of med incident
_isNewPos =        _character getVariable["posForceUpdate",false];        //Med Update is forced when a player receives some kind of med incident
_isNewGear =    ((count _magazines) > 0);

//Check for player initiated updates
if (_characterID != "0") then {
    _playerPos =    [];
    _playerGear =    [];
    _playerBackp =    [];
    _medical =        [];
    _distanceFoot =    0;
        
    //Check if update is requested
    if (_isNewPos || _force) then {
        if (((_charPos select 0) == 0) && ((_charPos select 1) == 0)) then {
            //Zero Position
        } else {
            //diag_log ("getting position..."); sleep 0.05;
            _playerPos = [round(direction _character),_charPos];
            _lastPos = _character getVariable["lastPos",_charPos];
            if (count _lastPos > 2 && count _charPos > 2) then {
                if (!_isInVehicle) then {
                    _distanceFoot = round(_charPos distance _lastPos);
                };
                _character setVariable["lastPos",_charPos];
            };
            if (count _charPos < 3) then {
                _playerPos =    [];
            };
            //diag_log ("position = " + str(_playerPos)); sleep 0.05;
        };
        _character setVariable ["posForceUpdate",false,true];
    };
    if (_isNewGear || _forceGear) then {
        _playerGear = [weapons _character,_magazines];
        _backpack = unitBackpack _character;
        if(_playerwasNearby) then {
            _empty = [[],[]];
            _playerBackp = [typeOf _backpack,_empty,_empty];
        } else {
            _playerBackp = [typeOf _backpack,getWeaponCargo _backpack,getMagazineCargo _backpack];
        };
    };
    if (_isNewMed || _force) then {
        if (!(_character getVariable["USEC_isDead",false])) then {
            _medical = _character call player_sumMedical;
        };
        _character setVariable ["medForceUpdate",false,true];
    };
    
    //Process update
    if (_characterID != "0") then {
        //Record stats while we're here        
        /*
            Check previous stats against what client had when they logged in
            this helps prevent JIP issues, where a new player wouldn't have received
            the old players updates. Only valid for stats where clients could have
            be recording  results from their local objects (such as agent zombies)
        */
        _kills =         ["zombieKills",_character] call server_getDiff;
        _killsB =         ["banditKills",_character] call server_getDiff;
        _killsH =         ["humanKills",_character] call server_getDiff;
        _headShots =     ["headShots",_character] call server_getDiff;
        _humanity =     ["humanity",_character] call server_getDiff2;
        //_humanity =     _character getVariable ["humanity",0];
        _character addScore _kills;        
        /*
            Assess how much time has passed, for recording total time on server
        */
        _lastTime =     _character getVariable["lastTime",time];
        if (isNil "_lastTime") then {_lastTime = time;};
        _timeGross =     (time - _lastTime);
        _timeSince =     floor(_timeGross / 60);
        _timeLeft =        (_timeGross - (_timeSince * 60));
        /*
            Get character state details
        */
        _currentWpn =     currentMuzzle _character;
        _currentAnim =    animationState _character;
        _config =         configFile >> "CfgMovesMaleSdr" >> "States" >> _currentAnim;
        _onLadder =        (getNumber (_config >> "onLadder")) == 1;
        _isTerminal =     (getNumber (_config >> "terminal")) == 1;
        //_wpnDisabled =    (getNumber (_config >> "disableWeapons")) == 1;
        _currentModel = typeOf _character;
        _modelChk =     _character getVariable ["model_CHK",""];
        if (isNil "_modelChk") then {_modelChk = "";};
        if (_currentModel == _modelChk) then {
            _currentModel = "";
        } else {
            _currentModel = _currentModel;
            _character setVariable ["model_CHK",typeOf _character];
        };
        
        if (_onLadder || _isInVehicle || _isTerminal) then {
            _currentAnim = "";
            //If position to be updated, make sure it is at ground level!
            if ((count _playerPos > 0) && !_isTerminal) then {
                _charPos set [2,0];
                _playerPos set[1,_charPos];                    
            };
        };
        if (_isInVehicle) then {
            _currentWpn = "";
        } else {
            if ( typeName(_currentWpn) == "STRING" ) then {
                _muzzles = getArray(configFile >> "cfgWeapons" >> _currentWpn >> "muzzles");
                if (count _muzzles > 1) then {
                    _currentWpn = currentMuzzle _character;
                };    
            } else {
                //diag_log ("DW_DEBUG: _currentWpn: " + str(_currentWpn));
                _currentWpn = "";
            };
        };
        _temp = round(_character getVariable ["temperature",100]);
        if (isNil "_temp") then {_temp = 100;};
        _currentState = [_currentWpn,_currentAnim,_temp];
        if(DZE_FriendlySaving) then {
            // save only last/most recent 5 entries as we only have 200 chars in db field && weapon + animation names are sometimes really long 60-70 chars.
            _arrayToSave = (_character getVariable ["friendlies",[]]);
            if (isNil "_arrayToSave") then {_arrayToSave = [];};
            _friendlies = [_arrayToSave,5] call array_reduceSizeReverse;
            _currentState set [(count _currentState),_friendlies];
        };
        /*
            Everything is ready, now publish to HIVE
        */
        if (count _playerPos > 0) then {
            _array = [];
            {
                if (_x > dayz_minpos && _x < dayz_maxpos) then {
                    _array set [count _array,_x];
                };
            } count (_playerPos select 1);
            _playerPos set [1,_array];
        };
        if (!isNull _character) then {
            if (alive _character) then {
                //Wait for HIVE to be free
                //Send request
                _key = format["CHILD:201:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:",_characterID,_playerPos,_playerGear,_playerBackp,_medical,false,false,_kills,_headShots,_distanceFoot,_timeSince,_currentState,_killsH,_killsB,_currentModel,_humanity];
                //diag_log ("HIVE: WRITE: "+ str(_key) + " / " + _characterID);
                _key call server_hiveWrite;
            };
        };

        // If player is in a vehicle, keep its position updated
        if (vehicle _character != _character) then {
            //[vehicle _character, "position"] call server_updateObject;
            if (!(vehicle _character in needUpdate_objects)) then {
                //diag_log format["DEBUG: Added to NeedUpdate=%1",vehicle _character];
                needUpdate_objects set [count needUpdate_objects, vehicle _character];
            };
        };
        
        // Force gear updates for nearby vehicles/tents
        {
            [_x, "gear"] call server_updateObject;
        } count (nearestObjects [_charPos, dayz_updateObjects, 10]);
        //[_charPos] call server_updateNearbyObjects;

        //Reset timer
        if (_timeSince > 0) then {
            _character setVariable ["lastTime",(time - _timeLeft)];
        };
        
    };
    
};

 

 

 

10.) Repack your mission and dayz_server pbo

 

 

 

I followed this and tested with a few characters on my test server and NO lose of location or lose of gear or roll back. Tested with one of my regular players also. Tested ai skins from the take cloths script.

 

I did receive a few of these:

 

17:52:17 "Player is Null FAILED: Exiting, player sync: <NULL-object>"
17:52:18 "NOTICE: Cannot update Detour, player is in transit"

 

Seems to have worked, at least in a test environment. Will put on my live later. 

 

Thanks for this. Has plagued my players for awhile!! 

Link to comment
Share on other sites

  • 0

You will need to modify scripts.txt if you have this filter: 5 "call player_humanityMorph"

I haven't done so yet but just noticed while testing.

Also getting errors following your instructions.

11:27:27 Error in expression <_name) + " as no characterID");

};

if (_inTransit) exitWith {

diag_log ("NOTICE>

11:27:27 Error position: <_inTransit) exitWith {

diag_log ("NOTICE>

11:27:27 Error Undefined variable in expression: _intransit

11:27:27 File z\addons\dayz_server\compile\server_playerSync.sqf, line 39

11:27:29 Error in expression <_name) + " as no characterID");

};

 

Yeah I'm getting massive rpt spam with that too.

 

Ugh, sorry guys! Missed a step :(

 

In server_playerSync.sqf

Find

_humanity             = 0;

Add below

_inTransit             = _character getVariable ["inTransit",false];
Link to comment
Share on other sites

  • 0

Hey guys, if any of you could confirm this as a working fix I'll update the OP and title.

 

 

Worked for me for a day or two until I changed the clothing thing completely so the inTransit wasn't needed anymore.

(Had some duping issues, simply forced players to re-log when changing clothes, temporary solution until I find a better one :/ )

Link to comment
Share on other sites

  • 0

It fixed the character not updating bug, but now getting lots of complaints of people just randomly losing their backpacks.

 

We are using Zupa's clothing script but I'm not sure if that conflicts with this fix. Either way there were no backpack issues before I added in

_inTransit             = _character getVariable ["inTransit",false];
Link to comment
Share on other sites

  • 0

A note:

 

in player sync you do

_inTransit             = _character getVariable ["inTransit",false];

now, as of experience i know IF this variable is not set, _InTransit is empy, and the default value FALSE is not passed in the variable.

 

I only see you setting this variable in humanitymorph. ( OR does this get called when you llogin, i dont know this by head ^^ ).

 

This will let the following if crashes your whole player_sync? ( i presume)

if (_inTransit) exitWith {
diag_log ("NOTICE: Cannot update " + (_name) + ", player is in transit");
};

i recommand the following

if ( !(isNil "_inTransit") && _inTransit) exitWith {
    diag_log ("NOTICE: Cannot update " + (_name) + ", player is in transit");
};
Link to comment
Share on other sites

  • 0

You sure about that Zupa? I've never seen it do anything else then set the variable to false. I think you might confuse it for "nil" which behaves in the way you explain?

--

@Anarior: Could you post the code of that script? It seems like something that might interfere.

Link to comment
Share on other sites

  • 0

You sure about that Zupa? I've never seen it do anything else then set the variable to false. I think you might confuse it for "nil" which behaves in the way you explain?

--

@Anarior: Could you post the code of that script? It seems like something that might interfere.

 

It's this one here: 

 

I haven't had any issues with it, all has been running fine but when I added the new line to playersync, things started getting weird with backpacks.

Link to comment
Share on other sites

  • 0
21:21:05   Error position: <private ["_inTransit","_empty","_name",">
21:21:05   Error Local variable in global space
21:21:05 File z\addons\dayz_server\compile\server_playerSync.sqf, line 1
21:21:05 Error in expression <z_server\compile\server_playerSync.sqf"
 
 
Getting this spammed alot.. Whats messed up?
Link to comment
Share on other sites

  • 0

 

21:21:05   Error position: <private ["_inTransit","_empty","_name",">
21:21:05   Error Local variable in global space
21:21:05 File z\addons\dayz_server\compile\server_playerSync.sqf, line 1
21:21:05 Error in expression <z_server\compile\server_playerSync.sqf"
 
 
Getting this spammed alot.. Whats messed up?

 

 

Remove the "_inTransit" from your private variable list?

So it's just like: private ["_empty","_name", etc...

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...