Raised This Month: $ Target: $400
 0% 

Detect Weapons in Hamsandwich Ham_TakeDamage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 12-21-2008 , 12:04   Detect Weapons in Hamsandwich Ham_TakeDamage
Reply With Quote #1

I am using
Code:
RegisterHam(Ham_TakeDamage,"player","ClientDamage")
I would rather do everything in hamsandwich if possible, as opposed to trying to work with client_damage in The Specialists -- which actually, I'm not sure if it's even possible to use both.

So, what I want to do is detect the weapon that was used to cause the damage within the ClientDamage function. Is this possible? If so, how?
__________________
Bad_Bud is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-21-2008 , 12:48   Re: Detect Weapons in Hamsandwich Ham_TakeDamage
Reply With Quote #2

Quote:
Originally Posted by Bad_Bud View Post
I am using
Code:
RegisterHam(Ham_TakeDamage,"player","ClientDamage")
I would rather do everything in hamsandwich if possible, as opposed to trying to work with client_damage in The Specialists -- which actually, I'm not sure if it's even possible to use both.

So, what I want to do is detect the weapon that was used to cause the damage within the ClientDamage function. Is this possible? If so, how?
This is how I ignore knife usage for my aimbot detection plugin.

Code:
public func_Ham_TakeDamage(victim, inflictor, attacker, Float:fDamage, bitDamage) {     ....     new iWeaponUsed = get_user_weapon( inflictor ,_,_)                 if( iWeaponUsed == CSW_KNIFE )         return PLUGIN_CONTINUE     ... }

I also use !(bitDamage & DMG_GRENADE) to ignore grenade damage but not sure if this can be used to detect all weapons.
__________________
Bugsy is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 12-21-2008 , 12:54   Re: Detect Weapons in Hamsandwich Ham_TakeDamage
Reply With Quote #3

Thanks!

Do you have any idea what the difference between inflictor and attacker are? From what I could tell when I tested with several people spamming chat of who was: this, inflictor, attacker, etc; attacker and inflictor were always the same.
__________________
Bad_Bud is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-21-2008 , 13:01   Re: Detect Weapons in Hamsandwich Ham_TakeDamage
Reply With Quote #4

Quote:
Originally Posted by Bad_Bud View Post
Thanks!

Do you have any idea what the difference between inflictor and attacker are? From what I could tell when I tested with several people spamming chat of who was: this, inflictor, attacker, etc; attacker and inflictor were always the same.
From ham_const.inc
/*
* Ham_TakeDamage
* Description: Usually called whenever an entity takes any kind of damage.
* Inflictor is the entity that caused the damage (such as a gun).
* Attacker is the entity that tirggered the damage (such as the gun's owner).
* Forward params: function(this, idinflictor, idattacker, Float:damage, damagebits);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_TakeDamage, this, idinflictor, idattacker, Float:damage, damagebits);
*/
__________________
Bugsy is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 12-21-2008 , 13:56   Re: Detect Weapons in Hamsandwich Ham_TakeDamage
Reply With Quote #5

Right. Should have read that one myself, considering I have the include open in notepad right now.

Still havn't gotten a chance to try get_user_weapon because I can't get my friends to join my server to experiment with it.

It may just return inflictor. Thanks again.
__________________
Bad_Bud is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-21-2008 , 14:02   Re: Detect Weapons in Hamsandwich Ham_TakeDamage
Reply With Quote #6

Quote:
Originally Posted by Bad_Bud View Post
Right. Should have read that one myself, considering I have the include open in notepad right now.

Still havn't gotten a chance to try get_user_weapon because I can't get my friends to join my server to experiment with it.

It may just return inflictor. Thanks again.
Here are additional checks that you may want

PHP Code:
switch( get_user_weaponinflictor ,_,_) )
{
    
//Pistols and primary weapons with little to no recoil
    
case CSW_AWP,CSW_G3SG1,CSW_SG550,CSW_SCOUT,CSW_GLOCK18,CSW_DEAGLE,CSW_P228,CSW_ELITE,CSW_FIVESEVEN,CSW_USP
    {
        
    }
    default: 
    {
        
//All other weapons
    
}
}

new 
iGun
new iHitzone
get_user_attacker
victim iGun iHitzone )
switch( 
iHitzone )
{
    case 
HIT_HEAD:
    {
        
    }
    case 
HIT_LEFTARMHIT_STOMACHHIT_CHESTHIT_RIGHTARM
    {
        
    }
    case 
HIT_LEFTLEGHIT_RIGHTLEG
    {
        
    }

__________________
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-21-2008 , 14:09   Re: Detect Weapons in Hamsandwich Ham_TakeDamage
Reply With Quote #7

Why do you use get_user_attacker native when you have attacker passed in the forward ?

First check if attacker is a player ( 1 <= attacker <= maxplayer )
Then check if inflictor is equal to attacker.
If it's equal, check get_user_weapon( attacker )
Else, inflictor is a nade or an another entity (may be created by another plugin )
In that case you can use fm_cs_get_grenadeid by VEN.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-21-2008 , 14:20   Re: Detect Weapons in Hamsandwich Ham_TakeDamage
Reply With Quote #8

Quote:
Originally Posted by ConnorMcLeod View Post
Why do you use get_user_attacker native when you have attacker passed in the forward ?
Just to get hitzones
__________________
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-21-2008 , 14:39   Re: Detect Weapons in Hamsandwich Ham_TakeDamage
Reply With Quote #9

Ah that's true, but note that it's not safe to use get_user_weapon with inflictor.
You could save hitzone in TraceAttack that is called just before TakeDamage.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-21-2008 , 14:50   Re: Detect Weapons in Hamsandwich Ham_TakeDamage
Reply With Quote #10

Quote:
Originally Posted by ConnorMcLeod View Post
Ah that's true, but note that it's not safe to use get_user_weapon with inflictor.
Safer to pass attacker to it?
__________________
Bugsy 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 09:07.


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