Created
May 24, 2016 01:35
-
-
Save iaretechnician/b5c369fcc572e418ac9a6a06c1e3610b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp" | |
private ["_playerObj","_myGroup","_playerUID","_playerPos","_playerName"]; | |
_playerUID = _this select 0; | |
_playerName = _this select 1; | |
_playerObj = nil; | |
_playerPos = []; | |
_removebackpack = false; | |
{ | |
if ((getPlayerUID _x) == _playerUID) exitWith { _playerObj = _x; _playerPos = getPosATL _playerObj;}; | |
} forEach playableUnits; | |
if (isNil "_playerObj") exitWith { | |
diag_log format["%1: nil player object, _this:%2", __FILE__, _this]; | |
}; | |
diag_log format["get: %1 (%2), sent: %3 (%4)",typeName (getPlayerUID _playerObj), getPlayerUID _playerObj, typeName _playerUID, _playerUID]; | |
if (!isNull _playerObj) then { | |
// log disconnect | |
#ifdef LOGIN_DEBUG | |
_characterID = _playerObj getVariable["characterID", "?"]; | |
_lastDamage = _playerObj getVariable["noatlf4",0]; | |
_Sepsis = _playerObj getVariable["USEC_Sepsis",false]; | |
// diag_log format ["%1 %2 %3", isNil "_timeout", typeName _timeout == 'SCALAR', _timeout]; | |
if (_Sepsis) then { | |
_playerObj setVariable["USEC_infected",true,true]; | |
}; | |
_lastDamage = round(diag_ticktime - _lastDamage); | |
diag_log format["Player UID#%1 CID#%2 %3 as %4, logged off at %5%6", | |
getPlayerUID _playerObj, _characterID, _playerObj call fa_plr2str, typeOf _playerObj, | |
(getPosATL _playerObj) call fa_coor2str, | |
if ((_lastDamage > 5 AND {(_lastDamage < 30)}) AND {((alive _playerObj) AND {(_playerObj distance (getMarkerpos "respawn_west") >= 2000)})}) then {" while in combat ("+str(_lastDamage)+" seconds left)"} else {""} | |
]; | |
#endif | |
//***********************************COMBAT LOGGING ********************************** | |
if ((_lastDamage > 5 AND {(_lastDamage < 30)}) AND {((alive _playerObj) AND {(_playerObj distance (getMarkerpos "respawn_west") >= 2000)})}) then { | |
diag_log "DEBUG IN COMBAT"; | |
_playerObj setVariable["NORRN_unconscious",true,true]; | |
_playerObj setVariable["unconsciousTime",120,true]; | |
_pos = getPosAtl _playerObj; | |
_backpack = unitBackpack _playerObj; | |
_weapons = weapons _playerObj; | |
_weapons_backpack = getWeaponCargo _backpack; | |
_magazines = magazines _playerObj; | |
_current_magazine = currentMagazine _playerObj; | |
_magazines_backpack = getMagazineCargo _backpack; | |
_loot_box = createVehicle ["USBasicAmmunitionBox",_pos,[],0,"CAN_COLLIDE"]; | |
clearMagazineCargoGlobal _loot_box; | |
clearWeaponCargoGlobal _loot_box; | |
{ | |
_loot_box addWeaponCargoGlobal [_x,1]; | |
} count (_weapons); | |
_magazines set [(count _magazines),_current_magazine]; | |
{ | |
_loot_box addMagazineCargoGlobal [_x,1]; | |
} count (_magazines); | |
if (typename _weapons_backpack == "ARRAY") then { | |
_i = 0; | |
{ | |
_loot_box addWeaponCargoGlobal [_x,((_weapons_backpack select 1) select _i)]; | |
_i = _i + 1; | |
} count (_weapons_backpack select 0); | |
}; | |
if (typename _magazines_backpack == "ARRAY") then { | |
_i = 0; | |
{ | |
_loot_box addMagazineCargoGlobal [_x,((_magazines_backpack select 1) select _i)]; | |
_i = _i + 1; | |
} count (_magazines_backpack select 0); | |
}; | |
if(typeOf _backpack != "") then { | |
_loot_box addBackpackCargoGlobal[(typeOf _backpack),1]; | |
}; | |
diag_log format["COMBAT LOGGED: %1 (%2) at location %3 - DEBUG: Weapons: (%4 - %5) / Magazines: (%6 - %7) / Backpack: (%8)",_playerName,_timeout,(getPosATL _playerObj),_weapons,_weapons_backpack,_magazines,_magazines_backpack,_backpack]; | |
_message = format["PLAYER COMBAT LOGGED: %1",_playerName]; | |
[nil, nil, rTitleText, _message, "PLAIN"] call RE; | |
_removebackpack = true; | |
{ | |
_playerObj removeMagazine _x; | |
} count magazines _playerObj; | |
{ | |
_playerObj removeWeapon _x; | |
} count _weapons; | |
}; | |
//************************************************************************************** | |
//Update Vehicle | |
if (vehicle _playerObj != _playerObj) then { | |
_playerObj action ["eject", vehicle _playerObj]; | |
}; | |
if (alive _playerObj) then { | |
//[_playerObj,(magazines _playerObj),true,(unitBackpack _playerObj)] call server_playerSync; | |
[_playerObj,nil,true,_removebackpack] call server_playerSync; | |
_myGroup = group _playerObj; | |
deleteVehicle _playerObj; | |
deleteGroup _myGroup; | |
}; | |
{ [_x,"gear"] call server_updateObject } foreach | |
(nearestObjects [_playerPos, ["Car", "Helicopter", "Motorcycle", "Ship", "TentStorage", "StashSmall", "StashMedium"], 10]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment