Jump to content
Kerbo

Logging player death messages

Recommended Posts

I like seeing when and how players died in my server log so I modified (Unpack, edit, repack) @Hive\Addons\dayz_server\compile\server_playerDied.sqf file to do so. The diff and file below are from the DayZMod 1.8 release.

This modification will give you messages in your server RPT like:

Killed by zombie

PKILL: Player1 was killed near Komarovo

Killed by player

PKILL: Player1 (001) was killed near Balota by Player2 (002) with weapon MeleeHatchet from 2.345m

Killed themselves

PKILL: Player1 killed themselves near Kamenka

Diff

@@ -1,6 +1,6 @@ #include "\z\addons\dayz_server\compile\server_toggle_debug.hpp" -private ["_characterID","_minutes","_newObject","_playerID","_key"];+private ["_characterID","_minutes","_newObject","_playerID","_key", "_killer", "_weapon", "_distance","_loc_message","_killerName","_killerPlayerID"]; //[unit, weapon, muzzle, mode, ammo, magazine, projectile]  _characterID = 	_this select 0;@@ -9,16 +9,40 @@ _playerID = 	_this select 3; _playerName = 	name _newObject; -//dayz_disco = dayz_disco - [_playerID];-_newObject setVariable["processedDeath",time];+_newObject setVariable["processedDeath",diag_tickTime]; _newObject setVariable ["bodyName", _playerName, true]; -/*-diag_log ("DW_DEBUG: (isnil _characterID): " + str(isnil "_characterID"));-if (isnil "_characterID") then {-diag_log ("DW_DEBUG: _newObject: " + str(_newObject));	+_killer = _newObject getVariable["AttackedBy", "nil"];+_killerName = _newObject 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 = _newObject getVariable["AttackedByWeapon", "nil"];+	_distance = _newObject getVariable["AttackedFromDistance", "nil"];++	if (_playerName == _killerName) then +	{+		_loc_message = format["PKILL: %1 killed themselves near %2", _playerName, (getPosATL _newObject) call fa_coor2str];+	}+	else +	{+		_killerPlayerID = getPlayerUID _killer;+		_loc_message = format["PKILL: %1 (%5) was killed near %7 by %2 (%6) with weapon %3 from %4m", _playerName, _killerName, _weapon, _distance, _playerID, _killerPlayerID, (getPosATL _newObject) call fa_coor2str]; 	};-*/++	diag_log _loc_message;++	// Cleanup+	_newObject setVariable["AttackedBy", "nil", true];+	_newObject setVariable["AttackedByName", "nil", true];+	_newObject setVariable["AttackedByWeapon", "nil", true];+	_newObject setVariable["AttackedFromDistance", "nil", true];+} else {+	_loc_message = format["PKILL: %1 was killed near %2", _playerName, (getPosATL _newObject) call fa_coor2str];+	diag_log _loc_message;+};  if (typeName _minutes == "STRING") then  {@@ -44,15 +68,4 @@ ]; #endif -/*-_eh = [_newObject] spawn {-	_body = _this select 0;-	_method = _body getVariable["deathType","unknown"];-	_name = _body getVariable["bodyName","unknown"];-	waitUntil{!isPlayer _body;sleep 1};-	_body setVariable["deathType",_method,true];-	_body setVariable["bodyName",_name,true];-	diag_log ("PDEATH: Player Left Body " + _name);-};-*/ //dead_bodyCleanup set [count dead_bodyCleanup,_newObject];\ No newline at end of file

 

Full file

