Raised This Month: $32 Target: $400
 8% 

Solved Store Attacker damage in dinamic array for every victim


Post New Thread Reply   
 
Thread Tools Display Modes
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 07-17-2021 , 11:34   Re: Store Attacker damage in dinamic array for every victim
Reply With Quote #11

Quote:
Originally Posted by Shadows Adi View Post
Yes, something like that.
So it will loop through all entries from "p" loop first, then will continue the "i" loop, isn't that?
You could simply add a debug message and check it out yourself.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-17-2021 , 12:11   Re: Store Attacker damage in dinamic array for every victim
Reply With Quote #12

It loops through all players with i, and for each player it loops through all players again with p, skipping when i = p, since a player cannot hurt himself. My example only shows damage issued, but you could also display damaged received by each player. You could get fancy and have a separate HUD to show team attacks, if you wanted.

So assume the server is full and iPlayers[ i ] is id 4. When the p loop occurs, it will only check for damage for player id's 1 to 3, and 5 to 32 (skipping 4 since this is the player held in i).
__________________

Last edited by Bugsy; 07-17-2021 at 12:16.
Bugsy is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 07-17-2021 , 13:45   Re: Store Attacker damage in dinamic array for every victim
Reply With Quote #13

Quote:
Originally Posted by Bugsy View Post
It loops through all players with i, and for each player it loops through all players again with p, skipping when i = p, since a player cannot hurt himself. My example only shows damage issued, but you could also display damaged received by each player. You could get fancy and have a separate HUD to show team attacks, if you wanted.

So assume the server is full and iPlayers[ i ] is id 4. When the p loop occurs, it will only check for damage for player id's 1 to 3, and 5 to 32 (skipping 4 since this is the player held in i).
Oki, thank you, I will try the three dimensional array, I will be back with an answer.
__________________


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
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-25-2021 , 11:49   Re: Store Attacker damage in dinamic array for every victim
Reply With Quote #14

Added code to reset the damage array at round end.
__________________
Bugsy is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 07-25-2021 , 12:01   Re: Store Attacker damage in dinamic array for every victim
Reply With Quote #15

Sorry, forgot to show the code after Bugsy's method:

PHP Code:
new g_ePlayerStats[MAX_PLAYERS 1][MAX_PLAYERS 1][PlayerStats]

public 
PlayerTakeDamage_Post(iVictimpevInflictoriAttackerFloat:flDamagebitsDamageType)
{
    
g_ePlayerStats[iAttacker][iVictim][DamageGiven] += floatround(flDamage)
    
g_ePlayerStats[iVictim][iAttacker][DamageReceived] += floatround(flDamage)
}

public 
Round_End()
{
    static 
iPlayeriPlayers[MAX_PLAYERS], iNumiVictimCsTeams:iTeam
    get_players
(iPlayersiNum"ch")

    for(new 
jiNumj++)
    {
        
iVictim iPlayers[j]

        
iTeam cs_get_user_team(iVictim)

        
// Checking if Victim's team is different than Attacker's Team

        
if(iTeam == CS_TEAM_CT || iTeam == CS_TEAM_T)
        {
            if(
!= && iTeam != cs_get_user_team(iPlayer))
            {
                
client_print_color(iPlayerprint_chat"^1(^4%d) damage, (^4%d^1) taken, ^4%s"g_ePlayerStats[iPlayer][iVictim][DamageGiven], g_ePlayerStats[iPlayer][iVictim][DamageReceived], g_szName[iVictim])
            }
        }
    }
    
    
// Reseting Array

    
for(new iMAX_PLAYERS 1i++)
    {
        for(new 
jMAX_PLAYERS 1j++)
        {
            
g_ePlayerStats[i][j][DamageGiven] = 0
            g_ePlayerStats
[i][j][DamageReceived] = 0
        
}
    }

Thank you, Bugsy and everyone
__________________


Accepting Paid Requests, contact PM.

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

Last edited by Shadows Adi; 07-25-2021 at 12:02.
Shadows Adi is offline
Reply


Thread Tools
Display Modes

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 17:08.


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