Raised This Month: $51 Target: $400
 12% 

Display previous round information in chat


Post New Thread Reply   
 
Thread Tools Display Modes
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 08-10-2021 , 22:50   Re: Display previous round information in chat
Reply With Quote #21

Quote:
Originally Posted by Natsheh View Post
Can you explain how this is related to the thread topic?
Just tried to help(chime in some "useful" info), because people can still shoot each other after roundend, and the damage won't be accurate if you display it as soon as CT or T wins, killing players who are saving guns or are still fighting is a thing in PUG mods (which this request is for). Using a task to get all alive players health won't really work in all scenarios, at least it didn't work the way I wanted it to.


Quote:
Originally Posted by Bugsy View Post
1. I didn't consider the scenario where someone could hurt someone before round start. I personally still consider it as damage issued in the round.
2. clamp() would only make sense if you want to enforce damage within a range (eg. 50-100). I do not need a lower boundary for damage since all damage counts, we just want to limit the max. Please provide your argument for using clamp().
3. My goal is to only call get_user_health() on alive players, and only call it once per alive player per round. I updated the code here to avoid redundant calls.
4. I added max() to limit the damage to 100 since you requested it here:


I really don't know why I chose clamp instead of min,max, I guess preference.
Your third point is actually good as well, I guess I resorted to using eventhealth just because I couldn't find a working way of properly gathering all player's health the instant before newround.
__________________

Last edited by deprale; 08-10-2021 at 22:55.
deprale is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-10-2021 , 23:11   Re: Display previous round information in chat
Reply With Quote #22

Try this:
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

new const Version[] = "0.8";

#define MAX_PLAYERS 32
#define MAX_NAME_LENGTH 32

enum PlayerStats
{
    
Shots,
    
DamageGiven,
    
HealthBeforeDamage
}

new 
g_pzStatsMAX_PLAYERS ][ MAX_PLAYERS ][ PlayerStats ];
new 
g_HealthAtRoundEndMAX_PLAYERS ];
new 
HamHook:g_hTakeDamagePre HamHook:g_hTakeDamagePost
new 
bool:g_bRoundDamageShown;
new 
g_pEnabled;

public 
plugin_init() 
{
    
register_plugin"Round Damage" Version "bugsy" );
    
    
RegisterHamHam_Spawn "player" "HamSpawn_Post" true );
    
DisableHamForwardg_hTakeDamagePre RegisterHamHam_TakeDamage "player" "HamTakeDamage_Pre" false ) );
    
DisableHamForwardg_hTakeDamagePost RegisterHamHam_TakeDamage "player" "HamTakeDamage_Post" true ) );
    
register_logevent"RoundStart" "1=Round_Start" ); 
    
register_logevent"RoundEnd" "1=Round_End" );
    
register_event"HLTV" "NewRound" "a" "1=0" "2=0" );
    
    
g_pEnabled register_cvar"rd_enabled" "1" );
}

public 
RoundStart()
{
    
ClearArray();
    
EnableHamForwardg_hTakeDamagePre );
    
EnableHamForwardg_hTakeDamagePost );
}

public 
RoundEnd()
{
    new 
iPlayers32 ] , iNum;
    
    
get_playersiPlayers iNum "ah" );
    
    for ( new 
iNum i++ )
    {
        
g_HealthAtRoundEndiPlayers] ] = get_user_healthiPlayers] );
    }
}

public 
NewRound()
{
    
g_bRoundDamageShown false;
    
DisableHamForwardg_hTakeDamagePre );
    
DisableHamForwardg_hTakeDamagePost );
}

public 
HamTakeDamage_Previctim inflictor attacker Float:fDamage bitDamage 
{
    if ( 
get_pcvar_numg_pEnabled ) )
    {
        
g_pzStatsattacker ][ victim ][ HealthBeforeDamage ] = get_user_healthvictim );
    }
}

public 
HamTakeDamage_Postvictim inflictor attacker Float:fDamage bitDamage 
{
    if ( 
get_pcvar_numg_pEnabled ) )
    {
        
g_pzStatsattacker ][ victim ][ Shots ]++;
        
