Advertisement
Brord

server_playerDied.sqf

Feb 19th, 2015
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.22 KB | None | 0 0
  1. private ["_characterID","_minutes","_newObject","_playerID","_infected","_victim","_victimName","_killer","_killerName","_weapon","_distance","_message","_loc_message","_key","_death_record"];
  2. //[unit, weapon, muzzle, mode, ammo, magazine, projectile]
  3. _characterID =  _this select 0;
  4. _minutes =      _this select 1;
  5. _newObject =    _this select 2;
  6. _playerID =     _this select 3;
  7. _infected =     _this select 4;
  8.  
  9. if (((count _this) >= 6) && {(typeName (_this select 5)) == "STRING"} && {(_this select 5) != ""}) then {
  10.     _victimName =   _this select 5;
  11. } else {
  12.     _victimName =  if (alive _newObject) then {name _newObject;} else {"";};
  13. };
  14. _victim = _newObject;
  15. _newObject setVariable ["bodyName", _victimName, true];
  16.  
  17. _killer = _victim getVariable["AttackedBy", "nil"];
  18. _killerName = _victim getVariable["AttackedByName", "nil"];
  19.  
  20. // when a zombie kills a player _killer, _killerName && _weapon will be "nil"
  21. // we can use this to determine a zombie kill && send a customized message for that. right now no killmsg means it was a zombie.
  22. if ((typeName _killer) != "STRING") then
  23. {
  24.     _weapon = _victim getVariable["AttackedByWeapon", "nil"];
  25.     _distance = _victim getVariable["AttackedFromDistance", "nil"];
  26.  
  27.     if ((owner _victim) == (owner _killer)) then
  28.     {
  29.         _message = format["%1 killed himself",_victimName];
  30.         _loc_message = format["PKILL: %1 killed himself", _victimName];
  31.     }
  32.     else
  33.     {
  34.         _message = format["%1 was killed by %2 with weapon %3 from %4m",_victimName, _killerName, _weapon, _distance];
  35.         _loc_message = format["PKILL: %1 was killed by %2 with weapon %3 from %4m", _victimName, _killerName, _weapon, _distance];
  36.     };
  37.  
  38.     diag_log _loc_message;
  39.  
  40.     if(DZE_DeathMsgGlobal) then {
  41.         [nil, nil, rspawn, [_killer, _message], { (_this select 0) globalChat (_this select 1) }] call RE;
  42.     };
  43.     /* needs customRemoteMessage
  44.     if(DZE_DeathMsgGlobal) then {
  45.         customRemoteMessage = ['globalChat', _message, _killer];
  46.         publicVariable "customRemoteMessage";
  47.     };
  48.     */
  49.     if(DZE_DeathMsgSide) then {
  50.         [nil, nil, rspawn, [_killer, _message], { (_this select 0) sideChat (_this select 1) }] call RE;
  51.     };
  52.     if(DZE_DeathMsgTitleText) then {
  53.         [nil,nil,"per",rTITLETEXT,_message,"PLAIN DOWN"] call RE;
  54.     };
  55.  
  56.     // build array to store death messages to allow viewing at message board in trader citys.
  57.     _death_record = [
  58.         _victimName,
  59.         _killerName,
  60.         _weapon,
  61.         _distance,
  62.         ServerCurrentTime
  63.     ];
  64.     PlayerDeaths set [count PlayerDeaths,_death_record];
  65.  
  66.     // Cleanup
  67.     _victim setVariable["AttackedBy", "nil", true];
  68.     _victim setVariable["AttackedByName", "nil", true];
  69.     _victim setVariable["AttackedByWeapon", "nil", true];
  70.     _victim setVariable["AttackedFromDistance", "nil", true];
  71. };
  72.  
  73. // Might not be the best way...
  74. /*
  75. if (isnil "dayz_disco") then {
  76.     dayz_disco = [];
  77. };
  78. */
  79.  
  80. // dayz_disco = dayz_disco - [_playerID];
  81. _newObject setVariable["processedDeath",diag_tickTime];
  82.  
  83. if (typeName _minutes == "STRING") then
  84. {
  85.     _minutes = parseNumber _minutes;
  86. };
  87.  
  88. diag_log ("PDEATH: Player Died " + _playerID);
  89. diag_log format["_characterID: %1, _playerID: %2", _characterID, _playerID];
  90.  
  91.  
  92. if (_characterID != "0") then
  93. {
  94.     diag_log format["CHILD:202:%1:%2:%3:%4:",_characterID,_minutes,_playerID,_infected];
  95. }
  96. else
  97. {
  98.     deleteVehicle _newObject;
  99. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement