Thread: [Solved] [HELP] attack 250 hp = 1 ap
View Single Post
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 03-27-2018 , 17:05   Re: [HELP] attack 250 hp = 1 ap
Reply With Quote #8

Quote:
Originally Posted by marcelowzd View Post
Code:
#include < amxmodx >
#include < hamsandwich >
#include < basebuilder >
#include < fun >

new Float:fClientDamage[ 33 ];

public plugin_init( )
{
    RegisterHam( Ham_TakeDamage, "player", "OnTakeDamage", 1 );
}

public client_putinserver( iClient )
{
    fClientDamage[ iClient ] = 0.0;
}

public OnTakeDamage( iVictim, iInflictor, iAttacker, Float:fDamage, biDamage )
{
    if( !IsPlayer( iAttacker ) || !IsPlayer( iVictim ) ) // Both must be players
        return HAM_IGNORED;

    if( !is_user_alive( iAttacker ) ) // Only alive
        return HAM_IGNORED;

    if( bb_is_user_zombie( iAttacker ) ) // Skip zombies
        return HAM_IGNORED;

    fClientDamage[ iAttacker ] += fDamage; // Add damage (AFTER ALREADY CALCULATED BY ENGINE)

    if( fClientDamage[ iAttacker ] >= 250.0 ) // If damage is higher than the value you want
    {
        fClientDamage[ iAttacker ] = 0.0;

        set_user_armor( iAttacker, get_user_armor( iAttacker ) + 1 );
    }

    return HAM_IGNORED;
}

stock IsPlayer( iEnt )
{
    if( iEnt >= 1 && iEnt <= 32 )
        return true;

    return false;
}
I think you have to use while() instead of if(). And he wants +1 Ammo Packs not Armor.
__________________
edon1337 is offline