100% Kill & Death Messages 1.7.7.1

Okay before we get started, i want to thank the modding community and dayz.st, dayz.codeit and a few other people who posted the code here. I'm going to walk you through this one step at a time. This Tut is meant for those want to find out how to do this fast and effective.

Step 1.
Open your dayz_mission and edit your init.sqf file to the following
Find
Code:
enableRadio false;
change to
Code:
//enableRadio false;

Step 2.
Find this in your fn_selfActions
Code:
#include "\z\addons\dayz_code\system\REsec.sqf"
And // it out like so
Code:
//#include "\z\addons\dayz_code\system\REsec.sqf"

Now before we move on i want you to create a new fnc_plyrHit.sqf or replace the one you already have with this code
Code:
private ["_victim", "_attacker","_weapon","_distance","_victimPlayerID","_attakerPlayerID"];
_victim = _this select 0;
_attacker = _this select 1;
 
if (!isPlayer _victim || !isPlayer _attacker) exitWith {};
if ((name _victim) == (name _attacker)) exitWith {};
 
_weapon = weaponState _attacker;
if (_weapon select 0 == "Throw") then
{
    _weapon = _weapon select 3;
}
else
{
    _weapon = _weapon select 0;
};
 
_distance = _victim distance _attacker;
 
_victimPlayerID = getPlayerUID _victim;
_attakerPlayerID = getPlayerUID _attacker;
 
diag_log format["PHIT: %1 (%5) was hit by %2 (%6) with %3 from %4m", _victim, _attacker, _weapon, _distance, _victimPlayerID, _attakerPlayerID];
 
_victim setVariable["AttackedBy", _attacker, true];
_victim setVariable["AttackedByName", (name _attacker), true];
//_victim setVariable["AttackedByWeapon", (currentWeapon _attacker), true];
_victim setVariable["AttackedByWeapon", _weapon, true];
_victim setVariable["AttackedFromDistance", _distance, true];


Step 3.
Open your dayz_server.pbo and look in the init folder and edit the server_functions.sqf file and find
Code:
server_updateNearbyObjects =    compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateNearbyObjects.sqf";
Add this right below that
Code:
fnc_plyrHit  = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\fnc_plyrHit.sqf";

Step 4.
Open your dayz_server.pbo and go to your compiles folder and open the file server_playerDied.sqf and find
Code:
private ["_characterID","_minutes","_newObject","_playerID","_key"];
//[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;
 
