//---------------------------------------- DEATH MESSAGES --------------------------------------------
_victim removeAllEventHandlers "MPHit";
_victim = _this select 2;
_victimName = _playerName;
_killer = _victim getVariable["AttackedBy", "nil"];
_killerName = _victim getVariable["AttackedByName", "nil"];
// when a zombie kills a player _killer, _killerName and _weapon will be "nil"
// we can use this to determine a zombie kill and send a customized message for that. right now no killmsg means it was a zombie.
if (_killerName != "nil") then
{
_weapon = _victim getVariable["AttackedByWeapon", "nil"];
_distance = _victim getVariable["AttackedFromDistance", "nil"];
_closestTown = (nearestLocations [getpos player,["NameCity","NameVillage"],5000]) select 0;
_town_name = text _closestTown;
_loc_message = format["PKILL: %1 (%5) was killed by %2 (%6) with weapon %3 from %4m", _victimName, _killerName, _weapon, _distance, _playerID, _killerPlayerID];
diag_log _loc_message;
death_message = format["%1 killed %2\nWeapon: %3\nDistance: %4\nNear: %5",_killername,_victim,_weapon,_distance,_closesttown];
// show death_message locally
5 cutRsc ["dm_disp","PLAIN"];
((uiNamespace getVariable "dm_control") displayCtrl 1) ctrlSetText death_message;
//show deathmessage globally
publicVariable "death_message";
_victim setVariable["Killedby", _killername, true];
_victim setVariable["Killedwith", _weapon, true];
_victim setVariable["KilledDistance", _distance, true];
// Cleanup
_victim setVariable["AttackedBy", "nil", true];
_victim setVariable["AttackedByName", "nil", true];
_victim setVariable["AttackedByWeapon", "nil", true];
_victim setVariable["AttackedFromDistance", "nil", true];
};
// -----------------------------------------------------------------------------------------------------------