Thread: [Solved] [L4D2] Witch headshot
View Single Post
midnight9
Senior Member
Join Date: Nov 2012
Old 06-19-2018 , 18:20   Re: [L4D2] Witch headshot
Reply With Quote #6

Quote:
Originally Posted by alcybery View Post
Like this?
PHP Code:
#pragma semicolon 1

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

public OnPluginStart()
{
    
HookEvent("infected_hurt"WitchHurt_EventEventHookMode_Post);
}

public 
WitchHurt_Event(Handle:event, const String:name[], bool:dontBroadcast)
{
    
// new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
    
new victimEntId GetEventInt(event"entityid");
    new 
hitgroup GetEventInt(event"hitgroup"); //headshot is 1
    
    
if (IsWitch(victimEntId) && hitgroup == 1)
    {
        
PrintToChatAll("Witch headshot registered");
        
//set damage amount to
        // SDKHooks_TakeDamage(victimEntId, attacker, attacker, 300.0, DMG_BULLET, -1, NULL_VECTOR, NULL_VECTOR);
        // Entity_Hurt(victimEntId, 300, attacker);
        
SetEventInt(event"amount"300);
    }
}

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

It doesn't seems to be working, even though headshot still registers.
Dont you need to FireEvent to SetEventInt?
midnight9 is offline