PHP Code:
#include <amxmodx>
#include <amxmisc>
new gMaxPlayers
new gHeadshots[33]
new gUniqueID[33]
new pStats
#define SHOW_COMMAND (1<<0)
#define SHOW_ROUND (1<<1)
public plugin_init()
{
register_plugin( "Stats MOTD", "1.0", "Hawk552" )
register_event( "HLTV", "EventHLTV", "a", "1=0", "2=0" )
register_event( "DeathMsg", "EventDeathMsg", "a" )
register_clcmd( "say /kills", "CmdKills", "- shows stats screen" )
// Add up 1 for /kills and 2 for new round.
pStats = register_cvar( "amx_motd_stats", "3" )
gMaxPlayers = get_maxplayers()
}
public EventHLTV()
if ( get_pcvar_num( pStats ) & SHOW_ROUND )
for ( new i = 1; i <= gMaxPlayers; i++ )
if ( is_user_alive( i ) )
ShowMOTD( i )
public EventDeathMsg()
{
new attacker = read_data( 1 )
if ( 1 <= attacker <= gMaxPlayers && read_data( 3 ) )
{
new uniqueID = get_user_userid( attacker )
if ( uniqueID != gUniqueID[attacker] )
{
gHeadshots[attacker] = 0
gUniqueID[attacker] = uniqueID
}
gHeadshots[attacker]++
}
}
public CmdKills( id )
{
if ( get_pcvar_num( pStats ) & SHOW_COMMAND )
{
ShowMOTD( id )
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
ShowMOTD( id )
{
new len
static MOTD[4096], name[33]
get_user_name( id, name, 32 )
len = formatex( MOTD, charsmax( MOTD ), "Name: %s", name )
len += formatex( MOTD[len], charsmax( MOTD ) - len, "Kills: %d<br>", get_user_frags( id ) )
len += formatex( MOTD[len], charsmax( MOTD ) - len, "Deaths: %d<br>", get_user_deaths( id ) )
len += formatex( MOTD[len], charsmax( MOTD ) - len, "Headshots: %d", gHeadshots[id] )
show_motd( id, MOTD, "Stats" )
}
Try that. Cvar:
amx_motd_stats: flags 1 & 2.
1 - allow /kills command
2 - show on round start
You can use one, both or neither. To use both, add them up. The default value is 3. Untested and uncompiled, again.
__________________