Raised This Month: $ Target: $400
 0% 

[Solved] Show Final Damage done


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 10-18-2015 , 07:04   [Solved] Show Final Damage done
Reply With Quote #1

PHP Code:
 if(zp_get_user_zombie(id) != zp_get_user_zombie(i)) {
                        
get_user_name(i,name,31)
                        static 
Float:fVelocity[3]
                        
pev(ipev_velocityfVelocity)
                        
xs_vec_mul_scalar(fVelocity2.75fVelocity)
                        
fVelocity[2] *= 1.75
                        set_pev
(ipev_velocityfVelocity)
      
            
client_cmd(i,"spk fvox/flatline.wav")
            
msg_screen_fade(i325500235)
            
ColorChat(idGrey"^x04[Jetpack+Bazooka]^x01 Damage to^x03 %s^x01 ::^x04 %i damage"namefloatround(damage))
                            
                        if(
hp damage)
                        {                       
                
ExecuteHamB(Ham_TakeDamageientityiddamageDMG_BLAST)
                    
msg_screen_shake(i255<<1010<<10255<<10)
                        }
                        else
                        {
                            
ExecuteHamB(Ham_Killediid2// set last param to 2 if you want victim to gib
                        
}
                    }
            } 
As you see im using ExecuteHamB to deal damage on victims:
ExecuteHamB will go through some hooks and because of this the damage shown in print_chat (floatround(damage)) is not showing the exact damage done.

What should I do to correct the damage shown in chat?

Last edited by Chihuahuax; 10-19-2015 at 10:04.
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-18-2015 , 08:21   Re: [Help] Damage done
Reply With Quote #2

Code:
 ExecuteHamB
->
Code:
 ExecuteHam
ExecuteHamB -> will go through hooks
ExecuteHam -> Will not go through hooks
Depresie is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 10-18-2015 , 08:48   Re: [Help] Damage done
Reply With Quote #3

Quote:
Originally Posted by Depresie View Post
Code:
 ExecuteHamB
->
Code:
 ExecuteHam
ExecuteHamB -> will go through hooks
ExecuteHam -> Will not go through hooks
Yeah im aware of that
For now I just wanna 'correct' to printed damage
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-18-2015 , 09:07   Re: [Help] Damage done
Reply With Quote #4

damage in Ham_TakeDamage is total inflicted damage. If the player has armor then they will not receive this full damage amount.

If you are trying to get the victims loss in hp, you need to hook Ham_TakeDamage post and get pev( victim , pev_dmg_take )
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

public plugin_init() 
{
    
RegisterHamHam_TakeDamage "player" "fw_TakeDamage_Post" );
}

public 
fw_TakeDamage_PostiVictim iInflictor iAttacker Float:fDamage DmgBits )
{
    new 
iVictimDamage peviVictim pev_dmg_take );
    
    
client_printprint_chat "%d received %d loss in hp" iVictim iVictimDamage );

This can be done in conjunction with modifying the amount of damage:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

public plugin_init() 
{
    
RegisterHamHam_TakeDamage "player" "fw_TakeDamage" );
    
RegisterHamHam_TakeDamage "player" "fw_TakeDamage_Post" );
}

public 
fw_TakeDamageiVictim iInflictor iAttacker Float:fDamage DmgBits )
{
    
//Triple damage
    
fDamage *= 3.0;

    
SetHamParamFloatfDamage );
    
    return 
HAM_HANDLED;
}

public 
fw_TakeDamage_PostiVictim iInflictor iAttacker Float:fDamage DmgBits )
{
    new 
iVictimDamage peviVictim pev_dmg_take );
    
    
client_printprint_chat "%d received %d loss in hp" iVictim iVictimDamage );

__________________

Last edited by Bugsy; 10-18-2015 at 09:12.
Bugsy is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 10-18-2015 , 09:52   Re: [Help] Damage done
Reply With Quote #5

Should i hook is_user_connected(iAttacker)?
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-18-2015 , 10:54   Re: [Help] Damage done
Reply With Quote #6

Quote:
Originally Posted by Chihuahuax View Post
Should i hook is_user_connected(iAttacker)?
If you are taking any action on the attacker then yes. By actions, I mean call any functions on them (get_user_name(), get_user_authid(), etc). You do not need to do this for the victim.
__________________

Last edited by Bugsy; 10-18-2015 at 10:54.
Bugsy is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 10-19-2015 , 01:39   Re: [Help] Damage done
Reply With Quote #7

PHP Code:
public fwd_TakeDamage_Post(victiminflictorattackerFloat:damagedamage_type)
{
    new 
dmg_take
    
if ((dmg_take pev(victimpev_dmg_take)) <= 0) return HAM_IGNORED

    
if (!is_user_connected(attacker) || victim == attacker) return HAM_IGNORED

    
if (damage_type DMG_BLAST)
    {
        
ColorChat(0Grey"^x04[Jetpack+Bazooka]^x01 Damage to^x03 %s^x01 ::^x04 %i damage"victimdmg_take)
    }
    return 
HAM_IGNORED

No error at all
but damage done isn't shown idk why
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-19-2015 , 08:45   Re: [Help] Show Final Damage done
Reply With Quote #8

My guess is the DMG_BLAST bit is not set. If you are trying to get grenade damage then use:
PHP Code:
#define DMG_GRENADE (1 << 24) 
__________________
Bugsy is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 10-19-2015 , 10:03   Re: [Help] Show Final Damage done
Reply With Quote #9

Sorry it was my fault
I was testing it on bots and thats why the damage wasnt printed

Problem Xolved

Last edited by Chihuahuax; 10-19-2015 at 10:03.
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
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 22:11.


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