Raised This Month: $ Target: $400
 0% 

Solved Store Attacker damage in dinamic array for every victim


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 07-17-2021 , 03:46   Re: Store Attacker damage in dinamic array for every victim
Reply With Quote #10

Quote:
Originally Posted by Bugsy View Post
Is this what you're trying to do?
Code:
#include <amxmodx> #include <hamsandwich> #include <fakemeta> new const Version[] = "0.1"; #define MAX_PLAYERS 32 #define MAX_NAME_LENGTH 32 enum PlayerStats {     DamageGiven,     DamageReceived } new g_szName[ MAX_PLAYERS + 1 ][ MAX_NAME_LENGTH ]; new g_pzStats[ MAX_PLAYERS + 1 ][ MAX_PLAYERS + 1 ][ PlayerStats ]; public plugin_init() {     register_plugin( "Round Damage" , Version , "bugsy" );         RegisterHam( Ham_TakeDamage , "player" , "HamTakeDamage" , true );     register_logevent( "RoundEnd" , 2 , "1=Round_End" ); } public client_putinserver( id ) {     get_user_name( id , g_szName[ id ] , charsmax( g_szName[] ) ); } public HamTakeDamage( victim , inflictor , attacker , Float:fDamage , bitDamage ) {         new iActualDamage = pev( victim , pev_dmg_take );         g_pzStats[ victim ][ attacker ][ DamageReceived ] += iActualDamage;     g_pzStats[ attacker ][ victim ][ DamageGiven ] += iActualDamage; } public RoundEnd() {     new iPlayers[ 32 ] , iNum , iAttackerPlayer , iVictimPlayer , iTotalDamage , iSingleDamage;     new szHUD[ 512 ] , iPos;         get_players( iPlayers , iNum );         for ( new i = 0 ; i < iNum ; i++ )     {         iAttackerPlayer = iPlayers[ i ];                 iPos = 0;         iTotalDamage = 0;                 for ( new p = 0 ; p < iNum ; p++ )         {             iVictimPlayer = iPlayers[ p ];                         if ( i != p )             {                 iSingleDamage = g_pzStats[ iAttackerPlayer ][ iVictimPlayer ][ DamageGiven ];                                 if ( iSingleDamage > 0 )                 {                     iTotalDamage += iSingleDamage;                     iPos += formatex( szHUD[ iPos ] , charsmax( szHUD ) - iPos , "%s - %d damage^n" , g_szName[ iVictimPlayer ] , iSingleDamage );                 }             }         }                 if ( iTotalDamage > 0 )         {             iPos += formatex( szHUD[ iPos ] , charsmax( szHUD ) - iPos , "^n^nTotal Damage - %d" , iTotalDamage );             set_hudmessage( 0 , 255 , 0 , 0.05, 0.35 , 0 , 0.0 , 5.0 );             show_hudmessage( iAttackerPlayer , szHUD );         }       } }
Yes, something like that.
So it will loop through all entries from "p" loop first, then will continue the "i" loop, isn't that?
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
 



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 02:30.


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