Raised This Month: $51 Target: $400
 12% 

Solved [TF2] Detecting Headshots


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ravrob
Junior Member
Join Date: Oct 2019
Location: The Ice
Old 11-10-2020 , 19:15   [TF2] Detecting Headshots
Reply With Quote #1

I'm trying to create a script that will increase the decaps and focus meter of the Bazaar Bargain and the Hitman's Heatmaker, however I only want this to trigger upon a headshot. Now I've got the first part of that figured out, however when I try to detect a headshot using TF_CUSTOM_HEADSHOT and TF_CUSTOM_HEADSHOT_DECAPITATION it also counts scoped bodyshots. I've tried this with both OnTakeDamage and the player_hurt event, both yield the same results. I'd really appreciate some advice.

PHP Code:
        switch (weaponid)
        {
            case (
77):
            if(
HasEntProp(attackerProp_Send"m_iDecapitations") && TF_CUSTOM_HEADSHOT)
            {
                
SetEntProp(attackerProp_Send"m_iDecapitations"GetEntProp(attackerProp_Send"m_iDecapitations") + 1);
            }
        
            case (
17):
            if (
HasEntProp(attackerProp_Send"m_flRageMeter") && TF_CUSTOM_HEADSHOT && GetEntPropFloat(attackerProp_Send"m_flRageMeter") < 100.0)
            {
                
SetEntPropFloat(attackerProp_Send"m_flRageMeter"GetEntPropFloat(attackerProp_Send"m_flRageMeter") + 20.0);
            }
        } 
In the code above I'm using the event player_hurt.

Last edited by Ravrob; 11-10-2020 at 19:54.
Ravrob is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 11-10-2020 , 19:34   Re: [TF2] Detecting Headshots
Reply With Quote #2

Your if statement isn't doing any tests on TF_CUSTOM_HEADSHOT, so that's evaluating to true, being a non-zero value.

I've done something similar with a custom attribute that adds rage on headshot.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop is offline
Ravrob
Junior Member
Join Date: Oct 2019
Location: The Ice
Old 11-10-2020 , 19:52   Re: [TF2] Detecting Headshots
Reply With Quote #3

Ah! Excellent, now that you point that out that makes perfect sense. One more line of code and it works just fine. Thanks!
Ravrob 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 23:16.


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