Raised This Month: $ Target: $400
 0% 

Damage problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
zXCaptainXz
Member
Join Date: May 2017
Old 07-10-2022 , 17:46   Re: Damage problem
Reply With Quote #5

Say "damage" is the name of the 4th argument in your Ham_TakeDamage function, when you call SetHamParamFloat(4, somerandomvalue), the "damage" argument remains the same, it's only changed for the next calls of the function. So what you are doing is this.

Original "damage" is 25.
You deal damage with farpiece, so you SetHamParamFloat(4, 500), expecting the damage to become 500.
You are higher than level 1, so you are using SetHamParamFloat(4, damage*leveldamage) to further boost your intended damage, however "damage" is still at 25, not 500, so farpiece damage is ignored.

A fix for this is to assign the "damage" variable to the same value you intend it to be after using SetHamParamFloat, so instead of typing
PHP Code:
       SetHamParamFloat(4get_pcvar_float(farpiece_damagehs)) 
You type
PHP Code:
        SetHamParamFloat(4get_pcvar_float(farpiece_damagehs))
    
damage get_pcvar_float(farpiece_damagehs
However you are calling get_pcvar_float twice for no reason now, so you can do something like what I wrote below.
PHP Code:
if(farpiece[attacker])
{
    if(
get_user_weapon(attacker) == CSW_AK47 && damagetype DMG_BULLET)
    {
        if(
get_pdata_int(victim75) == HIT_HEAD)
        {
            
damage get_pcvar_float(farpiece_damagehs)
        }
        else
        {
            
damage get_pcvar_float(farpiece_damage)
        }    
    }
    if(
level[id] >= 1)
    {
        
SetHamParamFloat(4damage*leveldamage)
    }
    else
    {
        
SetHamParamFloat(4damage)
    }
}
else if(
level[id] >= 1)
{
    
SetHamParamFloat(4damage*leveldamage)

zXCaptainXz is offline
 



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


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