Jump to content

[Release] Custom Kill Messages


0verHeaT

Recommended Posts

If anyone wants a system chat message to pop up in addition to the kill feed with pictures, use these 2 files.

server_playerDied.sqf

private ["_characterID","_minutes","_newObject","_playerID","_infected","_victim","_victimName","_killer","_killerName","_weapon","_distance","_message","_loc_message","_key","_death_record"];
//[unit, weapon, muzzle, mode, ammo, magazine, projectile]
_characterID = 	_this select 0;
_minutes =		_this select 1;
_newObject = 	_this select 2;
_playerID = 	_this select 3;
_infected =		_this select 4;
if (((count _this) >= 6) && {(typeName (_this select 5)) == "STRING"} && {(_this select 5) != ""}) then {
	_victimName =	_this select 5;
} else {
	_victimName =  if (alive _newObject) then {name _newObject;} else {"";};
};
_victim = _newObject;
_newObject setVariable ["bodyName", _victimName, true];

sleep 3;

_killer = _victim getVariable["AttackedBy", "nil"];
_killerName = _victim getVariable["AttackedByName", "nil"];

// when a zombie kills a player _killer, _killerName && _weapon will be "nil"
// we can use this to determine a zombie kill && send a customized message for that. right now no killmsg means it was a zombie.
if ((typeName _killer) != "STRING") then
{
	_weapon = _victim getVariable["AttackedByWeapon", "nil"];
	_distance = _victim getVariable["AttackedFromDistance", "nil"];

	if ((owner _victim) == (owner _killer)) then 
	{
		_message = format["%1 killed himself",_victimName];
		_loc_message = format["PKILL: %1 killed himself", _victimName];
	}
	else
	{
		_message = format["%1 was killed by %2 with weapon %3 from %4m",_victimName, _killerName, _weapon, _distance];
		_loc_message = format["PKILL: %1 was killed by %2 with weapon %3 from %4m", _victimName, _killerName, _weapon, _distance];
	
	
		_pic = _victim getVariable["AttackedByWeaponImg", "nil"];
		
                if ((gettext (configFile >> 'cfgWeapons' >> (currentWeapon _killer) >> 'displayName')) != "Throw") then {
			if (!isNil "_pic") then {
				_kill_txt = format ["<t align='left' size='0.7'>%1 </t>",_killerName,_pic,_victimName,(ceil _distance)];
				_kill_txt = _kill_txt + format ["<img size='0.9' align='left' image='%2'/>",_killerName,_pic,_victimName,(ceil _distance)];
				_kill_txt = _kill_txt + format ["<t align='left' size='0.7'> %3 </t>",_killerName,_pic,_victimName,(ceil _distance)];
				_kill_txt = _kill_txt + format ["<t align='left' size='0.7'>[%4m]</t>",_killerName,_pic,_victimName,(ceil _distance)];

				_msg = format ["<Playerkill>: %1 was killed by %2 with a %3 from %4 meters",_victimName,_killerName,_weapon,(ceil _distance)]; // <--- Edit HERE Your MSG
				customkillMessage = [_kill_txt,_msg];
				publicVariable "customkillMessage";
			};
		}; 
	
	
	};

	diag_log _loc_message;

	if(DZE_DeathMsgGlobal) then {
		[nil, nil, rspawn, [_killer, _message], { (_this select 0) globalChat (_this select 1) }] call RE;
	};
	/* needs customRemoteMessage
	if(DZE_DeathMsgGlobal) then {
		customRemoteMessage = ['globalChat', _message, _killer];
		publicVariable "customRemoteMessage";
	};
	*/
	if(DZE_DeathMsgSide) then {
		[nil, nil, rspawn, [_killer, _message], { (_this select 0) sideChat (_this select 1) }] call RE;
	};
	if(DZE_DeathMsgTitleText) then {
		[nil,nil,"per",rTITLETEXT,_message,"PLAIN DOWN"] call RE;
	};

	// build array to store death messages to allow viewing at message board in trader citys.
	_death_record = [
	_victimName,
	_killerName,
	_weapon,
	_pic,
	_distance,
	ServerCurrentTime
];
PlayerDeaths set [count PlayerDeaths,_death_record];
PV_DeathBoard = PlayerDeaths;
publicVariable "PV_DeathBoard"; 

	// Cleanup
	_victim setVariable["AttackedBy", "nil", true];
	_victim setVariable["AttackedByName", "nil", true];
	_victim setVariable["AttackedByWeapon", "nil", true];
	_victim setVariable["AttackedFromDistance", "nil", true];
};

