Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < engine >
#include < hamsandwich >
const Float:MONEY_PER_HP = 2.0; // $2 / 1HP
new g_iMaxPlayers;
public plugin_init( ) {
register_plugin( "Damage for Money", "0.0.1", "Exolent" );
RegisterHam( Ham_TakeDamage, "player", "FwdPlayerDamage", 1 );
g_iMaxPlayers = get_maxplayers( );
}
public FwdPlayerDamage( iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits ) {
if( !( 1 <= iAttacker <= g_iMaxPlayers ) ) {
return;
}
new Float:fRealDamage = entity_get_float( iVictim, EV_FL_dmg_take );
if( cs_get_user_team( iVictim ) == cs_get_user_team( iAttacker ) ) {
fRealDamage *= -1.0;
}
cs_set_user_money( iAttacker, cs_get_user_money( iAttacker ) + floatround( MONEY_PER_HP * fRealDamage ) );
}
__________________