Raised This Month: $32 Target: $400
 8% 

[TF2] Did shot hit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 09-25-2016 , 15:10   [TF2] Did shot hit
Reply With Quote #1

I needed a way of checking whether or not a player shot hit anyone and thought someone here might find it useful too.

PHP Code:
public void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_TraceAttackPostTraceAttack);
}

bool g_bShot[MAXPLAYERS 1];

public 
Action TF2_CalcIsAttackCritical(int clientint weaponchar[] weaponnamebool &result)
{
    
g_bShot[client] = true;
    
    
RequestFrame(DidHitGetClientUserId(client));
    
    return 
Plugin_Continue;
}

public 
void TraceAttack(int victimint attackerint inflictorfloat damageint damagetypeint ammotypeint hitboxint hitgroup)
{
    if(
g_bShot[attacker])
    {
        
g_bShot[attacker] = false;
    }
}

public 
void DidHit(int userid)
{
    
int client GetClientOfUserId(userid);
    if(
client 0)
    {
        
PrintToChatAll("DidHit? %s", !g_bShot[client] ? "Yes" "No");
    }

Obiviously it doesn't work with projectile weapons.
__________________

Last edited by Pelipoika; 09-25-2016 at 15:14.
Pelipoika is offline
Reply



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 05:00.


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