g_pzStatsattacker ][ victim ][ DamageGiven ] += clampg_pzStatsattacker ][ victim ][ HealthBeforeDamage ] - get_user_healthvictim ) , g_pzStatsattacker ][ victim ][ HealthBeforeDamage ] );    
    }
}

public 
HamSpawn_Postid )
{
    if ( 
g_bRoundDamageShown == true )
        return;

    if ( 
is_user_aliveid ) )
    {
        new 
iPlayers32 ] , iNum iPlayer iOtherPlayer iDamageGiven iDamageTaken szNameMAX_PLAYERS ][ 32 ];
        
        
get_playersiPlayers iNum );
    
        for ( new 
iNum i++ )
        {
            
iPlayer iPlayers];
            
            for ( new 
iNum p++ )
            {
                
iOtherPlayer iPlayers];
                
                if ( ( 
!= ) && ( g_pzStatsiPlayer ][ iOtherPlayer ][ DamageGiven ] || g_pzStatsiOtherPlayer ][ iPlayer ][ DamageGiven ] ) )
                {
                    
iDamageGiven g_pzStatsiPlayer ][ iOtherPlayer ][ DamageGiven ];
                    
iDamageTaken g_pzStatsiOtherPlayer ][ iPlayer ][ DamageGiven ];
                
                    if ( 
iDamageGiven || iDamageTaken )
                    {
                        if ( 
szNameiOtherPlayer ][ ] == EOS )
                            
get_user_nameiOtherPlayer szNameiOtherPlayer ] , charsmaxszName[] ) );
                            
                        
client_printiPlayer print_chat "(%d with %d) damage, (%d with %d) taken, %s (%dHP)" iDamageGiven g_pzStatsiPlayer ][ iOtherPlayer ][ Shots ] , iDamageTaken g_pzStatsiOtherPlayer ][ iPlayer ][ Shots ] , szNameiOtherPlayer ] , g_HealthAtRoundEndiOtherPlayer ] );
                    }
                }
            }
        }
        
        
g_bRoundDamageShown true;
    }
}

ClearArray()
{
    
arraysetg_HealthAtRoundEnd sizeofg_HealthAtRoundEnd ) );
    for ( new 
<= MAX_PLAYERS i++ )
    {
        for ( new 
<= MAX_PLAYERS p++ )
        {
            
g_pzStats][ ][ Shots ] = 0;
            
g_pzStats][ ][ DamageGiven ] = 0;
            
g_pzStats][ ][ HealthBeforeDamage ] = 0;
        }
    }

__________________

Last edited by Bugsy; 08-16-2021 at 19:35.
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-10-2021 , 23:18   Re: Display previous round information in chat
Reply With Quote #23

@deprale - I think your comment regarding damage happening during freeze time is valid. I'm not sure why Natsheh thought otherwise. If the OP wants to exclude damage during this time window, I can make an edit.

I too used to always use clamp, not realizing there was a min/max native for a 'one-sided' clamp.
__________________
Bugsy is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 08-10-2021 , 23:34   Re: Display previous round information in chat
Reply With Quote #24

Quote:
Originally Posted by Bugsy View Post
Try this:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

new const Version[] = "0.3";

#define MAX_PLAYERS 32
#define MAX_NAME_LENGTH 32

enum PlayerStats
{
    
Shots,
    
DamageGiven
}

new 
g_pzStatsMAX_PLAYERS ][ MAX_PLAYERS ][ PlayerStats ];
new 
g_pEnabled;

public 
plugin_init() 
{
    
register_plugin"Round Damage" Version "bugsy" );
    
    
RegisterHamHam_TakeDamage "player" "HamTakeDamage" true );
    
register_logevent"RoundEnd" "1=Round_End" ); 
    
    
g_pEnabled register_cvar"rd_enabled" "1" );
}

public 
HamTakeDamagevictim inflictor attacker Float:fDamage bitDamage 
{     
    if ( 
get_pcvar_numg_pEnabled ) )
    {
        new 
iActualDamage pevvictim pev_dmg_take ); 

        
g_pzStatsattacker ][ victim ][ Shots ]++;
        
