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

Weapon on OnDamage event


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
LucasFromDK
Member
Join Date: Sep 2016
Old 11-14-2016 , 11:31   Weapon on OnDamage event
#1

PHP Code:
public ActionOnDamagevictim, &attacker, &inflictor, &Float:damage, &damagetype ) {
    
decl String:sWeapon64 ]
    
GetEdictClassnameinflictorsWeaponsizeofsWeapon ) )

    if( 
StrEqualsWeapon"weapon_molotov" ) ) {
        
damage 0.0
        
return Plugin_Changed
    
}

    if( 
StrEqualsWeapon"weapon_hegrenade" ) ) {
        
damage 0.0
        
return Plugin_Changed
    
}

    if( 
StrEqualsWeapon"weapon_incgrenade" ) ) {
        
damage 0.0
        
return Plugin_Changed
    
}

    if( 
StrEqualsWeapon"weapon_knife" ) ) {
        
damage 0.0
        
return Plugin_Changed
    
}
    
    return 
Plugin_Continue

Doesn't work...
LucasFromDK is offline
luki1412
Veteran Member
Join Date: Oct 2008
Location: OnPluginStart()
Old 11-14-2016 , 13:51   Re: Weapon on OnDamage event
#2

Are you trying to use SDK hooks to block damage from these weapons?
Try this:

PHP Code:
public void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage); 
}

public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &weaponfloat damageForce[3], float damagePosition[3], int damagecustom)
{

    switch(
weapon)
    {
        case 
CSWeapon_INCGRENADECSWeapon_MOLOTOVCSWeapon_HEGRENADECSWeapon_KNIFE:
        {
            return 
Plugin_Handled;
        }
    }


__________________
luki1412 is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 11-14-2016 , 15:59   Re: Weapon on OnDamage event
#3

PHP Code:
public ActionOnDamagevictim, &attacker, &inflictor, &Float:damage, &damagetype ) {
    new 
String:sWeapon[64];
    
GetClientWeapon(attackersWeaponsizeof(sWeapon));

    if( 
StrEqualsWeapon"weapon_molotov" ) ) {
        
damage 0.0;
        return 
Plugin_Changed;
    }

    if( 
StrEqualsWeapon"weapon_hegrenade" ) ) {
        
damage 0.0;
        return 
Plugin_Changed;
    }

    if( 
StrEqualsWeapon"weapon_incgrenade" ) ) {
        
damage 0.0;
        return 
Plugin_Changed;
    }

    if( 
StrEqualsWeapon"weapon_knife" ) ) {
        
damage 0.0;
        return 
Plugin_Changed;
    }
    
    return 
Plugin_Continue;

should work
__________________


Max-Play.pl - the best polish servers
CamerDisco is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 11-14-2016 , 16:22   Re: Weapon on OnDamage event
#4

Quote:
Originally Posted by CamerDisco View Post
PHP Code:
public ActionOnDamagevictim, &attacker, &inflictor, &Float:damage, &damagetype ) {
    new 
String:sWeapon[64];
    
GetClientWeapon(attackersWeaponsizeof(sWeapon));

    if( 
StrEqualsWeapon"weapon_molotov" ) ) {
        
damage 0.0;
        return 
Plugin_Changed;
    }

    if( 
StrEqualsWeapon"weapon_hegrenade" ) ) {
        
damage 0.0;
        return 
Plugin_Changed;
    }

    if( 
StrEqualsWeapon"weapon_incgrenade" ) ) {
        
damage 0.0;
        return 
Plugin_Changed;
    }

    if( 
StrEqualsWeapon"weapon_knife" ) ) {
        
damage 0.0;
        return 
Plugin_Changed;
    }
    
    return 
Plugin_Continue;

should work
Shouldn't work as expected, especially since GetClientWeapon gets the weapon name of the active weapon, and not the weapon that actually did the damage.
Mitchell is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 11-14-2016 , 16:52   Re: Weapon on OnDamage event
#5

I don't know what do you mean. Damage is from actually active weapon?
__________________


Max-Play.pl - the best polish servers
CamerDisco is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 11-14-2016 , 17:25   Re: Weapon on OnDamage event
#6

Quote:
Originally Posted by CamerDisco View Post
I don't know what do you mean. Damage is from actually active weapon?
No, damage can be done from all sorts of things, mostly from the inflictor though.
Using GetClientWeapon will get the clients active weapon name.
Meaning that expecting damage from a grenade will never work, because grenades explode a few seconds after they are thrown, meaning that when the damage is taken from the grenade their active weapon can be their primary or their knife.
Mitchell is offline
Koremai
Junior Member
Join Date: Sep 2016
Old 11-15-2016 , 00:10   Re: Weapon on OnDamage event
#7

PHP Code:
public Action:OnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3])

    
decl String:sWeapon[32];
    
