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

Display previous round information in chat


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-08-2021 , 22:32   Re: Display previous round information in chat
Reply With Quote #11

Try this.

1. Minor update applied for get_user_health() efficiency

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

new const Version[] = "0.2";

#define MAX_PLAYERS 32
#define MAX_NAME_LENGTH 32

enum PlayerStats
{
    
Shots,
    
DamageGiven,
    
DamageReceived
}

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_pzStatsvictim ][ attacker ][ DamageReceived ] += iActualDamage;
        
g_pzStatsattacker ][ victim ][ DamageGiven ] += iActualDamage;
    }
}

public 
RoundEnd()
{
    new 
iPlayers32 ] , iNum iAttackerPlayer iVictimPlayer iDamageGiven iDamageTaken iHealthMAX_PLAYERS ] , szNameMAX_PLAYERS ][ 32 ];
    
    
get_playersiPlayers iNum );
    
    for ( new 
iNum i++ )
    {
        
iAttackerPlayer iPlayers];
        
        for ( new 
iNum p++ )
        {
            
iVictimPlayer iPlayers];
            
            if ( ( 
!= ) && g_pzStatsiAttackerPlayer ][ iVictimPlayer ][ DamageGiven ] || g_pzStatsiAttackerPlayer ][ iVictimPlayer ][ DamageReceived ] )
            {
                
iDamageGiven ming_pzStatsiAttackerPlayer ][ iVictimPlayer ][ DamageGiven ] , 100 );
                
iDamageTaken ming_pzStatsiAttackerPlayer ][ iVictimPlayer ][ DamageReceived ] , 100 );
            
                if ( 
iDamageGiven || iDamageTaken )
                {
                    if ( !
iHealthiVictimPlayer ] )
                        
iHealthiVictimPlayer ] = is_user_aliveiVictimPlayer ) ? get_user_healthiVictimPlayer ) : -1;
                        
                    if ( 
szNameiVictimPlayer ][ ] == EOS )
                        
get_user_nameiVictimPlayer szNameiVictimPlayer ] , charsmaxszName[] ) );
                        
                    
client_printiAttackerPlayer print_chat "(%d with %d) damage, (%d with %d) taken, %s (%dHP)" iDamageGiven g_pzStatsiAttackerPlayer ][ iVictimPlayer ][ Shots ] , iDamageTaken g_pzStatsiVictimPlayer ][ iAttackerPlayer ][ Shots ] , szNameiVictimPlayer ] , iHealthiVictimPlayer ] == -iHealthiVictimPlayer ] );
                }
            }
        }
    }

    
ClearArray();
}

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

__________________

Last edited by Bugsy; 08-10-2021 at 21:30.
Bugsy is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 08-08-2021 , 23:53   Re: Display previous round information in chat
Reply With Quote #12

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

new const Version[] = "0.2";

#define MAX_PLAYERS 32
#define MAX_NAME_LENGTH 32

enum PlayerStats
{
    
Shots,
    
DamageGiven,
    
DamageReceived
}

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_pzStatsvictim ][ attacker ][ DamageReceived ] += iActualDamage;
        
g_pzStatsattacker ][ victim ][ DamageGiven ] += iActualDamage;
    }
}

public 
RoundEnd()
{
    new 
iPlayers32 ] , iNum iAttackerPlayer iVictimPlayer iDamageGiven iDamageTaken iHealthMAX_PLAYERS ] , szNameMAX_PLAYERS ][ 32 ];
    
    
get_playersiPlayers iNum );
    
    for ( new 
iNum i++ )
    {
        
iAttackerPlayer iPlayers];
        
        for ( new 
iNum p++ )
        {
            
iVictimPlayer iPlayers];
            
            if ( ( 
!= ) && g_pzStatsiAttackerPlayer ][ iVictimPlayer ][ DamageGiven ] || g_pzStatsiAttackerPlayer ][ iVictimPlayer ][ DamageReceived ] )
            {
                
iDamageGiven ming_pzStatsiAttackerPlayer ][ iVictimPlayer ][ DamageGiven ] , 100 );
                
iDamageTaken ming_pzStatsiAttackerPlayer ][ iVictimPlayer ][ DamageReceived ] , 100 );
            
                if ( 
iDamageGiven || iDamageTaken )
                {
                    if ( !
iHealthiVictimPlayer ] )
                        