g_pzStatsattacker ][ victim ][ DamageGiven ] += iActualDamage;
    }
}

public 
RoundEnd()
{
    
set_task0.1 "DelayRoundEnd" );
}

public 
DelayRoundEnd()
{
    new 
iPlayers32 ] , iNum iPlayer iOtherPlayer iDamageGiven iDamageTaken iHealthMAX_PLAYERS ] , szNameMAX_PLAYERS ][ 32 ];

    
get_playersiPlayers iNum );

    for ( new 
iNum i++ )
    {
        
iPlayer iPlayers];
        
        for ( new 
iNum p++ )
        {
            
iOtherPlayer iPlayers];
            
            if ( ( 
!= ) && g_pzStatsiPlayer ][ iOtherPlayer ][ DamageGiven ] || g_pzStatsiOtherPlayer ][ iPlayer ][ DamageGiven ] )
            {
                
iDamageGiven ming_pzStatsiPlayer ][ iOtherPlayer ][ DamageGiven ] , 100 );
                
iDamageTaken ming_pzStatsiOtherPlayer ][ iPlayer ][ DamageGiven ] , 100 );
            
                if ( 
iDamageGiven || iDamageTaken )
                {
                    if ( !
iHealthiOtherPlayer ] )
                        
iHealthiOtherPlayer ] = is_user_aliveiOtherPlayer ) ? get_user_healthiOtherPlayer ) : 0;
                        
                    if ( 
szNameiOtherPlayer ][ ] == EOS )
                        
get_user_nameiOtherPlayer szNameiOtherPlayer ] , charsmaxszName[] ) );
                        
                    
client_printiPlayer print_chat "(%d with %d) damage, (%d with %d) taken, %s (%dHP)" is_user_aliveiOtherPlayer ) ? iDamageGiven 100 g_pzStatsiPlayer ][ iOtherPlayer ][ Shots ] , iDamageTaken g_pzStatsiOtherPlayer ][ iPlayer ][ Shots ] , szNameiOtherPlayer ] , iHealthiOtherPlayer ] );
                    
                }
            }
        }
    }

    
ClearArray();
}

ClearArray()
{
    for ( new 
<= MAX_PLAYERS i++ )
    {
        for ( new 
<= MAX_PLAYERS p++ )
        {
            
g_pzStats][ ][ Shots ] = 0;
            
g_pzStats][ ][ DamageGiven ] = 0;
        }
    }



Quote:
Originally Posted by Bugsy View Post
@deprale - I think your comment regarding damage happening during freeze time is valid. I'm not sure why Natsheh thought otherwise. If the OP wants to exclude damage during this time window, I can make an edit.

I too used to always use clamp, not realizing there was a min/max native for a 'one-sided' clamp.
Regarding the delay, wouldn't it make more sense to make a cvar pointer for mp_round_restart_delay and subtract 0.1 from it then execute this so it happens RIGHT before a newround? Putting it to 0.1 is still not enough IMO, since there's like 4.9 more seconds for people to damage each other.
__________________
deprale is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-10-2021 , 23:46   Re: Display previous round information in chat
Reply With Quote #25

I did not add that for excluding freeze time damage. I found that ham take damage on the very last victim was not registering correctly without a delay.

Edit: I think I added that while debugging, I don't think it's needed.
__________________

Last edited by Bugsy; 08-10-2021 at 23:52.
Bugsy is offline
theuser
Member
Join Date: Jul 2020
Old 08-11-2021 , 07:03   Re: Display previous round information in chat
Reply With Quote #26

Quote:
Originally Posted by Bugsy View Post
Try this:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

new const Version[] = "0.3";

#define MAX_PLAYERS 32
#define MAX_NAME_LENGTH 32

enum PlayerStats
{
    
Shots,
    
DamageGiven
}

new 
g_pzStatsMAX_PLAYERS ][ MAX_PLAYERS ][ PlayerStats ];
new 
g_pEnabled;

public 
plugin_init() 
{
    
register_plugin"Round Damage" Version "bugsy" );
    
    
RegisterHamHam_TakeDamage "player" "HamTakeDamage" true );
    
