AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detect Weapons in Hamsandwich Ham_TakeDamage (https://forums.alliedmods.net/showthread.php?t=82334)

Bad_Bud 12-21-2008 12:04

Detect Weapons in Hamsandwich Ham_TakeDamage
 
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?

Bugsy 12-21-2008 12:48

Re: Detect Weapons in Hamsandwich Ham_TakeDamage
 
Quote:

Originally Posted by Bad_Bud (Post 730894)
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.

Bad_Bud 12-21-2008 12:54

Re: Detect Weapons in Hamsandwich Ham_TakeDamage
 
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.

Bugsy 12-21-2008 13:01

Re: Detect Weapons in Hamsandwich Ham_TakeDamage
 
Quote:

Originally Posted by Bad_Bud (Post 730915)
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);
*/

Bad_Bud 12-21-2008 13:56

Re: Detect Weapons in Hamsandwich Ham_TakeDamage
 
Right. Should have read that one myself, considering I have the include open in notepad right now. :oops:

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. :evil:

It may just return inflictor. Thanks again.

Bugsy 12-21-2008 14:02

Re: Detect Weapons in Hamsandwich Ham_TakeDamage
 
Quote:

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

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. :evil:

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
    {
        
    }



ConnorMcLeod 12-21-2008 14:09

Re: Detect Weapons in Hamsandwich Ham_TakeDamage
 
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.

Bugsy 12-21-2008 14:20

Re: Detect Weapons in Hamsandwich Ham_TakeDamage
 
Quote:

Originally Posted by ConnorMcLeod (Post 730967)
Why do you use get_user_attacker native when you have attacker passed in the forward ?

Just to get hitzones

ConnorMcLeod 12-21-2008 14:39

Re: Detect Weapons in Hamsandwich Ham_TakeDamage
 
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.

Bugsy 12-21-2008 14:50

Re: Detect Weapons in Hamsandwich Ham_TakeDamage
 
Quote:

Originally Posted by ConnorMcLeod (Post 730979)
Ah that's true, but note that it's not safe to use get_user_weapon with inflictor.

Safer to pass attacker to it?


All times are GMT -4. The time now is 09:07.

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