#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"private ["_characterID","_minutes","_newObject","_playerID","_key", "_killer", "_weapon", "_distance","_loc_message","_killerName","_killerPlayerID"];//[unit, weapon, muzzle, mode, ammo, magazine, projectile]_characterID = 	_this select 0;_minutes =	_this select 1;_newObject = 	_this select 2;_playerID = 	_this select 3;_playerName = 	name _newObject;_newObject setVariable["processedDeath",diag_tickTime];_newObject setVariable ["bodyName", _playerName, true];_killer = _newObject getVariable["AttackedBy", "nil"];_killerName = _newObject 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 = _newObject getVariable["AttackedByWeapon", "nil"];	_distance = _newObject getVariable["AttackedFromDistance", "nil"];	if (_playerName == _killerName) then 	{		_loc_message = format["PKILL: %1 killed themselves near %2", _playerName, (getPosATL _newObject) call fa_coor2str];	}	else 	{		_killerPlayerID = getPlayerUID _killer;		_loc_message = format["PKILL: %1 (%5) was killed near %7 by %2 (%6) with weapon %3 from %4m", _playerName, _killerName, _weapon, _distance, _playerID, _killerPlayerID, (getPosATL _newObject) call fa_coor2str];	};	diag_log _loc_message;	// Cleanup	_newObject setVariable["AttackedBy", "nil", true];	_newObject setVariable["AttackedByName", "nil", true];	_newObject setVariable["AttackedByWeapon", "nil", true];	_newObject setVariable["AttackedFromDistance", "nil", true];} else {	_loc_message = format["PKILL: %1 was killed near %2", _playerName, (getPosATL _newObject) call fa_coor2str];	diag_log _loc_message;};if (typeName _minutes == "STRING") then {	_minutes = parseNumber _minutes;};if (_characterID != "0") then {	_key = format["CHILD:202:%1:%2:",_characterID,_minutes];	//diag_log ("HIVE: WRITE: "+ str(_key));	_key call server_hiveWrite;} else {	deleteVehicle _newObject;};#ifdef PLAYER_DEBUGformat ["Player UID#%3 CID#%4 %1 as %5 died at %2", 	_newObject call fa_plr2str, (getPosATL _newObject) call fa_coor2str,	getPlayerUID _newObject,_characterID,	typeOf _newObject];#endif//dead_bodyCleanup set [count dead_bodyCleanup,_newObject];
Edited by Kerbo

Share this post


Link to post
Share on other sites

it's already included in 1.8.

If you are talking about this:

#ifdef PLAYER_DEBUGformat ["Player UID#%3 CID#%4 %1 as %5 died at %2", 	_newObject call fa_plr2str, (getPosATL _newObject) call fa_coor2str,	getPlayerUID _newObject,_characterID,	typeOf _newObject];#endif
I wanted more detail, which is what the patch above provides. My server is low pop and friendly so no one has killed anyone yet to provide an example of the more detailed kill message.

It would look something like this:

PKILL: Player1 (001) was killed near Balota by Player2 (002) with weapon MeleeHatchet from 2.345m

Or in the case of a suicide:

PKILL: Player1 killed themselves near Kamenka

I updated my original post to make it more clear what the patch is doing.

Edited by Kerbo

Share this post


Link to post
Share on other sites

I just tried to load your file up and got stuck on the "waiting for server to authenticate" after trying to connect.

 

Any suggestions?

Share this post


Link to post
Share on other sites

Ok, got it to work, but I'm noticing it usually doesn't who the killer. 

 

It must be hitting the nil criteria due to blood loss death or such.  

 

Any suggestions?

Share this post


Link to post
Share on other sites

Ok, got it to work, but I'm noticing it usually doesn't who the killer. 

 

It must be hitting the nil criteria due to blood loss death or such.  

 

Any suggestions?

 

If you are using 1.8.0.3 it already has some really nice hit messages in the logs by default, however to get killer I used an MPHit handler like this - http://dayz.st/w/Kill_Messages and logged the message to my server logs rather than showing in game. 

 

Hopefully the 1.8 logs can be modified a little in a future patches so kills are logged as well as hits. I find the mphit messages don't always credit the right killer if two people are firing on a person at once.  

 

I used a combination of database triggers for deaths/kills and parsing my rpt logs for PKILL and the default 1.8 PHIT messages to produce my kill logs which I use as admin and am making a public version of for my players

 

MismKQo.png

 

JGfxD4e.png

Edited by seaweed

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×