AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] Show Final Damage done (https://forums.alliedmods.net/showthread.php?t=273385)

Chihuahuax 10-18-2015 07:04

[Solved] Show Final Damage done
 
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?

Depresie 10-18-2015 08:21

Re: [Help] Damage done
 
Code:

ExecuteHamB
->
Code:

ExecuteHam
ExecuteHamB -> will go through hooks
ExecuteHam -> Will not go through hooks

Chihuahuax 10-18-2015 08:48

Re: [Help] Damage done
 
Quote:

Originally Posted by Depresie (Post 2354339)
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

Bugsy 10-18-2015 09:07

Re: [Help] Damage done
 
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 );



Chihuahuax 10-18-2015 09:52

Re: [Help] Damage done
 
Should i hook is_user_connected(iAttacker)?

Bugsy 10-18-2015 10:54

Re: [Help] Damage done
 
Quote:

Originally Posted by Chihuahuax (Post 2354369)
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.

Chihuahuax 10-19-2015 01:39

Re: [Help] Damage done
 
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

Bugsy 10-19-2015 08:45

Re: [Help] Show Final Damage done
 
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) 


Chihuahuax 10-19-2015 10:03

Re: [Help] Show Final Damage done
 
Sorry it was my fault
I was testing it on bots and thats why the damage wasnt printed

Problem Xolved


All times are GMT -4. The time now is 22:11.

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