Thread: [Solved] [L4D2] Witch headshot
View Single Post
eyal282
Veteran Member
Join Date: Aug 2011
Old 06-21-2018 , 06:41   Re: [L4D2] Witch headshot
Reply With Quote #9

Quote:
Originally Posted by alcybery View Post
Can someone help me with that code? I tried FireEvent, but still no luck.
FireEvent will destroy the entirety of your purpose, FireEvent is when you CREATE AN EVENT, NOT USE AN EXISTING EVENT. And I just realized the issue you got. You are dealing two different damages. The headshot damage and the 300.0 so your plugin won't combine them.

Code:
#pragma semicolon 1 

#include <sourcemod> 
#include <sdktools> 
#include <sdkhooks> 
#include <smlib> 

public OnEntityCreated(entity, const String:Classname[])
{
    if(StrEqual(Classname, "witch"))
    {
        SDKHook(entity, SDKHook_TakeDamageAlive, Event_TraceAttack);
    }
}

public Action:Event_TraceAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
{

    if(hitgroup == 1)
    {
        damage += 300.0;
        return Plugin_Changed;
    }

    return Plugin_Continue;

}

stock bool:IsWitch(iEntity) 
{ 
    if(iEntity > 0 && IsValidEntity(iEntity) && IsValidEdict(iEntity)) 
    { 
        decl String:strClassName[64]; 
        GetEdictClassname(iEntity, strClassName, sizeof(strClassName)); 
        return StrEqual(strClassName, "witch"); 
    } 
    return false; 
}









Tell me if it works.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline