Code:
#include <tf2_stocks>
// At first since you changing event strings, event shoul be hooked as Pre and have Action: prefix
public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
// Previous value (32) is TF_DEATHFLAG_DEADRINGER I assume?
new bool:nofakekill = (GetEventInt(event, "death_flags") & TF_DEATHFLAG_DEADRINGER) ? false : true;
new meleeID;//, secondaryID;
decl String:weapon[32];
GetEventString(event, "weapon_logclassname", weapon, sizeof(weapon));
// Create 'headshot' boolean which checks if customkill value was 1 (aka headshot)
new bool:headshot = GetEventInt(event, "customkill") == TF_CUSTOM_HEADSHOT;
// attacker also may be 0, so that's why you got errors
if (1 <= attacker <= MaxClients)
{
new melee = GetPlayerWeaponSlot(attacker, TFWeaponSlot_Melee);
if (IsValidEdict(melee)) meleeID = GetEntProp(melee, Prop_Send, "m_iItemDefinitionIndex");
// Is not used anywhere
//new secondary = GetPlayerWeaponSlot(attacker, TFWeaponSlot_Secondary);
//if (IsValidEdict(secondary)) secondaryID = GetEntProp(secondary, Prop_Send, "m_iItemDefinitionIndex");
}
// Why not just check once if that wasnt fake kill?
if (nofakekill)
{
// Custom Bottle Broken/Unbroken Kills
if (strcmp(weapon, "bottle", false) == 0)
{
SetEventString(event, "weapon_logclassname", GetEntProp(meleeID, Prop_Send, "m_bBroken") ? "bottle_broken" : "bottle_unbroken");
}
// Custom Bleed Kills. Not a bottle, so use else if
else if (strcmp(weapon, "bleed_kill", false) == 0)
{
switch (meleeID)
{
case 155: SetEventString(event, "weapon_logclassname", "bleed_hospitality");
case 171: SetEventString(event, "weapon_logclassname", "bleed_shiv");
case 325: SetEventString(event, "weapon_logclassname", "bleed_basher");
case 452: SetEventString(event, "weapon_logclassname", "bleed_runeblade");
case 648: SetEventString(event, "weapon_logclassname", "bleed_wrap");
case 812, 833: SetEventString(event, "weapon_logclassname", "bleed_cleaver");
}
}
// Custom Demoman Taunt-Kills. Neither bottle nor bleed kills. use else if
else if (strcmp(weapon, "taunt_demoman", false) == 0)
{
switch (meleeID)
{
case 132, 1082: SetEventString(event, "weapon_logclassname", "taunt_demoman_eyelander");
case 357: SetEventString(event, "weapon_logclassname", "taunt_demoman_zatoichi");
case 327: SetEventString(event, "weapon_logclassname", "taunt_demoman_claid");
case 266: SetEventString(event, "weapon_logclassname", "taunt_demoman_headtaker");
case 482: SetEventString(event, "weapon_logclassname", "taunt_demoman_golf");
case 404: SetEventString(event, "weapon_logclassname", "taunt_demoman_persian");
}
}
// Custom Spy Taunt-Kills. Pretty obvious to comment
else if (strcmp(weapon, "taunt_spy", false) == 0)
{
switch (meleeID)
{
case 4, 194, 665, 794, 803, 883, 892, 901, 910, 959, 968: SetEventString(event, "weapon_logclassname", "taunt_spy_knife");
case 423: SetEventString(event, "weapon_logclassname", "taunt_spy_saxxy");
case 225: SetEventString(event, "weapon_logclassname", "taunt_spy_reward");
case 356: SetEventString(event, "weapon_logclassname", "taunt_spy_kunai");
case 461: SetEventString(event, "weapon_logclassname", "taunt_spy_earner");
case 574: SetEventString(event, "weapon_logclassname", "taunt_spy_voodoo");
case 727: SetEventString(event, "weapon_logclassname", "taunt_spy_rose");
}
}
// Custom Headshot Tracking
// I would change this code as well to something like this
// if (headshot)
// switch (weaponID)
// case whatevernumberforsniperrifle, whatevernumberforbazaar, et cetera.
else if (strcmp(weapon, "sniperrifle", false) == 0)
{
if (headshot) SetEventString(event, "weapon_logclassname", "sniperrifle_hs");
}
else if (strcmp(weapon, "tf_projectile_arrow", false) == 0)
{
if (headshot) SetEventString(event, "weapon_logclassname", "huntsman_hs");
}
else if (strcmp(weapon, "bazaar_bargain", false) == 0)
{
if (headshot) SetEventString(event, "weapon_logclassname", "bazaar_hs");
}
else if (strcmp(weapon, "machina", false) == 0)
{
if (headshot) SetEventString(event, "weapon_logclassname", "machina_hs");
}
else if (strcmp(weapon, "pro_rifle", false) == 0)
{
if (headshot) SetEventString(event, "weapon_logclassname", "pro_rifle_hs");
}
else if (strcmp(weapon, "awper_hand", false) == 0)
{
if (headshot) SetEventString(event, "weapon_logclassname", "awper_hand_hs");
}
else if (strcmp(weapon, "ambassador", false) == 0)
{
if (headshot) SetEventString(event, "weapon_logclassname", "ambassador_hs");
}
// Custom Backstabs
if (GetEventInt(event, "customkill") == TF_CUSTOM_BACKSTAB)
{
switch (meleeID)
{
case 4, 194, 665, 794, 803, 883, 892, 901, 910, 959, 968: SetEventString(event, "weapon_logclassname", "backstab_knife");
case 225: SetEventString(event, "weapon_logclassname", "backstab_eternal_reward");
case 356: SetEventString(event, "weapon_logclassname", "backstab_kunai");
case 423: SetEventString(event, "weapon_logclassname", "backstab_saxxy");
case 461: SetEventString(event, "weapon_logclassname", "backstab_big_earner");
case 574: SetEventString(event, "weapon_logclassname", "backstab_voodoo_pin");
case 638: SetEventString(event, "weapon_logclassname", "backstab_sharp_dresser");
case 649: SetEventString(event, "weapon_logclassname", "backstab_spy_cicle");
case 727: SetEventString(event, "weapon_logclassname", "backstab_black_rose");
}
}
// We've changed event strings, so return as Changed.
return Plugin_Changed;
}
// Not a fake death.
// Custom Machina Penetration Headshot I assume?
else if (strcmp(weapon, "player_penetration", false) == 0)
{
if (headshot)
{
SetEventString(event, "weapon_logclassname", "player_penetrationhs");
return Plugin_Changed;
}
}
return Plugin_Continue;
}