View Single Post
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-17-2017 , 18:39   Re: Request - l4d2 reflect damage plugin
Reply With Quote #10

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<= MaxClientsi++)
    {
        if(
IsClientInGame(i) && IsClientAuthorized(i)) OnClientPostAdminCheck(i);
    }

}

public 
void OnClientPostAdminCheck(client)
{
    
SDKHookEx(clientSDKHook_OnTakeDamageOnTakeDamage);
    
IsAdmin[client] = CheckCommandAccess(client"sm_admin"ADMFLAG_GENERIC);
}

public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetype)
{
    if( !(
attacker <= MaxClients) || !IsClientInGame(attacker) || victim == attacker || IsAdmin[attacker]) return Plugin_Continue;

    if(
GetClientTeam(victim) == GetClientTeam(attacker))
    {
        
int weapon GetEntPropEnt(attackerProp_Send"m_hActiveWeapon");

        if(
attacker != inflictorweapon inflictor;

        
// Fix bug?
        
if(!IsPlayerAlive(attacker) || weapon == -1) return Plugin_Handled;

        
char classname[MAX_NAME_LENGTH];
        
GetEntityClassname(weaponclassnamesizeof(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(victimProp_Send"m_pounceAttacker") == -&& // hunter
             
GetEntPropEnt(victimProp_Send"m_jockeyAttacker") == -&& // jockey
             
GetEntPropEnt(victimProp_Send"m_tongueOwner") == -&& // tongue
             
GetEntPropEnt(victimProp_Send"m_carryAttacker") == -&& // charger
             
GetEntPropEnt(victimProp_Send"m_pummelAttacker") == -&& // charger ??
            
!GetEntProp(victimProp_Send"m_isIncapacitated") &&
            !
GetEntProp(victimProp_Send"m_isHangingFromLedge") )
            {
                
SDKHooks_TakeDamage(attackerinflictorattackerdamagedamagetypeweapon);
                
//PrintToServer("-classname %s %f", classname, damage);
            
}

        
damage 0.0;
        return 
Plugin_Changed;
    }

    return 
Plugin_Continue;

__________________
Do not Private Message @me

Last edited by Bacardi; 10-17-2017 at 18:40.
Bacardi is offline