Thread: [Solved] [L4D2] Witch headshot
View Single Post
alcybery
Member
Join Date: Apr 2016
Old 06-19-2018 , 17:27   Re: [L4D2] Witch headshot
Reply With Quote #5

Quote:
Originally Posted by Spirit_12 View Post
Try to set the damage value for "amount" in the event. Seems like that's where the other plugins are catching the value.

https://sm.alliedmods.net/new-api/events/Event/SetInt
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.

Last edited by alcybery; 06-19-2018 at 17:28.
alcybery is offline