GetEdictClassname(inflictorsWeaponsizeof(sWeapon));
    
    if(
StrEqual(sWeapon"weapon_molotov")){
        
damage == 0.0;
        return 
Plugin_Changed;
    }
    else if(
StrEqual(sWeapon"weapon_hegrenade")){
        
damage == 0.0;
        return 
Plugin_Changed;
    }
    else if(
StrEqual(sWeapon"weapon_incgrenade")){
        
damage == 0.0;
        return 
Plugin_Changed;
    }
    else if(
StrEqual(sWeapon"weapon_knife" )){
        
damage == 0.0;
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue;

If it doesn't work, make sure the inflictor for nades isn't something like projectile_incgrenade. I don't play that game so I wouldn't know.

Last edited by Koremai; 11-15-2016 at 00:12.
Koremai is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 10-13-2018 , 14:31   Re: Weapon on OnDamage event
#8

Maybe try
PHP Code:
    decl String:sdamagetype[64] ;
    
GetEdictClassnamedamagetypesdamagetypesizeofsdamagetype ) ) ;
    if(
StrEqual(sdamagetype"weapon_molotov")){
        
damage == 0.0;
        return 
Plugin_Changed;
    }
    .
    .
    . 
HarryPotter is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 10-14-2018 , 13:54   Re: Weapon on OnDamage event
#9

fbef0102, damage type it's type of damage, but not weapon or entity
PHP Code:
// this is obviously _not_ a robust check, but it will solve most conflict and is clean
#if !defined DMG_GENERIC
#define DMG_GENERIC                                0                    /**< generic damage was done */
#define DMG_CRUSH                                    (1 << 0)    /**< crushed by falling or moving object.
                                                                                                 
NOTEIt's assumed crush damage is occurring as a result of physics collision, so no extra physics force is generated by crush damage.
                                                                                                 DON'
use DMG_CRUSH when damaging entities unless it's the result of a physics collision. You probably want DMG_CLUB instead. */
#define DMG_BULLET                                (1 << 1)    /**< shot */
#define DMG_SLASH                                    (1 << 2)    /**< cut, clawed, stabbed */
#define DMG_BURN                                    (1 << 3)    /**< heat burned */
#define DMG_VEHICLE                                (1 << 4)    /**< hit by a vehicle */
#define DMG_FALL                                    (1 << 5)    /**< fell too far */
#define DMG_BLAST                                    (1 << 6)    /**< explosive blast damage */
#define DMG_CLUB                                    (1 << 7)    /**< crowbar, punch, headbutt */
#define DMG_SHOCK                                    (1 << 8)    /**< electric shock */
#define DMG_SONIC                                    (1 << 9)    /**< sound pulse shockwave */
#define DMG_ENERGYBEAM                        (1 << 10)    /**< laser or other high energy beam  */
#define DMG_PREVENT_PHYSICS_FORCE    (1 << 11)    /**< Prevent a physics force  */
#define DMG_NEVERGIB                            (1 << 12)    /**< with this bit OR'
d inno damage type will be able to gib victims upon death */
#define DMG_ALWAYSGIB                            (1 << 13)    /**< with this bit OR'd in, any damage type can be made to gib victims upon death. */
#define DMG_DROWN                                    (1 << 14)    /**< Drowning */
#define DMG_PARALYZE                            (1 << 15)    /**< slows affected creature down */
#define DMG_NERVEGAS                            (1 << 16)    /**< nerve toxins, very bad */
#define DMG_POISON                                (1 << 17)    /**< blood poisoning - heals over time like drowning damage */
#define DMG_RADIATION                            (1 << 18)    /**< radiation exposure */
#define DMG_DROWNRECOVER                    (1 << 19)    /**< drowning recovery */
#define DMG_ACID                                    (1 << 20)    /**< toxic chemicals or acid burns */
#define DMG_SLOWBURN                            (1 << 21)    /**< in an oven */
#define DMG_REMOVENORAGDOLL                (1 << 22)    /**< with this bit OR'd in, no ragdoll will be created, and the target will be quietly removed.
                                                                                                 
use this to kill an entity that you've already got a server-side ragdoll for */
#define DMG_PHYSGUN                                (1 << 23)    /**< Hit by manipulator. Usually doesn'
do any damage. */
#define DMG_PLASMA                                (1 << 24)    /**< Shot by Cremator */
#define DMG_AIRBOAT                                (1 << 25)    /**< Hit by the airboat's gun */
#define DMG_DISSOLVE                            (1 << 26)    /**< Dissolving! */
#define DMG_BLAST_SURFACE                    (1 << 27)    /**< A blast on the surface of water that cannot harm things underwater */
#define DMG_DIRECT                                (1 << 28)
#define DMG_BUCKSHOT                            (1 << 29)    /**< not quite a bullet. Little, rounder, different. */ 
from sdkhooks.ini
__________________
Grey83 is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 10-14-2018 , 14:17   Re: Weapon on OnDamage event
#10

This thread is almost two years old.
Fyren is offline
Closed Thread


Thread Tools
Display Modes

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 08:32.


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