Code:
#include <sourcemod.inc>
public Plugin:myinfo =
{
name = "SnipemanMod",
author = "Snipeman ([email protected])",
description = "Various TF2 gameplay tweaks.",
version = "1.0.0.0",
url = "http://www.sourcemod.net/"
};
new Handle:g_Cvar_hide_kills_knife = INVALID_HANDLE
new Handle:g_Cvar_hide_kills_sapper = INVALID_HANDLE
public OnPluginStart()
{
HookEvent("player_death", SnipemanMod_PlayerDeath, EventHookMode_Pre)
HookEvent("object_destroyed", SnipemanMod_ObjectDestroyed, EventHookMode_Pre)
g_Cvar_hide_kills_knife = CreateConVar( "sm_hide_kills_knife", "1", "If 1, backstab kills will not show on the HUD." )
g_Cvar_hide_kills_sapper = CreateConVar( "sm_hide_kills_sapper", "1", "If 1, sapper kills (on buildings) will not show on the HUD." )
AutoExecConfig( true, "plugin_snipeman")
}
public Action:SnipemanMod_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
if ( !GetConVarBool(g_Cvar_hide_kills_knife) )
{
return Plugin_Continue
}
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
new damagebits = GetEventInt(event, "damagebits");
new customkill = GetEventInt(event, "customkill");
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
decl String:weaponName[32];
GetEventString(event, "weapon", weaponName, sizeof(weaponName));
decl String:attackerName[32]
GetClientName(attacker, attackerName, sizeof(attackerName));
decl String:victimName[32]
GetClientName(victim, victimName, sizeof(victimName));
if (StrEqual(weaponName, "knife"))
{
if(damagebits == 1052802 && customkill == 2){
PrintToChat(attacker, "You backstabbed %s", victimName);
PrintToChat(victim, "You was backstabbed by %s", attackerName);
}
else if(damagebits == 4226 && customkill == 2)
{
PrintToChat(attacker, "You backstabbed %s", victimName);
PrintToChat(victim, "You was backstabbed by %s", attackerName);
}
else
{
PrintToChat(attacker, "You knifed %s", victimName);
PrintToChat(victim, "You was knifed by %s", attackerName);
}
return Plugin_Handled;
}
return Plugin_Continue
}
public Action:SnipemanMod_ObjectDestroyed(Handle:event, const String:name[], bool:dontBroadcast)
{
if ( !GetConVarBool(g_Cvar_hide_kills_sapper) )
{
return Plugin_Continue
}
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
decl String:attackerName[32]
GetClientName(attacker, attackerName, sizeof(attackerName));
decl String:victimName[32]
GetClientName(victim, victimName, sizeof(victimName));
decl String:weaponName[32];
GetEventString(event, "weapon", weaponName, sizeof(weaponName));
new objectName = GetEventInt(event, "objecttype");
if (StrEqual(weaponName, "obj_attachment_sapper"))
{
switch(objectName)
{
case 0:{
PrintToChat(attacker, "You destroyed %s dispenser", victimName);
PrintToChat(victim, "%s destroyed your dispenser", attackerName);
}
case 1:{
PrintToChat(attacker, "You destroyed %s teleporter entrance", victimName);
PrintToChat(victim, "%s destroyed your teleporter entrance", attackerName);
}
case 2:{
PrintToChat(attacker, "You destroyed %s teleporter exit", victimName);
PrintToChat(victim, "%s destroyed your teleporter exit", attackerName);
}
case 3:{
PrintToChat(attacker, "You destroyed %s sentry gun", victimName);
PrintToChat(victim, "%s destroyed your sentry gun", attackerName);
}
}
}
return Plugin_Continue
}