Raised This Month: $ Target: $400
 0% 

Float problem with Ham_TakeDamage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-19-2011 , 07:56   Re: Float problem with Ham_TakeDamage
Reply With Quote #1

Use the functions from the fun module instead.
They are much faster.

PHP Code:
public Ham_CBasePlayer_TakeDamage_Post(idpevInflictorpevAttackerFloat:flDamagebitsDamageType)
{
    if(
IsPlayer(pevAttacker) && is_user_connected(pevAttacker) && HasUserMirror(id) && id != pevAttacker)
    {
            
// removed unnecessary forced float tag for flDamage
            // changed to get_pcvar_float()
            
new Float:damage_done flDamage get_pcvar_float(md_hp_division)
        
            
// float() for get_user_health() since it returns integer
            // removed unnecessary forced float tag for damage_done
            
new Float:HP float(get_user_health(pevAttacker)) - damage_done
            
            
// removed unnecessary forced float tag for HP
            
if(HP 5.0)
            {
                
// changed to set_user_health()
                // redundant fm_get_user_health() calculation since HP variable contains that same calculation
                
set_user_health(pevAttackerfloatround(HP))
                
fade_red(pevAttackerget_pcvar_num(md_fade_amount))
            }
    }

Since this is a POST hook, you are hooking after the damage is already done to the player.
Therefore, you will be doing damage twice to the player.
You should hook this as a PRE hook and change the damage parameter.
Then you should hook it as POST and check if remaining health of the player is more than 5.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 23:26.


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