Updated. I added SDKHook_TakeDamage back.
And check is attacker still alive and weapon have not null index.
Added some pinned checks
PHP Code:
#include <sdktools>
#include <sdkhooks>
bool IsAdmin[MAXPLAYERS+1];
public void OnPluginStart()
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i) && IsClientAuthorized(i)) OnClientPostAdminCheck(i);
}
}
public void OnClientPostAdminCheck(client)
{
SDKHookEx(client, SDKHook_OnTakeDamage, OnTakeDamage);
IsAdmin[client] = CheckCommandAccess(client, "sm_admin", ADMFLAG_GENERIC);
}
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
if( !(0 < attacker <= MaxClients) || !IsClientInGame(attacker) || victim == attacker || IsAdmin[attacker]) return Plugin_Continue;
if(GetClientTeam(victim) == GetClientTeam(attacker))
{
int weapon = GetEntPropEnt(attacker, Prop_Send, "m_hActiveWeapon");
if(attacker != inflictor) weapon = inflictor;
// Fix bug?
if(!IsPlayerAlive(attacker) || weapon == -1) return Plugin_Handled;
char classname[MAX_NAME_LENGTH];
GetEntityClassname(weapon, classname, sizeof(classname));
if(StrEqual(classname, "inferno", false) || StrEqual(classname, "pipe_bomb_projectile", false)) return Plugin_Continue;
//PrintToServer("classname %s %f", classname, damage);
//inferno
//pipe_bomb_projectile
if( GetEntPropEnt(victim, Prop_Send, "m_pounceAttacker") == -1 && // hunter
GetEntPropEnt(victim, Prop_Send, "m_jockeyAttacker") == -1 && // jockey
GetEntPropEnt(victim, Prop_Send, "m_tongueOwner") == -1 && // tongue
GetEntPropEnt(victim, Prop_Send, "m_carryAttacker") == -1 && // charger
GetEntPropEnt(victim, Prop_Send, "m_pummelAttacker") == -1 && // charger ??
!GetEntProp(victim, Prop_Send, "m_isIncapacitated") &&
!GetEntProp(victim, Prop_Send, "m_isHangingFromLedge") )
{
SDKHooks_TakeDamage(attacker, inflictor, attacker, damage, damagetype, weapon);
//PrintToServer("-classname %s %f", classname, damage);
}
damage = 0.0;
return Plugin_Changed;
}
return Plugin_Continue;
}
__________________