|
Senior Member
Join Date: Oct 2018
Location: Leeds
|

08-08-2021
, 23:53
Re: Display previous round information in chat
|
#11
|
Quote:
Originally Posted by Bugsy
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_pzStats[ MAX_PLAYERS + 1 ][ MAX_PLAYERS + 1 ][ PlayerStats ]; new g_pEnabled;
public plugin_init() { register_plugin( "Round Damage" , Version , "bugsy" ); RegisterHam( Ham_TakeDamage , "player" , "HamTakeDamage" , true ); register_logevent( "RoundEnd" , 2 , "1=Round_End" ); g_pEnabled = register_cvar( "rd_enabled" , "1" ); }
public HamTakeDamage( victim , inflictor , attacker , Float:fDamage , bitDamage ) { if ( get_pcvar_num( g_pEnabled ) ) { new iActualDamage = pev( victim , pev_dmg_take ); g_pzStats[ attacker ][ victim ][ Shots ]++; g_pzStats[ victim ][ attacker ][ DamageReceived ] += iActualDamage; g_pzStats[ attacker ][ victim ][ DamageGiven ] += iActualDamage; } }
public RoundEnd() { new iPlayers[ 32 ] , iNum , iAttackerPlayer , iVictimPlayer , iDamageGiven , iDamageTaken , iHealth[ MAX_PLAYERS + 1 ] , szName[ MAX_PLAYERS + 1 ][ 32 ]; get_players( iPlayers , iNum ); for ( new i = 0 ; i < iNum ; i++ ) { iAttackerPlayer = iPlayers[ i ]; for ( new p = 0 ; p < iNum ; p++ ) { iVictimPlayer = iPlayers[ p ]; if ( ( i != p ) && g_pzStats[ iAttackerPlayer ][ iVictimPlayer ][ DamageGiven ] || g_pzStats[ iAttackerPlayer ][ iVictimPlayer ][ DamageReceived ] ) { iDamageGiven = min( g_pzStats[ iAttackerPlayer ][ iVictimPlayer ][ DamageGiven ] , 100 ); iDamageTaken = min( g_pzStats[ iAttackerPlayer ][ iVictimPlayer ][ DamageReceived ] , 100 ); if ( iDamageGiven || iDamageTaken ) { if ( !iHealth[ iVictimPlayer ] ) iHealth[ iVictimPlayer ] = is_user_alive( iVictimPlayer ) ? get_user_health( iVictimPlayer ) : 0; if ( szName[ iVictimPlayer ][ 0 ] == EOS ) get_user_name( iVictimPlayer , szName[ iVictimPlayer ] , charsmax( szName[] ) ); client_print( iAttackerPlayer , print_chat , "(%d with %d) damage, (%d with %d) taken, %s (%dHP)" , iDamageGiven , g_pzStats[ iAttackerPlayer ][ iVictimPlayer ][ Shots ] , iDamageTaken , g_pzStats[ iVictimPlayer ][ iAttackerPlayer ][ Shots ] , szName[ iVictimPlayer ] , iHealth[ iVictimPlayer ] ); } } } }
ClearArray(); }
ClearArray() { for ( new i = 1 ; i <= MAX_PLAYERS ; i++ ) { for ( new p = 1 ; p <= MAX_PLAYERS ; p++ ) { g_pzStats[ i ][ p ][ Shots ] = 0; g_pzStats[ i ][ p ][ DamageGiven ] = 0; g_pzStats[ i ][ p ][ 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.
|
|