Request Help - Detailed kill messages for Overwatch

DangerRuss

OpenDayZ Rockstar!
Prior to the steam update, I used this custom server_playerdied.sqf that would detail who killed who, with what weapon, and from how far away. But it was flawed and occasionally players would respawn back at their bodies fully geared.
Code:
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"

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, rspawn, [_killer, _message], { (_this select 0) globalChat (_this select 1) }] 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];
_newObject setVariable["processedDeath",time];
_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));   
    };
*/

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_DEBUG
format ["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

/*
_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];

sleep 600;
deleteVehicle _newObject;

Either way this no longer works after the steam update. Does anyone have a working custom death message script that details who killed who and with what weapon and from how far? This is really a big deal for a PVP server. Thanks a lot for any help.
 
Very interesting. I have been trying to get my globalChat messages to work all day but I cant't seem to get them to work. And since these deathmessages work through globalChat that might be the issue. I'll test if this works with sideChat. I'll report back soon.

EDIT: Ok sideChat doesn't seem to work as well. I have no idea what happend.
 
Last edited:
I actually did get this to work on my server. I followed these instructions http://dayz.st/w/Kill_Messages except I used the server_playerdied.sqf I posted above instead, with one minor change. I compared it to the default server_playerdied.sqf, and of the parts that were unchanged I noticed one small difference.
Instead of
Code:
_newObject setVariable["processedDeath",time];
I changed "time" to "diag_tickTime"
Code:
_newObject setVariable["processedDeath",diag_tickTime];
This got them working, although it still doesn't seem quite right. It doesn't seem to do it every time, especially when a lot of people are on and the server gets a bit laggy. I'd love to know how Player 2 does it on their server where it shows the picture of the gun instead of the classname. People see "vil_sg542f" and scratch their heads lol.
 
I actually did get this to work on my server. I followed these instructions http://dayz.st/w/Kill_Messages except I used the server_playerdied.sqf I posted above instead, with one minor change. I compared it to the default server_playerdied.sqf, and of the parts that were unchanged I noticed one small difference.
Instead of
Code:
_newObject setVariable["processedDeath",time];
I changed "time" to "diag_tickTime"
Code:
_newObject setVariable["processedDeath",diag_tickTime];
This got them working, although it still doesn't seem quite right. It doesn't seem to do it every time, especially when a lot of people are on and the server gets a bit laggy. I'd love to know how Player 2 does it on their server where it shows the picture of the gun instead of the classname. People see "vil_sg542f" and scratch their heads lol.

server_playerDied.sqf
Code:
private ["_characterID","_minutes","_newObject","_playerID","_playerName","_victim","_victimName","_killer","_killerName","_weapon","_distance","_message","_loc_message","_killerPlayerID","_key","_eh","_body","_method","_killmsg","_pic","_safeOffset","_lvl","_isHeadshot"];


_characterID =     _this select 0;
_minutes =    _this select 1;
_newObject =     _this select 2;
_playerID =     _this select 3;
_playerName =     name _newObject;

_victim = _this select 2;
_victim removeAllEventHandlers "MPHit";
_victim setVariable["processedDeath",time];
_victim setVariable ["bodyName", _playerName, true];
_victimName = _victim getVariable["bodyName", "nil"];

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



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 
{
_loc_message = format["KILLMSG: %1 Was Killed By %2 With A %3 From %4m", _victimName, _killerName, _weapon, _distance];
_message = format["%1 killed by %2 with %3 from %4m",_victimName, _killerName, _weapon, _distance];

if (_distance > 2000) then {
_distance = -1;
} else {
_distance = round _distance;
};

_pic = (getText (configFile >> 'cfgWeapons' >> _weapon >> 'picture'));
if (_pic == "") then {
_pic = (getText (configFile >> 'cfgVehicles' >> _weapon >> 'picture'));
};

[nil, nil, rspawn, [_killerName, _pic, _victimName, _distance, nil, nil], {
_killerName = _this select 0;
_pic        = _this select 1;
_victimName = _this select 2;
_distance     = _this select 3;
if (line4 == 1) then {
line0 = 1; lvl = 6000; safeOffset = 0;
line1 = 0; line2 = 0; line3 = 0; line4 = 0;
[] spawn { sleep 10; line0 = 0; };
} else { if (line3 == 1) then {
line4 = 1; lvl = 6004; safeOffset =0.2;
[] spawn { sleep 10; line4 = 0; };
} else { if (line2 == 1) then {
line3 = 1; lvl = 6003; safeOffset = 0.15;
[] spawn { sleep 10; line3 = 0; };
} else { if (line1 == 1) then {
line2 = 1; lvl = 6002; safeOffset = 0.1;
[] spawn { sleep 10; line2 = 0; };
} else { if (line0 == 1) then {
line1 = 1; lvl = 6001; safeOffset = 0.05;
[] spawn { sleep 10; line1 = 0; };
} else { line0 = 1; lvl = 6000; safeOffset = 0; [] spawn { sleep 10; line0 = 0; };};};};};};
["<t color='#ffffff' align='left' size='0.66'>"+_killerName+" </t><img align='left' size='1' image='"+_pic+"'/><t color='#ffffff' align='left' size='0.66'> "+_victimName+" ["+str _distance+"m]</t>",safezoneX,(safezoneY + safeOffset),9,0,0,lvl] spawn yoloText;

}] call RE;


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


_newObject setVariable["processedDeath",diag_tickTime];
_newObject setVariable ["bodyName", _playerName, true];


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

if (_characterID != "0") then 
{
_key = format["CHILD:202:%1:%2:",_characterID,_minutes];

_key call server_hiveWrite;
} 
else 
{
deleteVehicle _newObject;
};


format ["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
];

It's not the version from Player 2 but it has the same results. ;)
 
Oh add this to compiles.sqf:
Code:
yoloText = compile preprocessFileLineNumbers "ca\modules_e\functions\GUI\fn_dynamicText.sqf";
 
Oh add this to compiles.sqf:
Code:
yoloText = compile preprocessFileLineNumbers "ca\modules_e\functions\GUI\fn_dynamicText.sqf";
anywhere?
also shouldn't it be "\ca\" ? or no?


hmmm I don't think the server_playerdied.sqf you provided is working for me.
 
Last edited:
You got any errors in RPT? I might be missing something. And ye anywhere in (!isDedicated){} should be good.
 
You got any errors in RPT? I might be missing something. And ye anywhere in (!isDedicated){} should be good.
Oddly enough I don't see any errors pertaining to the server_playerDied.sqf.

My server_monitor is wrong and spamming my RPT, still not updating tents. Can't find the right one, and I if I did I wouldn't know where to add guns to some of the vehicles I gave guns to.

The weird thing is, my server_playerDied.sqf that I posted above, although it works, produces an error.
Code:
16:27:21 WARNING: Function 'name' - [DZBS]Weston is dead
16:27:21 Error in expression <ect 3;
_playerName =     name _newObject;

_victim removeAllEventHandlers "MPHit";
>
16:27:21   Error position: <_victim removeAllEventHandlers "MPHit";
>
16:27:21   Error Undefined variable in expression: _victim
16:27:21 File z\addons\dayz_server\compile\server_playerDied.sqf, line 11

and I had correctly placed that line before you answered, unless I was wrong in adding the "\" I thought you were missing
Code:
    BIS_Effects_Burn = compile preprocessFile "\ca\Data\ParticleEffects\SCRIPTS\destruction\burn.sqf";
    yoloText = compile preprocessFileLineNumbers "\ca\modules_e\functions\GUI\fn_dynamicText.sqf";

Does it matter that yours lacks
Code:
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
 
Last edited:
I don't have the \ I copied that straight from my own compiles.sqf. Not sure if it matters.

for your error change:

Code:
_victim = _this select 2;
to
Code:
 _victim = _this select 5;
 
gonna try yours again and correct that line in the compiles.sqf

I wonder if there were some other steps to get yours to work? Similar to the dayz.st instructions how I had to make a fnc_plyrHit.sqf and modify the server_playersetup.sqf...

I'll report back if it works or not.

Edit - Yea still nothing showing up. It ass MPHIT to players when they log in, and it seems to be recording when players are hit as a PHIT.

When someone is hit and killed
Code:
11:01:04 "P1ayer PID#29(Fox) hit by PID#16(Faison) with RH_hk417sglaim/B_762x51_noTracer <ammo left:18> from 53 meters"
11:01:04 "z\addons\dayz_code\medical\setup_functions_med.sqf::fnc_usec_damageBleed [B 1-4-D:1 (Fox) REMOTE,"neck",1.06771]"
11:01:04 "z\addons\dayz_code\medical\setup_functions_med.sqf::fnc_usec_damageBleed [B 1-4-D:1 (Fox) REMOTE,"aimpoint",1.44106]"
11:01:04 "z\addons\dayz_code\medical\setup_functions_med.sqf::fnc_usec_damageBleed [B 1-4-D:1 (Fox) REMOTE,"Pelvis",1.23527]"
11:01:04 "z\addons\dayz_code\medical\setup_functions_med.sqf::fnc_usec_damageBleed [B 1-4-D:1 (Fox) REMOTE,"pilot",1.06771]"
11:01:05 "z\addons\dayz_code\medical\setup_functions_med.sqf::fnc_usec_damageBleed [B 1-4-D:1 (Fox) REMOTE,"relbow",0.995019]"
11:01:05 "PHIT: B 1-4-D:1 (Fox) REMOTE (76561198083887724) was hit by B 1-3-C:1 (Faison) REMOTE (76561198138725321) with RH_hk417sglaim from 53.0121m"
11:01:05 WARNING: Function 'name' - Fox is dead

When someone logs in
Code:
11:01:48 "Adding MPHit EH for B 1-3-D:1 (Fox) REMOTE"
11:01:48 "LOGIN PUBLISHING: UID#76561198083887724 CID#23958 PID#29(Fox) as Survivor2_DZ should spawn at factory [132:78]"

Here is my fnc_plyrHit.sqf maybe I need to edit this for yours to work?
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];
 
Last edited:
My fnc_plyrHit.sqf is pretty much the same. Don't think it was anything in there. I can't remember what it was exactly. Installed this a long long time ago. I think it might be in player_death.sqf. Could you send that? I'll have a look.
 
My fnc_plyrHit.sqf is pretty much the same. Don't think it was anything in there. I can't remember what it was exactly. Installed this a long long time ago. I think it might be in player_death.sqf. Could you send that? I'll have a look.

Here is the default player_death.sqf in my dayz_code.pbo. I haven't added a custom one to the server.
http://pastebin.com/sWprHSaJ
 
Last edited:
Well that's not it either. I'm not entirely sure anymore whats needed to get it to work. I thought player_died was enough + the compiles stuff was enough but if you say it's not then I'm not sure. Something is missing. I'm pretty sure it should work tho.
 
did you add anything to server_playersetup.sqf?
I added
Code:
//Add MPHit event handler
diag_log("Adding MPHit EH for " + str(_playerObj));
_playerObj addMPEventHandler ["MPHit", {_this spawn fnc_plyrHit;}];

I also quoted out the enable radio section of my init.sqf. If you figure it out, let me know man I am very interested!
 
did you add anything to server_playersetup.sqf?
I added
Code:
//Add MPHit event handler
diag_log("Adding MPHit EH for " + str(_playerObj));
_playerObj addMPEventHandler ["MPHit", {_this spawn fnc_plyrHit;}];

I also quoted out the enable radio section of my init.sqf. If you figure it out, let me know man I am very interested!

I have this as well. I feel like it should work tho. damn I can't remember what I did to get this working XD
 
It'll come to you Im sure. Mind if I pick your brain about and overwatch issue? The default server_monitor.sqf I have is incorrect. It's not updating tent inventories to the database. Do you have a correct one? Also, I use the server_monitor to add guns to the little birds and an2 biplanes, but I wouldn't know where to enter the code correctly in a new server_monitor.
I've tried a few different server_monitor.sqf files and they all seem to be wrong. Only one was updating tent inventories to the database but it was causing destroyed vehicles to respawn very high in the air.
 
For Littlebirds and bi planes with guns put this somewhere in if(isServer in server_monitor

Code:
            if (_entity isKindOf "AN2_DZ") then {
            _entity addWeapon "M240_veh";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            };
            if (_entity isKindOf "AH6X_DZ") then {
            _entity addWeapon "M240_veh";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            };
            if (_entity isKindOf "MH6J_DZ") then {
            _entity addWeapon "M240_veh";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            };

For the tents I'm pretty sure that inventory gets saved by server_updateObject.sqf. But you said you had a error in your server monitor post that error and your server monitor and i'll have a look.
 
Also, I tried your fix for my server_playerdied.sqf by changing
Code:
_victim = _this select 2;
to
Code:
_victim = _this select 5;
but it doesn't work and I get this error
Code:
18:22:39 WARNING: Function 'name' - C. Blackburn  is dead
18:22:39 Error in expression <ect 3;
_playerName =     name _newObject;

_victim removeAllEventHandlers "MPHit";
>
18:22:39   Error position: <_victim removeAllEventHandlers "MPHit";
>
18:22:39   Error Undefined variable in expression: _victim
18:22:39 File z\addons\dayz_server\compile\server_playerDied.sqf, line 11
 
For Littlebirds and bi planes with guns put this somewhere in if(isServer in server_monitor

Code:
            if (_entity isKindOf "AN2_DZ") then {
            _entity addWeapon "M240_veh";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            };
            if (_entity isKindOf "AH6X_DZ") then {
            _entity addWeapon "M240_veh";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            };
            if (_entity isKindOf "MH6J_DZ") then {
            _entity addWeapon "M240_veh";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            _entity addMagazine "100Rnd_762x51_M240";
            };

For the tents I'm pretty sure that inventory gets saved by server_updateObject.sqf. But you said you had a error in your server monitor post that error and your server monitor and i'll have a look.

Yea everything I read said it's a bad server_monitor, and I've found a server_monitor that did update tents, just spawned vehicles wonky. I know about that code above, but placement in the "updated" server_monitor.sqf was what I don't know. It works fine in my current server_monitor.sqf however.

RPT error
Code:
diag_log ("HIVE: got>
18:19:54   Error Undefined variable in expression: _hiveresponse
18:19:54 File z\addons\dayz_server\system\server_monitor.sqf, line 77
18:19:54 Error in expression <,6,6,2,2,1,7,10,5,1,1,1,1,2,1,1,3,1,3,2,>
18:19:54   Error position: <>
18:19:54   Error Missing ]
18:19:54 Error in expression <,6,6,2,2,1,7,10,5,1,1,1,1,2,1,1,3,1,3,2,>
18:19:54   Error position: <>
18:19:54   Error Missing ]
18:19:54 Error in expression <ray = call compile format ["%1",_data];
_resultArray;
};

onPlayerDisconnected     >
18:19:54   Error position: <_resultArray;
};
http://pastebin.com/657a2j3A Server_monitor.sqf thanks dude.
 
Back
Top