Raised This Month: $ Target: $400
 0% 

HeadShot Only?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Luke Penny
Senior Member
Join Date: Jan 2010
Location: Canada
Old 09-30-2010 , 21:57   HeadShot Only?
Reply With Quote #1

I'm trying to make Tanks only take damage from headshots in L4D, but it doesn't seem to work.

Here's what I have:

PHP Code:
public Action:Event_Player_Hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
userid GetEventInt(event"userid");
    new 
client GetClientOfUserId(userid);
    
decl String:model[40];
    
GetClientModel(clientmodel40);
    if (!
strcmp(model"models/infected/hulk.mdl"false))
    {
        new 
hitgroup GetEventInt(event"hitgroup");
        
//Do 0 damage if 
        
if (hitgroup != 1)
        {
            return 
Plugin_Handled;
        }
    }
    return 
Plugin_Continue;

Any thoughts?
__________________
Luke Penny is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 09-30-2010 , 22:15   Re: HeadShot Only?
Reply With Quote #2

you'll probably want to look into using SDKHooks and the TraceAttack feature (at least I think it's functioning on L4D). Player Hurt fires after the player has been injured, so you can't stop damage that way if memory serves me correctly. The most you can do is heal back the damage that has been dealt. The better solution, however, is to use SDKHooks and OnPlayerDamage or TraceAttack, determine if it's a headshot, then block it if it's not.
__________________
thetwistedpanda is offline
CanadaRox
Member
Join Date: Dec 2009
Old 10-04-2010 , 08:59   Re: HeadShot Only?
Reply With Quote #3

In "SDKHook_OnTakeDamage" I believe the damagetype includes a flag for if it is a headshot or not. Just check that + if they player is the tank to determine if damage is allowed or not.
CanadaRox is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 10-04-2010 , 11:24   Re: HeadShot Only?
Reply With Quote #4

OnTakeDamage doesn't have the hitbox var, but TraceAttack does.
Damagetype flag is probably just that, damage type, as in DMG_CRUSH, etc...
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys 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 15:42.


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