iHealthiVictimPlayer ] = is_user_aliveiVictimPlayer ) ? get_user_healthiVictimPlayer ) : 0;
                        
                    if ( 
szNameiVictimPlayer ][ ] == EOS )
                        
get_user_nameiVictimPlayer szNameiVictimPlayer ] , charsmaxszName[] ) );
                        
                    
client_printiAttackerPlayer print_chat "(%d with %d) damage, (%d with %d) taken, %s (%dHP)" iDamageGiven g_pzStatsiAttackerPlayer ][ iVictimPlayer ][ Shots ] , iDamageTaken g_pzStatsiVictimPlayer ][ iAttackerPlayer ][ Shots ] , szNameiVictimPlayer ] , iHealthiVictimPlayer ] );
                }
            }
        }
    }

    
ClearArray();
}

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

Rather interesting approach of getting health but problem is, players can still damage each other after round end(since it's called 5 seconds before a newround).
The way I do it is - I hook eventdeath and eventhealth, I use a bool for freezetime, set it to true on newround, and false on startround, in eventhealth I gather HP if it's not freezetime, and it works properly. This way I don't have to care if somebody changed mp_round_restart_delay (regamedll) or if they're using some mod that changes the amount of seconds it takes for new round to start.
PHP Code:
public EventHealth(client){ 
    if( !
g_FreezeTime // Have to do this because EventHealth is called after you die (or maybe I'm stupid) and it sets your health to 100.
        
g_RoundEndHp[client] = get_user_health(client);

Also may I ask why you chose min instead of clamp?
__________________

Last edited by deprale; 08-09-2021 at 02:42.
deprale is offline
theuser
Member
Join Date: Jul 2020
Old 08-09-2021 , 08:01   Re: Display previous round information in chat
Reply With Quote #13

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

new const Version[] = "0.2";

#define MAX_PLAYERS 32
#define MAX_NAME_LENGTH 32

enum PlayerStats
{
    
Shots,
    
DamageGiven,
    
DamageReceived
}

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_pzStatsvictim ][ attacker ][ DamageReceived ] += iActualDamage;
        
g_pzStatsattacker ][ victim ][ DamageGiven ] += iActualDamage;
    }
}

public 
RoundEnd()
{
    new 
iPlayers32 ] , iNum iAttackerPlayer iVictimPlayer iDamageGiven iDamageTaken iHealthMAX_PLAYERS ] , szNameMAX_PLAYERS ][ 32 ];
    
    
get_playersiPlayers iNum );
    
    for ( new 
iNum i++ )
    {
        
iAttackerPlayer iPlayers];
        
        for ( new 
iNum p++ )
        {
            
iVictimPlayer iPlayers];
            
            if ( ( 
!= ) && g_pzStatsiAttackerPlayer ][ iVictimPlayer ][ DamageGiven ] || g_pzStatsiAttackerPlayer ][ iVictimPlayer ][ DamageReceived ] )
            {
                
iDamageGiven ming_pzStatsiAttackerPlayer ][ iVictimPlayer ][ DamageGiven ] , 100 );
                
iDamageTaken ming_pzStatsiAttackerPlayer ][ iVictimPlayer ][ DamageReceived ] , 100 );
            
                if ( 
iDamageGiven || iDamageTaken )
                {
                    if ( !
iHealthiVictimPlayer ] )
                        
iHealthiVictimPlayer ] = is_user_aliveiVictimPlayer ) ? get_user_healthiVictimPlayer ) : 0;
                        
                    if ( 
szNameiVictimPlayer ][ ] == EOS )
                        
get_user_nameiVictimPlayer szNameiVictimPlayer ] , charsmaxszName[] ) );
                        
                    
client_printiAttackerPlayer print_chat "(%d with %d) damage, (%d with %d) taken, %s (%dHP)" iDamageGiven g_pzStatsiAttackerPlayer ][ iVictimPlayer ][ Shots ] , iDamageTaken g_pzStatsiVictimPlayer ][ iAttackerPlayer ][ Shots ] , szNameiVictimPlayer ] , iHealthiVictimPlayer ] );
                }
            }
        }
    }

    
ClearArray();
}

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