register_logevent"RoundEnd" "1=Round_End" ); 
    
    
g_pEnabled register_cvar"rd_enabled" "1" );
}

public 
HamTakeDamagevictim inflictor attacker Float:fDamage bitDamage 
{     
    if ( 
get_pcvar_numg_pEnabled ) )
    {
        new 
iActualDamage pevvictim pev_dmg_take ); 

        
g_pzStatsattacker ][ victim ][ Shots ]++;
        
g_pzStatsattacker ][ victim ][ DamageGiven ] += iActualDamage;
    }
}

public 
RoundEnd()
{
    new 
iPlayers32 ] , iNum iPlayer iOtherPlayer iDamageGiven iDamageTaken iHealthMAX_PLAYERS ] , szNameMAX_PLAYERS ][ 32 ];

    
get_playersiPlayers iNum );

    for ( new 
iNum i++ )
    {
        
iPlayer iPlayers];
        
        for ( new 
iNum p++ )
        {
            
iOtherPlayer iPlayers];
            
            if ( ( 
!= ) && g_pzStatsiPlayer ][ iOtherPlayer ][ DamageGiven ] || g_pzStatsiOtherPlayer ][ iPlayer ][ DamageGiven ] )
            {
                
iDamageGiven ming_pzStatsiPlayer ][ iOtherPlayer ][ DamageGiven ] , 100 );
                
iDamageTaken ming_pzStatsiOtherPlayer ][ iPlayer ][ DamageGiven ] , 100 );
            
                if ( 
iDamageGiven || iDamageTaken )
                {
                    if ( !
iHealthiOtherPlayer ] )
                        
iHealthiOtherPlayer ] = is_user_aliveiOtherPlayer ) ? get_user_healthiOtherPlayer ) : 0;
                        
                    if ( 
szNameiOtherPlayer ][ ] == EOS )
                        
get_user_nameiOtherPlayer szNameiOtherPlayer ] , charsmaxszName[] ) );
                        
                    
client_printiPlayer print_chat "(%d with %d) damage, (%d with %d) taken, %s (%dHP)" is_user_aliveiOtherPlayer ) ? iDamageGiven 100 g_pzStatsiPlayer ][ iOtherPlayer ][ Shots ] , iDamageTaken g_pzStatsiOtherPlayer ][ iPlayer ][ Shots ] , szNameiOtherPlayer ] , iHealthiOtherPlayer ] );
                    
                }
            }
        }
    }

    
ClearArray();
}

ClearArray()
{
    for ( new 
<= MAX_PLAYERS i++ )
    {
        for ( new 
<= MAX_PLAYERS p++ )
        {
            
g_pzStats][ ][ Shots ] = 0;
            
g_pzStats][ ][ DamageGiven ] = 0;
        }
    }

In this case, a maximum of 100 is printed.
But you forgot:
A player's damage is 70 and I shoot him with an awp arrow, 100 damages are printed in chat, while 70 damages should be printed.
theuser is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-11-2021 , 08:18   Re: Display previous round information in chat
Reply With Quote #27

Ah ok, yes I have a condition where if they are dead, print 100..I'll fix
__________________
Bugsy is offline
theuser
Member
Join Date: Jul 2020
Old 08-11-2021 , 08:59   Re: Display previous round information in chat
Reply With Quote #28

Quote:
Originally Posted by Bugsy View Post
Ah ok, yes I have a condition where if they are dead, print 100..I'll fix
so tnx +karma
theuser is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-11-2021 , 22:32   Re: Display previous round information in chat
Reply With Quote #29

Try this

https://forums.alliedmods.net/showpo...8&postcount=22
__________________
Bugsy is offline
theuser
Member
Join Date: Jul 2020
Old 08-12-2021 , 13:18   Re: Display previous round information in chat
Reply With Quote #30

Quote:
Originally Posted by Bugsy View Post
The problem is still visible

"A player's damage is 70 and I shoot him with an awp arrow, 100 damages are printed in chat, while 70 damages should be printed."
theuser is offline
Reply



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


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