AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Double Damage (https://forums.alliedmods.net/showthread.php?t=320824)

Napoleon_be 01-11-2020 08:16

Double Damage
 
I'm trying to set double damage when a certain boolean is true
PHP Code:

new bool:bHasWeapon[33]; 

Is this the way to do it or is there a better way? I've found this from a post of 2011 which is why i'm asking since it might be outdated.

PHP Code:

public PreDoubleDamage(idInflictorAttackerFloat:DamageDamagebits)
{
    if(!(
<= Attacker <= get_maxplayers()) || Attacker != Inflictor || !bHasWeapon[Attacker])
    {
        return 
HAM_IGNORED;
    }
    
    
SetHamParamFloat(4Damage 2); 
    return 
HAM_HANDLED;


Original thread: https://forums.alliedmods.net/showthread.php?t=174279

OciXCrom 01-11-2020 08:34

Re: Double Damage
 
Code:
1 <= Attacker <= get_maxplayers()

is_user_connected(iAttacker)

Code:
Attacker != Inflictor

This check will prevent double damage for HE grenades.

The rest is fine.

Napoleon_be 01-11-2020 08:39

Re: Double Damage
 
So something like this?

PHP Code:

public PreDoubleDamage(idInflictorAttackerFloat:DamageDamagebits)
{
    if(!
is_user_connected(Attacker) || Attacker != Inflictor || !bHasWeapon[Attacker])
    {
        return 
HAM_IGNORED;
    }
    
    
SetHamParamFloat(4Damage 2); 
    return 
HAM_HANDLED;



OciXCrom 01-11-2020 08:53

Re: Double Damage
 
I meant to replace the entire check with "is_user_connected", not add it again.

Napoleon_be 01-11-2020 09:42

Re: Double Damage
 
Adjusted my code, should be okay now?

Also double damage is not needed for HE Grenades. Double damage should only be applied to AK47, M4A1, AWP and Deagle. Gotta add CurWeapon for that, but i'm not that far yet.

OciXCrom 01-11-2020 09:52

Re: Double Damage
 
You don't need CurWeapon. You can use "get_user_weapon" directly.

Napoleon_be 01-11-2020 10:07

Re: Double Damage
 
Quote:

Originally Posted by OciXCrom (Post 2679751)
You don't need CurWeapon. You can use "get_user_weapon" directly.

Awesome thanks for the info, this is what it's become. Will something like this work? Can't really test it on my own. and i don't have a proper bot plugin

PHP Code:

new const iWeapons[] =
{
    
CSW_AK47,
    
CSW_M4A1,
    
CSW_AWP
}; 

PHP Code:

public PreDoubleDamage(idiInflictoriAttackerFloat:iDamageiDamagebits)
{
    if(!
is_user_connected(iAttacker) || iAttacker != iInflictor || !bHasWeapon[iAttacker])
    {
        return 
HAM_IGNORED;
    }
    
    new 
iWeapon get_user_weapon(iAttacker)
    
    for(new 
isizeof(iWeapons); i++)
    {
        if(
iWeapon == iWeapons[i])
        {
            
SetHamParamFloat(4iDamage 2); 
        }
    }
    return 
HAM_HANDLED;



Bugsy 01-11-2020 12:25

Re: Double Damage
 
Try this

PHP Code:

new g_WeaponList = ( << CSW_AK47 ) | ( << CSW_M4A1 ) | ( << CSW_AWP );

public 
PreDoubleDamageid iInflictor iAttacker Float:fDamage Damagebits )
{
    if ( ( 
iAttacker == iInflictor ) && bHasWeaponiAttacker ] && is_user_connectediAttacker ) && ( g_WeaponList & ( << get_user_weaponiAttacker ) ) ) )
    {
        
SetHamParamFloatfDamage 2.0 ); 
        return 
HAM_HANDLED;
    }
    
    return 
HAM_IGNORED;



Napoleon_be 01-12-2020 07:54

Re: Double Damage
 
Thanks for the feedback Bugsy, but i'm afraid if i use that code, that this code will become unnessecary.
PHP Code:

new const iWeapons[] =
{
    
CSW_AK47,
    
CSW_M4A1,
    
CSW_AWP
}; 


OciXCrom 01-12-2020 08:33

Re: Double Damage
 
Bugsy gave you everything you need, so you don't need the iWeapons array. It's better to check the weapon using a bitstum rather than looping an entire array.


All times are GMT -4. The time now is 02:56.

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