MGT

server_onPlayerDisconnect.sqf

MGT
Jul 22nd, 2014
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. private ["_invehicle","_isplayernearby","_playerObj","_myGroup","_id","_playerUID","_playerName","_characterID","_timeout","_message","_magazines","_playerPos"];
  2. _playerUID = _this select 0;
  3. _playerName = _this select 1;
  4. _playerObj = nil;
  5. _playerPos = [];
  6. {
  7. if ((getPlayerUID _x) == _playerUID) exitWith {_playerObj = _x;};
  8. } count playableUnits;
  9.  
  10. if (isNil "_playerObj") then {
  11. diag_log format["nil player object attempting PV, :%1", _this];
  12.  
  13. // fall back to using PV for now so we have a better chance at finding the player
  14. _playerObj = call compile format["PVDZE_player%1",_playerUID];
  15. };
  16.  
  17. if (isNil "_playerObj") exitWith {
  18. diag_log format["%1: nil player object, _this:%2", __FILE__, _this];
  19. };
  20.  
  21. diag_log format["get: %1 (%2), sent: %3 (%4)",typeName (getPlayerUID _playerObj), getPlayerUID _playerObj, typeName _playerUID, _playerUID];
  22.  
  23. if (!isNull _playerObj) then {
  24.  
  25. _playerPos = getPosATL _playerObj;
  26. _characterID = _playerObj getVariable ["CharacterID","0"];
  27. _timeout = _playerObj getVariable["combattimeout",0];
  28.  
  29. _invehicle = false;
  30.  
  31. if (vehicle _playerObj != _playerObj) then {
  32. _playerObj action ["eject", vehicle _playerObj];
  33. _invehicle = true;
  34. _playerObj setVariable["NORRN_unconscious",true, true];
  35. _playerObj setVariable["unconsciousTime",300,true];
  36. diag_log format["LOGOUT IN VEHICLE - GLITCHING?: %1 at location %2", _playerName,(getPosATL _playerObj)];
  37. _hint = parseText format["<t align='center' color='#FF0033' shadow='2' size='1.75'>Vehicle Logger</t><br/><t align='center' color='#ffffff'>%1 Disconnected in a vehicle, may be base glitching</t>",_playerName];
  38. customRemoteMessage = ['hint', _hint];
  39. publicVariable "customRemoteMessage";
  40. };
  41.  
  42. if ((_timeout - time) > 0) then {
  43.  
  44. _playerObj setVariable["NORRN_unconscious",true, true];
  45. _playerObj setVariable["unconsciousTime",300,true];
  46. _playerObj setVariable["USEC_BloodQty",1000];
  47. _playerObj setVariable["USEC_injured",true];
  48.  
  49. diag_log format["COMBAT LOGGED: %1 (%2) at location %3", _playerName,_timeout,(getPosATL _playerObj)];
  50. //diag_log format["SET UNCONCIOUSNESS: %1", _playerName];
  51.  
  52. // Message whole server when player combat logs
  53. _hint = parseText format["<t align='center' color='#FF0033' shadow='2' size='1.75'>Combat Logger</t><br/><t align='center' color='#ffffff'>%1 combat logged, they're on low blood, bleeding and unconscious when they reconnect</t>",_playerName];
  54. customRemoteMessage = ['hint', _hint];
  55. publicVariable "customRemoteMessage";
  56. };
  57.  
  58. diag_log format["DISCONNECT: %1 (%2) Object: %3, _characterID: %4 at loc %5", _playerName,_playerUID,_playerObj,_characterID, (getPosATL _playerObj)];
  59.  
  60. _id = [_playerUID,_characterID,2] spawn dayz_recordLogin;
  61.  
  62. if (alive _playerObj) then {
  63.  
  64. _isplayernearby = (DZE_BackpackGuard && !_invehicle && ({(isPlayer _x) && (alive _x)} count (_playerPos nearEntities ["AllVehicles", 5]) > 1));
  65.  
  66. // prevent saving more than 20 magazine items
  67. _magazines = [(magazines _playerObj),20] call array_reduceSize;
  68.  
  69. [_playerObj,_magazines,true,true,_isplayernearby] call server_playerSync;
  70.  
  71. // remove player
  72. _playerObj call dayz_removePlayerOnDisconnect;
  73. } else {
  74. //Update Vehicle
  75. {
  76. [_x,"gear"] call server_updateObject;
  77. } count (nearestObjects [_playerPos, dayz_updateObjects, 10]);
  78. };
  79. };
Advertisement
Add Comment
Please, Sign In to add comment