Fix wrong vehicle update if the player disconnects

This commit is contained in:
AirwavesMan
2020-11-15 15:43:02 +01:00
parent c78d6859b8
commit ae52a0e5e8

View File

@@ -18,12 +18,12 @@ _humanity = 0;
_name = if (alive _character) then {name _character} else {"Dead Player"};
_inDebug = (respawn_west_original distance _charPos) < 1500;
_exitReason = switch true do {
case (isNil "_characterID"): {("ERROR: Cannot Sync Character " + _name + " has nil characterID")}; //Unit is null
case (_inDebug): {format["INFO: Cannot Sync Character %1 near respawn_west %2. This is normal when relogging or changing clothes.",_name,_charPos]};
case (_characterID == "0"): {("ERROR: Cannot Sync Character " + _name + " has no characterID")};
case (_character isKindOf "Animal"): {("ERROR: Cannot Sync Character " + _name + " is an Animal class")};
default {"none"};
_exitReason = call {
if (isNil "_characterID") exitwith {("ERROR: Cannot Sync Character " + _name + " has nil characterID")}; //Unit is null
if (_inDebug) exitwith {format["INFO: Cannot Sync Character %1 near respawn_west %2. This is normal when relogging or changing clothes.",_name,_charPos]};
if (_characterID == "0") exitwith {("ERROR: Cannot Sync Character " + _name + " has no characterID")};
if (_character isKindOf "Animal") exitwith {("ERROR: Cannot Sync Character " + _name + " is an Animal class")};
"none";
};
if (_exitReason != "none") exitWith {
@@ -136,6 +136,12 @@ if (_currentModel == _modelChk) then {
_currentModel = str _currentModel;
_character setVariable ["model_CHK",typeOf _character];
};
// If player is in a vehicle, keep its position updated
if (vehicle _character != _character) then {
[vehicle _character, "position"] call server_updateObject;
};
if (count _this > 4) then { //calling from player_onDisconnect
if (_this select 4) then { //combat logged
_medical set [1, true]; //set unconcious to true
@@ -188,11 +194,6 @@ if (_isInVehicle) then {
};
_currentState = [[_currentWpn,_currentAnim,_temp],[]];
// If player is in a vehicle, keep its position updated
if (vehicle _character != _character) then {
[vehicle _character, "position"] call server_updateObject;
};
//Reset timer
if (_timeSince > 0) then {
_character setVariable ["lastTime",(diag_ticktime - _timeLeft)];