I haven't tested yet but I think there is a problem
In the function you specified, the minimum value is damaged and consider 100
for example :
The opponent's damage is 40
We shoot him a awp (we know that each awp shot to the body reduces 115 damage)
In this case, the plugin considers the minimum between 115 and 100, which becomes 100!
While he has to print the number 40 (because the opponent's damage was 40 and we took 40 damage from him)

Is my opinion really correct or did you anticipate this?

And what can be done for the comment that our friend said in the previous replay? (Roundend function that still has 5 seconds left when called)
theuser is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-09-2021 , 09:21   Re: Display previous round information in chat
Reply With Quote #14

Quote:
Originally Posted by deprale View Post
Rather interesting approach of getting health but problem is, players can still damage each other after round end(since it's called 5 seconds before a newround).
The way I do it is - I hook eventdeath and eventhealth, I use a bool for freezetime, set it to true on newround, and false on startround, in eventhealth I gather HP if it's not freezetime, and it works properly. This way I don't have to care if somebody changed mp_round_restart_delay (regamedll) or if they're using some mod that changes the amount of seconds it takes for new round to start.
PHP Code:
public EventHealth(client){ 
    if( !
g_FreezeTime // Have to do this because EventHealth is called after you die (or maybe I'm stupid) and it sets your health to 100.
        
g_RoundEndHp[client] = get_user_health(client);

Also may I ask why you chose min instead of clamp?


Can you explain how this is related to the thread topic?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-09-2021 , 10:07   Re: Display previous round information in chat
Reply With Quote #15

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:
Quote:
Yes, sometimes it is more than 100, which I want to be a maximum of 100.
And that sometimes it is not displayed correctly
For example, I do 100 damage and the plugin writes 80
thank you
__________________

Last edited by Bugsy; 08-09-2021 at 10:53.
Bugsy is offline
theuser
Member
Join Date: Jul 2020
Old 08-09-2021 , 13:42   Re: Display previous round information in chat
Reply With Quote #16

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:

The plugin still has a problem, for example, I give 100 damage to the opponent and the plugin writes 70 !!!
What is the reason for this problem?
theuser is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-09-2021 , 14:02   Re: Display previous round information in chat
Reply With Quote #17

If a victim has 10hp and I blast him in the head with an awp, do you want to see another 100 (or whatever) damage issued in, or only the 10 loss in hp? I think this is the issue .. I built this from a loss in hp perspective, assuming this is what you wanted.

Try this
__________________

Last edited by Bugsy; 08-09-2021 at 14:19.
Bugsy is offline
theuser
Member
Join Date: Jul 2020
Old 08-10-2021 , 02:57   Re: Display previous round information in chat
Reply With Quote #18

Quote:
Originally Posted by Bugsy View Post
If a victim has 10hp and I blast him in the head with an awp, do you want to see another 100 (or whatever) damage issued in, or only the 10 loss in hp? I think this is the issue .. I built this from a loss in hp perspective, assuming this is what you wanted.

Try this
I want to see only 10
theuser is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-10-2021 , 09:36   Re: Display previous round information in chat
Reply With Quote #19

Doesn't that contradict this? https://forums.alliedmods.net/showpo...4&postcount=16
__________________
Bugsy is offline
theuser
Member
Join Date: Jul 2020
Old 08-10-2021 , 10:40   Re: Display previous round information in chat
Reply With Quote #20

Quote:
Originally Posted by Bugsy View Post
No, I meant that my opponent's damage is 100 and I do 100 damage to him, but the plugin mistypes 70 (I solved this problem myself)

And that if possible show the text of the message in next round freeze time

And show the damage we get from the enemy
For example, when a player's damage is 60 and I kill him, it is shown in the chat that I have taken 60 damage from him (Even if I had taken 400 damages from him)
(Note that the following may occur):
-The opponent's damage in the first round is 100
-I do 10 damage to him and his damage becomes 90
-Then my teammate deals 20 damage to him and his damage becomes 70
-In the end I kill him
Now in my chat it should say 80 (because I got 10 damage in the first round and 70 damage when I killed him.
Does the plugin calculate like this or it is possible?

And another problem
When someone drops a bomb and is damaged by a bomb, he sees himself as an attacker in the chat.

Last edited by theuser; 08-10-2021 at 15:13. Reason: add other bugs
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 02:01.


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