View Single Post
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-12-2022 , 05:20   Re: Check if Attack has recieved damage from Victim
Reply With Quote #11

Here you go thats how to properly do it....


PHP Code:
#define IsPlayer(%1) (1 <= %1 <= MAX_PLAYERS)

enum DAMAGE_PARAMS
{
    
Float:DAMAGE_AMOUNT,
    
Float:DAMAGE_TIME
}

new 
g_aDamageData[MAX_PLAYERS+1][MAX_PLAYERS+1][DAMAGE_PARAMS]

public @
PlayerTakeDamage_Post__int_Victim__int_Inflictor__int_AttackerFloat:__float_Damage__int_DamageBits 
{
    if(
IsPlayer(__int_Attacker))
    {
        
g_aDamageData[__int_Victim][__int_Attacker][DAMAGE_AMOUNT] += __float_Damage;
        
g_aDamageData[__int_Victim][__int_Attacker][DAMAGE_TIME] = get_gametime();
    }

    static 
iplayers[32], pnumplayer;
    
get_players(playerspnum);

    for(
0pnumi++)
    {
        
player players];

        if ( 
g_aDamageData[player][__int_Victim][DAMAGE_TIME] > 0.0 && floatabs(g_aDamageData[__int_Victim][player][DAMAGE_TIME] - g_aDamageData[player][__int_Victim][DAMAGE_TIME]) <= 1.0 )
        {
            
PlayersExchangeAttacks(__int_Victimplayerg_aDamageData[__int_Victim][player][DAMAGE_AMOUNT], g_aDamageData[player][__int_Victim][DAMAGE_AMOUNT]);
        }
    }
}

PlayersExchangeAttacks(iPlayerOneiPlayerTwoFloat:fDealtDamage_PlayerOneFloat:fDealtDamage_PlayerTwo)
{
    
// Make sure to reset players time fire exchange to prevent calling it for them multiple times...
    
g_aDamageData[iPlayerOne][iPlayerTwo][DAMAGE_TIME] = 0.0;
    
g_aDamageData[iPlayerTwo][iPlayerOne][DAMAGE_TIME] = 0.0;
    
// Both players attacked each other in less  than 1 second...

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 08-12-2022 at 05:53.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh