Raised This Month: $ Target: $400
 0% 

Solved [L4D2] Witch headshot


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
alcybery
Member
Join Date: Apr 2016
Old 06-18-2018 , 19:50   [L4D2] Witch headshot
Reply With Quote #1

I'm trying to make a plugin so the witch would die from a headshot from any weapon. I tried SDKHooks_TakeDamage and Entity_Hurt, both of those methods work, but show incorrect damage amount in witch damage announce plugin. Is there a way to fix it?

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)
    {
        
//set damage amount to
        // SDKHooks_TakeDamage(victimEntId, attacker, attacker, 300.0, DMG_BULLET, -1, NULL_VECTOR, NULL_VECTOR);
        
Entity_Hurt(victimEntId300attacker);
    }
}

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

Working code:
PHP Code:
#pragma semicolon 1 

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

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

public 
Action:Event_TraceAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotypehitboxhitgroup)
{

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

    return 
Plugin_Continue;

}

stock bool:IsWitch(iEntity

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


Last edited by alcybery; 06-26-2018 at 13:17.
alcybery is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode