mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
Speed up onPlayerDisconnect some more
Moved combat log setVariables to playerSync. Now the player object is no longer needed for any of the code at the bottom of playerSync or onPlayerDisconnected. Update objects is already performed at the bottom of playerSync. There is no reason to do it again in playerDisconnect since it calls playerSync.
This commit is contained in:
@@ -50,20 +50,21 @@ if (_characterID != "?") exitwith {
|
||||
//if player object is alive lets sync the player and remove the body and if ghosting is active add the player id to the array
|
||||
if (alive _playerObj) then {
|
||||
// High priority. Sync must finish fast before player object isNull
|
||||
[_playerObj,nil,true,true] call server_playerSync;
|
||||
[_playerObj,nil,true,_inCombat] call server_playerSync;
|
||||
|
||||
/*
|
||||
Low priority code below this point where
|
||||
_playerObj is no longer needed and may be Null.
|
||||
*/
|
||||
|
||||
//Punish combat log
|
||||
if (_inCombat > 0) then {
|
||||
_playerObj setVariable ["NORRN_unconscious",true,true]; // Set status to unconscious
|
||||
_playerObj setVariable ["unconsciousTime",150,true]; // Set knock out timer to 2 minutes 30 seconds
|
||||
//_playerObj setVariable ["USEC_injured",true]; // Set status to bleeding
|
||||
//_playerObj setVariable ["USEC_BloodQty",3000]; // Set blood to 3000
|
||||
|
||||
// Low priority. Player object not needed
|
||||
// Moved setVariables to server_playerSync since they are high priority
|
||||
// Messages are low priority. Player object not needed
|
||||
diag_log format["PLAYER COMBAT LOGGED: %1(%3) at location %2",_playerName,_playerPos,_playerUID];
|
||||
[nil, nil, rTitleText, format["PLAYER COMBAT LOGGED: %1",_playerName], "PLAIN"] call RE; // Message whole server
|
||||
};
|
||||
// Low priority. Player object not needed
|
||||
|
||||
if (dayz_enableGhosting) then {
|
||||
//diag_log format["GhostPlayers: %1, ActivePlayers: %2",dayz_ghostPlayers,dayz_activePlayers];
|
||||
if (!(_playerUID in dayz_ghostPlayers)) then {
|
||||
@@ -75,14 +76,7 @@ if (_characterID != "?") exitwith {
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
Low priority code below this point where
|
||||
_playerObj is no longer needed and may be Null.
|
||||
*/
|
||||
[_playerUID,_characterID,2,_playerName] call dayz_recordLogin;
|
||||
|
||||
//Lets scan the area near the player logout position and save all objects.
|
||||
{ [_x,"gear"] call server_updateObject } foreach (nearestObjects [_playerPos, DayZ_GearedObjects, 10]);
|
||||
};
|
||||
|
||||
if (isNull _playerObj) then { diag_log("Player Object does not esist"); };
|
||||
|
||||
@@ -148,24 +148,32 @@ if (_currentModel == _modelChk) then {
|
||||
_currentModel = str _currentModel;
|
||||
_character setVariable ["model_CHK",typeOf _character];
|
||||
};
|
||||
if ((count _this) > 3 && {_isInVehicle}) then { //calling from player_onDisconnect
|
||||
//if the player object is inside a vehicle lets eject the player
|
||||
_relocate = if (vehicle _character isKindOf "Air") then {true} else {false};
|
||||
_character action ["eject", vehicle _character];
|
||||
|
||||
// Prevent relog in parachute, heli or plane above base exploit to get inside
|
||||
if (_relocate) then {
|
||||
_count = 0;
|
||||
_maxDist = 800;
|
||||
_newPos = [_charPos, 80, _maxDist, 10, 1, 0, 0, [], [_charPos,_charPos]] call BIS_fnc_findSafePos;
|
||||
if (count _this > 3) then { //calling from player_onDisconnect
|
||||
if (_this select 3 > 0) then { //combat logged
|
||||
_character setVariable ["NORRN_unconscious",true,true]; // Set status to unconscious
|
||||
_character setVariable ["unconsciousTime",150,true]; // Set knock out timer to 2 minutes 30 seconds
|
||||
//_character setVariable ["USEC_injured",true]; // Set status to bleeding
|
||||
//_character setVariable ["USEC_BloodQty",3000]; // Set blood to 3000
|
||||
};
|
||||
if (_isInVehicle) then {
|
||||
//if the player object is inside a vehicle lets eject the player
|
||||
_relocate = if (vehicle _character isKindOf "Air") then {true} else {false};
|
||||
_character action ["eject", vehicle _character];
|
||||
|
||||
while {_newPos distance _charPos == 0} do {
|
||||
_count = _count + 1;
|
||||
if (_count > 4) exitWith {_newPos = _charPos;}; // Max 4km away fail safe (needs to finish fast so server_playerSync runs below)
|
||||
_newPos = [_charPos, 80, (_maxDist + 800), 10, 1, 0, 0, [], [_charPos,_charPos]] call BIS_fnc_findSafePos;
|
||||
// Prevent relog in parachute, heli or plane above base exploit to get inside
|
||||
if (_relocate) then {
|
||||
_count = 0;
|
||||
_maxDist = 800;
|
||||
_newPos = [_charPos, 80, _maxDist, 10, 1, 0, 0, [], [_charPos,_charPos]] call BIS_fnc_findSafePos;
|
||||
|
||||
while {_newPos distance _charPos == 0} do {
|
||||
_count = _count + 1;
|
||||
if (_count > 4) exitWith {_newPos = _charPos;}; // Max 4km away fail safe (needs to finish fast so server_playerSync runs below)
|
||||
_newPos = [_charPos, 80, (_maxDist + 800), 10, 1, 0, 0, [], [_charPos,_charPos]] call BIS_fnc_findSafePos;
|
||||
};
|
||||
_charPos = _newPos;
|
||||
diag_log format["%1(%2) logged out in air vehicle. Relocated to safePos %3m from logout position.",_name,_playerUID,_charPos distance _newPos];
|
||||
};
|
||||
_charPos = _newPos;
|
||||
diag_log format["%1(%2) logged out in air vehicle. Relocated to safePos %3m from logout position.",_name,_playerUID,_charPos distance _newPos];
|
||||
};
|
||||
};
|
||||
if (_onLadder or _isInVehicle or _isTerminal) then {
|
||||
@@ -189,8 +197,19 @@ 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)];
|
||||
};
|
||||
|
||||
/*
|
||||
Everything is ready, now publish to HIVE
|
||||
Low priority code below this point where _character object is no longer needed and may be Null.
|
||||
*/
|
||||
if (count _playerPos > 0) then {
|
||||
_array = [];
|
||||
@@ -220,15 +239,5 @@ if (DZE_groupManagement) then { //update player group
|
||||
_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;
|
||||
};
|
||||
|
||||
// Force gear updates for nearby vehicles/tents
|
||||
{[_x,"gear"] call server_updateObject;} count nearestObjects [_character,DayZ_GearedObjects,10];
|
||||
|
||||
//Reset timer
|
||||
if (_timeSince > 0) then {
|
||||
_character setVariable ["lastTime",(diag_ticktime - _timeLeft)];
|
||||
};
|
||||
{[_x,"gear"] call server_updateObject;} count nearestObjects [_charPos,DayZ_GearedObjects,10];
|
||||
Reference in New Issue
Block a user