//dayz_disco = dayz_disco - [_playerID];
Replace it with
Code:
private["_characterID","_minutes","_newObject","_playerID","_key","_playerName","_playerID","_myGroup","_group","_victim", "_killer", "_weapon", "_message", "_distance","_loc_message","_victimName","_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;
 
_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"];
 
    if (_victimName == _killerName) then
    {
        _message = format["%1 killed himself",_victimName];
        _loc_message = format["PKILL: %1 killed himself", _victimName];
    }
    else
    {
        _killerPlayerID = getPlayerUID _killer;
        _message = format["%1 was killed by %2 with weapon %3 from %4m",_victimName, _killerName, _weapon, _distance];
        _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;
    [nil, nil, rTITLETEXT, _message, "PLAIN DOWN", 0] call RE;
 
    // Cleanup
    _victim setVariable["AttackedBy", "nil", true];
    _victim setVariable["AttackedByName", "nil", true];
    _victim setVariable["AttackedByWeapon", "nil", true];
    _victim setVariable["AttackedFromDistance", "nil", true];
};
 
//dayz_disco = dayz_disco - [_playerID];

Step 5.
Open your dayz_server.pbo and open the folder compile then edit the server_playerSetup.sqf file and find
Code:
if (isNull _playerObj) exitWith {
    diag_log ("SETUP INIT FAILED: Exiting, player object null: " + str(_playerObj));
};
 
if (_playerID == "") then {
    _playerID = getPlayerUID _playerObj;
};
Replace it with
Code:
if (isNull _playerObj) exitWith {
    diag_log ("SETUP INIT FAILED: Exiting, player object null: " + str(_playerObj));
};
 
//Add MPHit event handler
diag_log("Adding MPHit EH for " + str(_playerObj));
_playerObj addMPEventHandler ["MPHit", {_this spawn fnc_plyrHit;}];
 
if (_playerID == "") then {
    _playerID = getPlayerUID _playerObj;
};

Step 6.
Now this code is going to debate weather or not your going to show if a player died by another player or not or just the weapon. Open your day_server.pbo and look in folder compiles and edit server_playerDied.sqf, edit the line
Code:
_message = format["%1 was killed by %2 with weapon %3 from %4m",_victimName, _killerName, _weapon, _distance];
If you just want the player was killed with weapon instead of who killed them, replace the top code with
Code:
_message = format["%1 was killed with weapon %3 from %4m",_victimName, _killerName, _weapon, _distance];
Battleye Edits
Open your battleye/mpeventhandler.txt
find the following line
Code:
5 "spawn" !="spawn BIS_Effects_AirDestruction" !="spawn BIS_Effects_AirDestructionStage2" !="spawn BIS_Effects_Burn"
5 "this" !="this enableSimulation false;this allowDammage false;this disableAI 'FSM';this disableAI 'ANIM';this disableAI 'MOVE';" !="_v setVehicleInit format [\"[this, %1, %2,false,true]spawn BIS_Effects_Burn\",_int, _t];" !="_v setVehicleInit \"[this] spawn BIS_Effects_AirDestruction\";" !="if((local(_this select 0))or(isServer))then{_this call fnc_plyrHit_local;};" !="if(local(_this select 0))then{_this call fnc_plyrDead_local;};"
replace with
Code:
1 "spawn" !="spawn BIS_Effects_AirDestruction" !="spawn BIS_Effects_AirDestructionStage2" !="spawn BIS_Effects_Burn" !="spawn fnc_plyrHit" !"fnc_plyrHit.sqf" !"server_playerSetup.sqf" !"server_playerDied.sqf"
1 "this" !="this enableSimulation false;this allowDammage false;this disableAI 'FSM';this disableAI 'ANIM';this disableAI 'MOVE';" !="this spawn fnc_plyrHit" !="_v setVehicleInit format [\"[this, %1, %2,false,true]spawn BIS_Effects_Burn\",_int, _t];" !="_v setVehicleInit \"[this] spawn BIS_Effects_AirDestruction\";" !="if((local(_this select 0))or(isServer))then{_this call fnc_plyrHit_local;};" !="if(local(_this select 0))then{_this call fnc_plyrDead_local;};"

Now last but not least, open your battleye/remoteexec.txt
find the following line
Code:
5 fnc_
replace with
Code:
1 fnc_

Again thanks to the community for everything hope this helps and you don't have to run around everywhere to try to find out how to do this. If you would like to see future tut please give me a message or post below!


 
I can't find the file named fn_selfActions in either Mission or Server.pbo
Also you haven't said where fnc_plyrHit.sqf needs to be placed, I assume it is in Compiles folder on Server.pbo

Also
server_updateNearbyObjects = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateNearbyObjects.sqf";
is not in my server_functions.sqf

I am using a Bliss build for version 1.7.7.1
 
just 1 question where i can change the time how long the message appears? sometimes its ok sometimes its just pops up for an half second or somthing like that :D

any ideas?
 
I got the Kill Messages to work on my test server. So thank you for the information posted.
I have too have same problem as Hexxar as stated in the above post.

I would like to have the message sent to the Global or Side Chat instead.

So in the file server_playerDied.sqf:


Code:
    {
 
        _killerPlayerID = getPlayerUID _killer;
 
        _message = format["%1 was killed by %2 with weapon %3 from %4m",_victimName, _killerName, _weapon, _distance];
 
        _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;
 
    [nil, nil, rTITLETEXT, _message, "PLAIN DOWN", 0] call RE;



How can i have that exact message sent to Global or Side Chat?

TIA!
StAnky
 
Well I tried this code and it did not work.
Code:
diag_log _loc_message;
 
    [nil, nil, rTITLETEXT, _message, "PLAIN DOWN", 0] call RE;
    [nil, nil, rGLOBALCHAT, _message, "PLAIN DOWN", 0] call RE;

Any ideas as to how i can get this message posted in to the Global Chat?
 
I'd also like to know how to get the message to be displayed in a chat so I can catch it in Gotcha or DaRT....
 
So anyone have an idea how do I add these kill messages to Side Chat? A hint? A nudge? No? Nothing?

We've tried all that we can think of and have reached the end of our collective rope and knowledge.

On a POSITIVE note .....We have had great success breaking all the chat channels and keeping the server from starting ....so if anyone needs help keeping their server from running right we are the resident experts.
 
add sleep to your server_playerdied.sqf

diag_log _loc_message;
[nil, nil, rTITLETEXT, _message, "PLAIN DOWN", 0] call RE;

sleep 30;

// Cleanup
 
St.Anky,
I believe you and I have been looking at this the wrong way...

The kill message is sent to the RPT via 'diag_log _loc_message;' and to all players via rTITLETEXT.
Since we are trying to send to sidechat perhaps 'sidechat _loc_message;' would work?

Current server_playerDied.sqf code displays message in RPT and across screen:

diag_log _loc_message;
[nil,nil,rTITLETEXT, _message, "PLAINDOWN", 0] call RE;

Perhaps if you add the following it will add to the Chat log files?

sidechat _loc_message;
diag_log _loc_message;
[nil,nil,rTITLETEXT, _message, "PLAINDOWN", 0] call RE

I will test later on today when I get home but if someone can check this or verfiy my thoughts it will be great

-Ref
 
Refnen,
I see what you are trying to do but I foresee a problem.

"sidechat _loc_message;"
If that line works, it will produce the PKILL message in the chat box.

I would be more interested in getting the "_message" to show in the chat window.

I guess at this point, getting anything to show in the chat window would be considered a success. Once that task is complete, its just massaging the message to your custom liking.

I will also test your suggestion and report back my findings.

I still can not believe there are not more interest in this....

StAnky
 
St.Anky,
I believe you and I have been looking at this the wrong way...

The kill message is sent to the RPT via 'diag_log _loc_message;' and to all players via rTITLETEXT.
Since we are trying to send to sidechat perhaps 'sidechat _loc_message;' would work?

Current server_playerDied.sqf code displays message in RPT and across screen:

diag_log _loc_message;
[nil,nil,rTITLETEXT, _message, "PLAINDOWN", 0] call RE;

Perhaps if you add the following it will add to the Chat log files?

sidechat _loc_message;
diag_log _loc_message;
[nil,nil,rTITLETEXT, _message, "PLAINDOWN", 0] call RE

I will test later on today when I get home but if someone can check this or verfiy my thoughts it will be great

-Ref


-Ref,
I tried it and it broke the rTITLETEXT _message.
I am thinking that this will never work. I have tried everything that i could find. I do not think this is possible.
At this point, I am will to pay someone to script it for me.
PM me !!!

Stanky
 
-Ref,
The replacement of the line:

"[nil,nil,rTITLETEXT, _message, "PLAINDOWN", 0] call RE;"

with

"[nil, nil, rspawn, [_killer, _message], { (_this select 0) globalChat (_this select 1) }] call RE;"

worked for the global chat window. I was not able to get sidechat to work thought when using
"[nil, nil, rspawn, [_killer, _message], { (_this select 0) sideChat (_this select 1) }] call RE;"
We are getting close.
I will play around with this a little more tonight.
StAnky
 
i tried this thing on my reality server and it kind of made people spawn on there dead bodies :s
might of done something wrong so going to redo it and test again on our test server.
 
-Ref,
The replacement of the line:

"[nil,nil,rTITLETEXT, _message, "PLAINDOWN", 0] call RE;"

with

"[nil, nil, rspawn, [_killer, _message], { (_this select 0) globalChat (_this select 1) }] call RE;"

worked for the global chat window. I was not able to get sidechat to work thought when using
"[nil, nil, rspawn, [_killer, _message], { (_this select 0) sideChat (_this select 1) }] call RE;"
We are getting close.
I will play around with this a little more tonight.
StAnky


Still no luck with that. Hint is working, but i cant get it to work with globalchat.
Any idea what i neet to change to get this working ?
 
Back
Top