Raised This Month: $ Target: $400
 0% 

Display previous round information in chat


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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 #11

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
 



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 20:38.


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