AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [TF2] Did shot hit (https://forums.alliedmods.net/showthread.php?t=288264)

Pelipoika 09-25-2016 15:10

[TF2] Did shot hit
 
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.


All times are GMT -4. The time now is 18:53.

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