Raised This Month: $ Target: $400
 0% 

Displaying bullet damage with HamSandwich


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-12-2009 , 14:06   Re: Displaying bullet damage with HamSandwich
Reply With Quote #1

I don't know if final damage (pev_dmg_take) is proportional to initial damage, but if it is, this should work :
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

new Float:g_fCritHit[33];

public 
plugin_init()
{
    
RegisterHam(Ham_TakeDamage"player""hTakeDamagePre");
    
RegisterHam(Ham_TakeDamage"player""hTakeDamagePost"1);
}

public 
hTakeDamagePre(iVictimiInflictoriAttackerFloat:fDmg)
{
    if(
random_num(099) < 15// 15% of success
    
{
        
g_fCritHit[iAttacker] = random_float(1.52.5);
        
SetHamParamFloat(4fDmg g_fCritHit[iAttacker]);
    }
}

public 
hTakeDamagePost(iVictimiInflictoriAttackerFloat:fDmg)
{
    static 
Float:fMult
    
if( ( fMult g_fCritHit[iAttacker] ) )
    {
        
pev(iVictimpev_dmg_takefDmg);  
        
client_print(iAttackerprint_chat,
            
"You've made a critical hit: normal dmg: %d, dmg multiplier: %.1f, total dmg: %d",
            
floatround(fDmg*fMult), fMultfloatround(fDmg))
        
g_fCritHit[iAttacker] = 0.0;
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 01-13-2009 , 09:36   Re: Displaying bullet damage with HamSandwich
Reply With Quote #2

It works. Just one edit:
Code:
floatround(fDmg*fMult)
>
Code:
floatround(fDmg / fMult)
Thanks a lot. ^^
__________________
hleV is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 01-14-2009 , 13:29   Re: Displaying bullet damage with HamSandwich
Reply With Quote #3

Hey.
I tried using 'pev_dmg_take' but is not working.
PHP Code:
new FloatfDamageFloatfTotaliTotal;
pevvictimpev_dmg_takefDamage );

fTotal fDamage 0.3;
iTotal floatroundfTotal );

client_printattackerprint_chat"Damage inflicted: %i"iTotal ); 
It shows me '0'
__________________

anakin_cstrike 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 01:38.


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