HospitalChair
Well-Known Member
The original thread is located here.
http://opendayz.net/threads/kill-messages-1-8-2.20957/
It was labeled 1.8.2 so I thought I would make a new post to keep things clear. So i loaded this script up and test it out for 18.6.1 and I am getting this error in my rpt and obviously no kill message.
10:26:37 Error in expression <ct 3;
_playerName = name _newObject;
_victim removeAllEventHandlers "MPHit";
>
10:26:37 Error position: <_victim removeAllEventHandlers "MPHit";
>
10:26:37 Error Undefined variable in expression: _victim
10:26:37 File z\addons\dayz_server\compile\server_playerDied.sqf, line 13
I'm including my playerdied.sqf
Server_PlayerDied.sqf
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
private ["_characterID","_minutes","_newObject","_playerID","_key", "_pos"];
//[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;
//---------------------------------------- DEATH MESSAGES --------------------------------------------
_victim removeAllEventHandlers "MPHit"; <-----The error in question
_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"];
_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",_killername,_victim,_weapon,_distance];
// 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];
};
// -----------------------------------------------------------------------------------------------------------
//diag_log format["CID: %1, PID: %2",_characterID,_playerID];
//Mark player as dead so we bypass the ghost system
dayz_died set [count dayz_died, _playerID];
_newObject setVariable["processedDeath",diag_tickTime];
_newObject setVariable ["bodyName", _playerName, true];
_pos = getPosATL _newObject;
if (_pos select 2 < 0.1) then { _pos set [2,0]; }; // force to follow the terrain slope in sched_corpses.sqf
_newObject setVariable [ "deathPos", _pos];
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;
};
#ifdef PLAYER_DEBUG
diag_log 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
_newObject setDamage 1;
_newObject setOwner 0;
//dead_bodyCleanup set [count dead_bodyCleanup,_newObject];
I'm not sure if something has changed with the 1.8.6.1 patch so I'm deferring this to some guys a bit more savvy than myself.
http://opendayz.net/threads/kill-messages-1-8-2.20957/
It was labeled 1.8.2 so I thought I would make a new post to keep things clear. So i loaded this script up and test it out for 18.6.1 and I am getting this error in my rpt and obviously no kill message.
10:26:37 Error in expression <ct 3;
_playerName = name _newObject;
_victim removeAllEventHandlers "MPHit";
>
10:26:37 Error position: <_victim removeAllEventHandlers "MPHit";
>
10:26:37 Error Undefined variable in expression: _victim
10:26:37 File z\addons\dayz_server\compile\server_playerDied.sqf, line 13
I'm including my playerdied.sqf
Server_PlayerDied.sqf
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
private ["_characterID","_minutes","_newObject","_playerID","_key", "_pos"];
//[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;
//---------------------------------------- DEATH MESSAGES --------------------------------------------
_victim removeAllEventHandlers "MPHit"; <-----The error in question
_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"];
_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",_killername,_victim,_weapon,_distance];
// 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];
};
// -----------------------------------------------------------------------------------------------------------
//diag_log format["CID: %1, PID: %2",_characterID,_playerID];
//Mark player as dead so we bypass the ghost system
dayz_died set [count dayz_died, _playerID];
_newObject setVariable["processedDeath",diag_tickTime];
_newObject setVariable ["bodyName", _playerName, true];
_pos = getPosATL _newObject;
if (_pos select 2 < 0.1) then { _pos set [2,0]; }; // force to follow the terrain slope in sched_corpses.sqf
_newObject setVariable [ "deathPos", _pos];
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;
};
#ifdef PLAYER_DEBUG
diag_log 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
_newObject setDamage 1;
_newObject setOwner 0;
//dead_bodyCleanup set [count dead_bodyCleanup,_newObject];
I'm not sure if something has changed with the 1.8.6.1 patch so I'm deferring this to some guys a bit more savvy than myself.