// Might not be the best way...
/*
if (isnil "dayz_disco") then {
	dayz_disco = [];
};
*/

// dayz_disco = dayz_disco - [_playerID];
_newObject setVariable["processedDeath",diag_tickTime];

if (typeName _minutes == "STRING") then
{
	_minutes = parseNumber _minutes;
};

diag_log ("PDEATH: Player Died " + _playerID);

if (_characterID != "0") then
{
	_key = format["CHILD:202:%1:%2:%3:",_characterID,_minutes,_infected];
	#ifdef DZE_SERVER_DEBUG_HIVE
	diag_log ("HIVE: WRITE: "+ str(_key));
	#endif
	_key call server_hiveWrite;
}
else
{
	deleteVehicle _newObject;
};

 

kill_msg.sqf

/*** Written by 0verHeaT ***/
fnc_kill_message = {
	private ["_finaltxt","_systemmsg"];
	_finaltxt = _this select 0;
	_systemmsg = _this select 1;
	systemChat _systemmsg;
	[_finaltxt,[safezoneX + 0.01 * safezoneW,2.0],[safezoneY + 0.01 * safezoneH,0.3],30,0.5] spawn BIS_fnc_dynamicText;
};
"customkillMessage" addPublicVariableEventHandler {(_this select 1) call fnc_kill_message;}; 

 

It will look like this

NdywL8K.jpg

what about JUST this??? it looks like origins death messages.

 

i'm sorry overheat, i had to remove your script. it was conflicting with something and rolling players back to about an hours back in time lol. it was probably my mistake, i just didn't know how to fix it so i removed it.

Link to comment
Share on other sites

  • 2 months later...

adding a sleep, caused this not to work at all for me, remove the sleep, works perfect

you added the sleep incorrectly? if you copy/paste the files I posted here... it works perfectly. You definitely need a sleep otherwise this will not work 100% of the time on a busy server.

Link to comment
Share on other sites

  • 1 month later...

Working great so far but getting this RPT error when using DangerRuss server_playerDied.sqf:

 Error in expression < = [

_victimName,
_killerName,
_weapon,
_pic,
_distance,
ServerCurrentTime
];
Pl>
Error position: <_pic,
_distance,
ServerCurrentTime
];
Pl>
 Error Undefined variable in expression: _pic
File z\addons\dayz_server\compile\server_playerDied.sqf, line 80
 
Link to comment
Share on other sites

  • 8 months later...

This all seems to work except that it only works the first time and not again.

So if user A kills user B, I get the kill message and kill board in trader zone is updated.

User B logs back in again and is killed by user A again.  No kill message.  No update to kill boards.
User B logs back in again, killed by user A again, same.  No kill message, no update.

If user B kills user A kill message shows and kill board updates.  If user A logs in again  and is killed by user B, no message, no updates.

You get the picture... shrug.  Any suggestions?

Link to comment
Share on other sites

  • 4 months later...
On 03/04/2016 at 9:37 AM, ravenwolf said:

This all seems to work except that it only works the first time and not again.

So if user A kills user B, I get the kill message and kill board in trader zone is updated.

User B logs back in again and is killed by user A again.  No kill message.  No update to kill boards.
User B logs back in again, killed by user A again, same.  No kill message, no update.

If user B kills user A kill message shows and kill board updates.  If user A logs in again  and is killed by user B, no message, no updates.

You get the picture... shrug.  Any suggestions?

i got the same problem :( did u get it to work ?

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×
×
  • Create New...