Raised This Month: $ Target: $400
 0% 

Remaining Health on Damage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ichiban
Member
Join Date: Dec 2008
Old 11-30-2010 , 01:34   Re: Remaining Health on Damage
Reply With Quote #1

Quote:
Originally Posted by Exolent[jNr] View Post
Yes, it does. Show your code.
Here it is
PHP Code:
#include < amxmodx >

#include < fakemeta >
#include < hamsandwich >

const MAX_PLAYERS 32;

new 
iDamage[33]

new 
Float:g_flTakeDamage_HealthMAX_PLAYERS ];

public 
plugin_init( )
{
    
RegisterHamHam_TakeDamage"player""FwdPlayerDamage" );
    
RegisterHamHam_TakeDamage"player""FwdPlayerDamagePost");
    
    
register_clcmd("say /damage","showDamage");
}

public 
FwdPlayerDamageiVictimiInflictoriAttackerFloat:flDamageiDamageType )
{
    
// save player's health before the damage is done
    
peviVictimpev_healthg_flTakeDamage_HealthiVictim ] );
}

public 
FwdPlayerDamagePostiVictimiInflictoriAttackerFloat:flDamageiDamageType )
{
    
// gets real damage that was affected by armor
    // flDamage in the forward params does not have the armor-affected value
    // you can only get this in POST hook (not PRE)
    
new Float:flRealDamage;
    
peviVictimpev_dmg_takeflRealDamage );
    
    
// the amount of health taken from the player
    
new Float:flHealthTaken floatminflRealDamageg_flTakeDamage_HealthiVictim ] );
    
    
//Add to total damage
    
new num floatround(flHealthTaken)
    
iDamage[iInflictor] += num;
}

public 
showDamage(id)
{
    
client_print(idprint_chat"Total Damage: %i"iDamage[id]);

ichiban is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-30-2010 , 01:51   Re: Remaining Health on Damage
Reply With Quote #2

You could directly work in Post TakeDamage and only check pev(victim, pev_dmg_take) and take it as an integer.

This should be ok :

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.1"
#define PLUGIN ""

#define FIRST_PLAYER_ID    1
#define MAX_PLAYERS        32
new g_iMaxPlayers
#define IsPlayer(%1)    ( FIRST_PLAYER_ID <= %1 <= g_iMaxPlayers )

new g_iDamage[MAX_PLAYERS+1]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
RegisterHam(Ham_Spawn"player""Ham_CBasePlayer_Spawn_Post"1)
    
RegisterHam(Ham_TakeDamage"player""CBasePlayer_TakeDamage_Post"1)
    
g_iMaxPlayers get_maxplayers()
}

public 
Ham_CBasePlayer_Spawn_Postid )
{
    
g_iDamage[id] = 0
}

public 
CBasePlayer_TakeDamage_Post(idiInflictoriAttackerFloat:flDamagebitsDamageType)
{
    if( 
id != iAttacker && IsPlayer(iAttacker) && cs_get_user_team(id) != cs_get_user_team(iAttacker) )
    {
        
g_iDamage[iAttacker] += pev(idpev_dmg_take)

        if( !
is_user_alive(id) )
        {
            
g_iDamage[iAttacker] += get_user_health(id)
        }
    }    


Anyway, i think csx module already provides some natives that could give you exactly what you want.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 11:17.


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