2014-08-04 12:12:15 +00:00
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// StatsX Plugin
//
2004-06-24 08:10:52 +00:00
//--------------------------------
# include <amxmodx>
# include <amxmisc>
2004-10-04 07:30:39 +00:00
# include <csx>
2014-05-01 20:30:17 +00:00
# include <hamsandwich>
2004-06-24 08:10:52 +00:00
//--------------------------------
// Uncomment to activate log debug messages.
//#define STATSX_DEBUG
// HUD statistics duration in seconds (minimum 1.0 seconds).
2004-07-29 14:56:47 +00:00
# define HUD_DURATION_CVAR "amx_statsx_duration"
# define HUD_DURATION "12.0"
2004-06-24 08:10:52 +00:00
// HUD statistics stop relative freeze end in seconds.
// To stop before freeze end use a negative value.
2004-07-29 14:56:47 +00:00
# define HUD_FREEZE_LIMIT_CVAR "amx_statsx_freeze"
# define HUD_FREEZE_LIMIT "-2.0"
2004-06-24 08:10:52 +00:00
// HUD statistics minimum duration, in seconds, to trigger the display logic.
# define HUD_MIN_DURATION 0.2
// Config plugin constants.
2014-05-02 14:44:06 +00:00
# define MODE_HUD_DELAY 0 // Make a 0.1 sec delay on HUD reset process.
2004-06-24 08:10:52 +00:00
// You can also manualy enable or disable these options by setting them to 1
// For example:
// public ShowAttackers = 1
// However amx_statscfg command is recommended
2014-05-01 02:57:59 +00:00
public KillerChat = 0 // displays killer hp&ap to victim console
2005-09-18 03:19:34 +00:00
// and screen
2004-07-29 14:56:47 +00:00
2004-09-19 17:32:55 +00:00
public ShowAttackers = 0 // shows attackers
public ShowVictims = 0 // shows victims
2004-07-29 14:56:47 +00:00
public ShowKiller = 0 // shows killer
public ShowTeamScore = 0 // shows team score at round end
public ShowTotalStats = 0 // shows round total stats
public ShowBestScore = 0 // shows rounds best scored player
public ShowMostDisruptive = 0 // shows rounds most disruptive player
public EndPlayer = 0 // displays player stats at the end of map
public EndTop15 = 0 // displays top15 at the end of map
public SayHP = 0 // displays information about user killer
public SayStatsMe = 0 // displays user's stats and rank
2004-09-19 17:32:55 +00:00
public SayRankStats = 0 // displays user's rank stats
2004-07-29 14:56:47 +00:00
public SayMe = 0 // displays user's stats
2004-09-19 17:32:55 +00:00
public SayRank = 0 // displays user's rank
2004-07-29 14:56:47 +00:00
public SayReport = 0 // report user's weapon status to team
public SayScore = 0 // displays team's map score
2004-09-19 17:32:55 +00:00
public SayTop15 = 0 // displays first 15 players
2004-07-29 14:56:47 +00:00
public SayStatsAll = 0 // displays all players stats and rank
2004-10-04 07:30:39 +00:00
public ShowStats = 1 // set client HUD-stats switched off by default
2004-07-29 14:56:47 +00:00
public ShowDistHS = 0 // show distance and HS in attackers and
// victims HUD lists
public ShowFullStats = 0 // show full HUD stats (more than 78 chars)
public SpecRankInfo = 0 // displays rank info when spectating
2004-06-24 08:10:52 +00:00
// Standard Contstants.
# define MAX_TEAMS 2
# define MAX_WEAPON_LENGTH 31
# define MAX_TEXT_LENGTH 255
# define MAX_BUFFER_LENGTH 2047
// User stats parms id
# define STATS_KILLS 0
# define STATS_DEATHS 1
# define STATS_HS 2
# define STATS_TKS 3
# define STATS_SHOTS 4
# define STATS_HITS 5
# define STATS_DAMAGE 6
// Global player flags.
2005-09-18 03:19:34 +00:00
new BODY_PART [ 8 ] [ ] =
{
2014-05-01 02:57:59 +00:00
" WHOLEBODY " ,
" HEAD " ,
" CHEST " ,
" STOMACH " ,
" LEFTARM " ,
" RIGHTARM " ,
" LEFTLEG " ,
2005-09-18 03:19:34 +00:00
" RIGHTLEG "
2004-06-24 08:10:52 +00:00
}
// Killer information, save killer info at the time when player is killed.
# define KILLED_KILLER_ID 0 // Killer userindex/user-ID
# define KILLED_KILLER_HEALTH 1 // Killer's health
# define KILLED_KILLER_ARMOUR 2 // Killer's armour
# define KILLED_TEAM 3 // Killer's team
# define KILLED_KILLER_STATSFIX 4 // Fix to register the last hit/kill
2015-02-01 18:20:55 +00:00
new g_izKilled [ MAX_PLAYERS + 1 ] [ 5 ]
2004-06-24 08:10:52 +00:00
// Menu variables and configuration
# define MAX_PPL_MENU_ACTIONS 2 // Number of player menu actions
# define PPL_MENU_OPTIONS 7 // Number of player options per displayed menu
2015-02-01 18:20:55 +00:00
new g_iPluginMode = 0
2004-07-29 14:56:47 +00:00
2015-02-01 18:20:55 +00:00
new g_izUserMenuPosition [ MAX_PLAYERS + 1 ] = { 0 , . . . }
new g_izUserMenuAction [ MAX_PLAYERS + 1 ] = { 0 , . . . }
2015-02-01 20:45:16 +00:00
new g_izUserMenuPlayers [ MAX_PLAYERS + 1 ] [ MAX_PLAYERS ]
2004-07-29 14:56:47 +00:00
2015-02-01 18:20:55 +00:00
new g_izSpecMode [ MAX_PLAYERS + 1 ] = { 0 , . . . }
2004-07-29 14:56:47 +00:00
2015-02-01 18:20:55 +00:00
new g_izShowStatsFlags [ MAX_PLAYERS + 1 ] = { 0 , . . . }
new g_izStatsSwitch [ MAX_PLAYERS + 1 ] = { 0 , . . . }
new Float : g_fzShowUserStatsTime [ MAX_PLAYERS + 1 ] = { 0.0 , . . . }
new Float : g_fShowStatsTime = 0.0
new Float : g_fFreezeTime = 0.0
new Float : g_fFreezeLimitTime = 0.0
new Float : g_fHUDDuration = 0.0
2004-07-29 14:56:47 +00:00
2015-02-01 18:20:55 +00:00
new g_iRoundEndTriggered = 0
new g_iRoundEndProcessed = 0
2004-07-29 14:56:47 +00:00
2015-02-01 18:20:55 +00:00
new g_pFreezeTime = 0
new g_pRoundTime = 0
new g_pHudDuration = 0
new g_pHudFreezeLimit = 0
2014-05-01 03:08:26 +00:00
2015-02-01 18:20:55 +00:00
new Float : g_fStartGame = 0.0
new g_izTeamScore [ MAX_TEAMS ] = { 0 , . . . }
new g_izTeamEventScore [ MAX_TEAMS ] = { 0 , . . . }
2004-07-29 14:56:47 +00:00
new g_izTeamRndStats [ MAX_TEAMS ] [ 8 ]
new g_izTeamGameStats [ MAX_TEAMS ] [ 8 ]
2015-02-01 18:20:55 +00:00
new g_izUserUserID [ MAX_PLAYERS + 1 ] = { 0 , . . . }
new g_izUserAttackerDistance [ MAX_PLAYERS + 1 ] = { 0 , . . . }
new g_izUserVictimDistance [ MAX_PLAYERS + 1 ] [ MAX_PLAYERS + 1 ]
new g_izUserRndName [ MAX_PLAYERS + 1 ] [ MAX_NAME_LENGTH ]
new g_izUserRndStats [ MAX_PLAYERS + 1 ] [ 8 ]
new g_izUserGameStats [ MAX_PLAYERS + 1 ] [ 8 ]
2004-06-24 08:10:52 +00:00
// Common buffer to improve performance, as Small always zero-initializes all vars
2015-02-01 18:20:55 +00:00
new g_sBuffer [ MAX_BUFFER_LENGTH + 1 ] = " "
new g_sScore [ MAX_TEXT_LENGTH + 1 ] = " "
new g_sAwardAndScore [ MAX_BUFFER_LENGTH + 1 ] = " "
2004-06-24 08:10:52 +00:00
2015-02-01 18:20:55 +00:00
new t_sText [ MAX_TEXT_LENGTH + 1 ] = " "
new t_sName [ MAX_NAME_LENGTH + 1 ] = " "
new t_sWpn [ MAX_WEAPON_LENGTH + 1 ] = " "
2004-06-24 08:10:52 +00:00
2006-03-01 02:17:20 +00:00
new g_HudSync_EndRound
2007-06-28 04:25:04 +00:00
new g_HudSync_SpecInfo
2005-11-19 18:55:29 +00:00
2004-06-24 08:10:52 +00:00
//--------------------------------
2005-09-18 03:19:34 +00:00
// Initialize
2004-06-24 08:10:52 +00:00
//--------------------------------
2005-09-18 03:19:34 +00:00
public plugin_init ( )
{
// Register plugin.
register_plugin ( " StatsX " , AMXX_VERSION_STR , " AMXX Dev Team " )
register_dictionary ( " statsx.txt " )
// Register events.
register_event ( " TextMsg " , " eventStartGame " , " a " , " 2=#Game_Commencing " , " 2=#Game_will_restart_in " )
2014-05-01 20:30:17 +00:00
RegisterHamPlayer ( Ham_Spawn , " eventSpawn " , 1 )
2005-09-18 03:19:34 +00:00
register_event ( " RoundTime " , " eventStartRound " , " bc " )
register_event ( " SendAudio " , " eventEndRound " , " a " , " 2=%!MRAD_terwin " , " 2=%!MRAD_ctwin " , " 2=%!MRAD_rounddraw " )
register_event ( " TeamScore " , " eventTeamScore " , " a " )
register_event ( " 30 " , " eventIntermission " , " a " )
register_event ( " TextMsg " , " eventSpecMode " , " bd " , " 2&ec_Mod " )
register_event ( " StatusValue " , " eventShowRank " , " bd " , " 1=2 " )
// Register commands.
register_clcmd ( " say /hp " , " cmdHp " , 0 , " - display info. about your killer (chat) " )
register_clcmd ( " say /statsme " , " cmdStatsMe " , 0 , " - display your stats (MOTD) " )
register_clcmd ( " say /rankstats " , " cmdRankStats " , 0 , " - display your server stats (MOTD) " )
register_clcmd ( " say /me " , " cmdMe " , 0 , " - display current round stats (chat) " )
register_clcmd ( " say /score " , " cmdScore " , 0 , " - display last score (chat) " )
register_clcmd ( " say /rank " , " cmdRank " , 0 , " - display your rank (chat) " )
2006-11-22 04:14:56 +00:00
register_clcmd ( " say /report " , " cmdReport " , 0 , " - display weapon status (say_team) " )
2005-09-18 03:19:34 +00:00
register_clcmd ( " say /top15 " , " cmdTop15 " , 0 , " - display top 15 players (MOTD) " )
register_clcmd ( " say /stats " , " cmdStats " , 0 , " - display players stats (menu/MOTD) " )
register_clcmd ( " say /switch " , " cmdSwitch " , 0 , " - switch client's stats on or off " )
2006-06-12 06:14:35 +00:00
register_clcmd ( " say_team /hp " , " cmdHp " , 0 , " - display info. about your killer (chat) " )
register_clcmd ( " say_team /statsme " , " cmdStatsMe " , 0 , " - display your stats (MOTD) " )
register_clcmd ( " say_team /rankstats " , " cmdRankStats " , 0 , " - display your server stats (MOTD) " )
register_clcmd ( " say_team /me " , " cmdMe " , 0 , " - display current round stats (chat) " )
register_clcmd ( " say_team /score " , " cmdScore " , 0 , " - display last score (chat) " )
register_clcmd ( " say_team /rank " , " cmdRank " , 0 , " - display your rank (chat) " )
2006-11-22 04:17:08 +00:00
register_clcmd ( " say_team /report " , " cmdReport " , 0 , " - display weapon status (say_team_team) " )
2006-06-12 06:14:35 +00:00
register_clcmd ( " say_team /top15 " , " cmdTop15 " , 0 , " - display top 15 players (MOTD) " )
register_clcmd ( " say_team /stats " , " cmdStats " , 0 , " - display players stats (menu/MOTD) " )
register_clcmd ( " say_team /switch " , " cmdSwitch " , 0 , " - switch client's stats on or off " )
2005-09-18 03:19:34 +00:00
// Register menus.
register_menucmd ( register_menuid ( " Server Stats " ) , 1023 , " actionStatsMenu " )
// Register special configuration setting and default value.
register_srvcmd ( " amx_statsx_mode " , " cmdPluginMode " , ADMIN_CFG , " <flags> - sets plugin options " )
2004-06-24 08:10:52 +00:00
2005-09-18 03:19:34 +00:00
# if defined STATSX_DEBUG
register_clcmd ( " say /hudtest " , " cmdHudTest " )
# endif
2004-07-29 14:56:47 +00:00
2014-05-01 03:08:26 +00:00
g_pHudDuration = register_cvar ( HUD_DURATION_CVAR , HUD_DURATION )
g_pHudFreezeLimit = register_cvar ( HUD_FREEZE_LIMIT_CVAR , HUD_FREEZE_LIMIT )
g_pFreezeTime = get_cvar_pointer ( " mp_freezetime " )
g_pRoundTime = get_cvar_pointer ( " mp_roundtime " )
2004-07-29 14:56:47 +00:00
2005-09-18 03:19:34 +00:00
// Init buffers and some global vars.
g_sBuffer [ 0 ] = 0
2014-05-01 02:57:59 +00:00
2006-03-01 02:17:20 +00:00
g_HudSync_EndRound = CreateHudSyncObj ( )
2007-06-28 04:25:04 +00:00
g_HudSync_SpecInfo = CreateHudSyncObj ( )
2005-09-18 03:19:34 +00:00
}
2004-07-29 14:56:47 +00:00
2005-09-18 03:19:34 +00:00
public plugin_cfg ( )
{
new addStast [ ] = " amx_statscfg add ^ " % s ^ " %s "
2007-06-28 04:25:04 +00:00
server_cmd ( addStast , " ST_SHOW_KILLER_CHAT " , " KillerChat " )
server_cmd ( addStast , " ST_SHOW_ATTACKERS " , " ShowAttackers " )
server_cmd ( addStast , " ST_SHOW_VICTIMS " , " ShowVictims " )
server_cmd ( addStast , " ST_SHOW_KILLER " , " ShowKiller " )
server_cmd ( addStast , " ST_SHOW_TEAM_SCORE " , " ShowTeamScore " )
server_cmd ( addStast , " ST_SHOW_TOTAL_STATS " , " ShowTotalStats " )
server_cmd ( addStast , " ST_SHOW_BEST_SCORE " , " ShowBestScore " )
server_cmd ( addStast , " ST_SHOW_MOST_DISRUPTIVE " , " ShowMostDisruptive " )
server_cmd ( addStast , " ST_SHOW_HUD_STATS_DEF " , " ShowStats " )
server_cmd ( addStast , " ST_SHOW_DIST_HS_HUD " , " ShowDistHS " )
server_cmd ( addStast , " ST_STATS_PLAYER_MAP_END " , " EndPlayer " )
server_cmd ( addStast , " ST_STATS_TOP15_MAP_END " , " EndTop15 " )
server_cmd ( addStast , " ST_SAY_HP " , " SayHP " )
server_cmd ( addStast , " ST_SAY_STATSME " , " SayStatsMe " )
server_cmd ( addStast , " ST_SAY_RANKSTATS " , " SayRankStats " )
server_cmd ( addStast , " ST_SAY_ME " , " SayMe " )
server_cmd ( addStast , " ST_SAY_RANK " , " SayRank " )
server_cmd ( addStast , " ST_SAY_REPORT " , " SayReport " )
server_cmd ( addStast , " ST_SAY_SCORE " , " SayScore " )
server_cmd ( addStast , " ST_SAY_TOP15 " , " SayTop15 " )
server_cmd ( addStast , " ST_SAY_STATS " , " SayStatsAll " )
server_cmd ( addStast , " ST_SPEC_RANK " , " SpecRankInfo " )
2005-09-18 03:19:34 +00:00
// Update local configuration vars with value in cvars.
get_config_cvars ( )
}
2004-07-29 14:56:47 +00:00
2005-09-18 03:19:34 +00:00
// Set hudmessage format.
set_hudtype_killer ( Float : fDuration )
2005-11-19 01:25:34 +00:00
set_hudmessage ( 220 , 80 , 0 , 0.05 , 0.15 , 0 , 6.0 , fDuration , ( fDuration > = g_fHUDDuration ) ? 1.0 : 0.0 , 1.0 , - 1 )
2004-07-29 14:56:47 +00:00
2006-03-01 02:17:20 +00:00
set_hudtype_endround ( Float : fDuration )
2005-11-19 18:55:29 +00:00
{
2006-03-01 02:17:20 +00:00
set_hudmessage ( 100 , 200 , 0 , 0.05 , 0.55 , 0 , 0.02 , fDuration , ( fDuration > = g_fHUDDuration ) ? 1.0 : 0.0 , 1.0 )
2005-11-19 18:55:29 +00:00
}
2004-07-29 14:56:47 +00:00
2005-09-18 03:19:34 +00:00
set_hudtype_attacker ( Float : fDuration )
2005-11-19 01:25:34 +00:00
set_hudmessage ( 220 , 80 , 0 , 0.55 , 0.35 , 0 , 6.0 , fDuration , ( fDuration > = g_fHUDDuration ) ? 1.0 : 0.0 , 1.0 , - 1 )
2004-06-24 08:10:52 +00:00
2005-09-18 03:19:34 +00:00
set_hudtype_victim ( Float : fDuration )
2005-11-19 01:25:34 +00:00
set_hudmessage ( 0 , 80 , 220 , 0.55 , 0.60 , 0 , 6.0 , fDuration , ( fDuration > = g_fHUDDuration ) ? 1.0 : 0.0 , 1.0 , - 1 )
2004-06-24 08:10:52 +00:00
2005-09-18 03:19:34 +00:00
set_hudtype_specmode ( )
{
2007-06-28 04:25:04 +00:00
set_hudmessage ( 255 , 255 , 255 , 0.02 , 0.96 , 2 , 0.05 , 0.1 , 0.01 , 3.0 , - 1 )
2004-06-24 08:10:52 +00:00
}
2004-07-29 14:56:47 +00:00
# if defined STATSX_DEBUG
2005-09-18 03:19:34 +00:00
public cmdHudTest ( id )
{
new i , iLen
iLen = 0
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
for ( i = 1 ; i < 20 ; i + + )
2014-05-01 03:05:32 +00:00
iLen + = formatex ( g_sBuffer [ iLen ] , charsmax ( g_sBuffer ) - iLen , " ....x....1....x....2....x....3....x....4....x....^n " )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
set_hudtype_killer ( 50.0 )
2005-11-21 20:31:18 +00:00
show_hudmessage ( id , " %s " , g_sBuffer )
2004-06-24 08:10:52 +00:00
}
# endif
// Stats formulas
2005-09-18 03:19:34 +00:00
Float : accuracy ( izStats [ 8 ] )
{
2014-07-26 15:13:49 +00:00
return izStats [ STATS_SHOTS ] ? ( 100.0 * float ( izStats [ STATS_HITS ] ) / float ( izStats [ STATS_SHOTS ] ) ) : ( 0.0 ) ;
2004-06-24 08:10:52 +00:00
}
2005-09-18 03:19:34 +00:00
Float : effec ( izStats [ 8 ] )
{
2014-07-26 15:13:49 +00:00
return izStats [ STATS_KILLS ] ? ( 100.0 * float ( izStats [ STATS_KILLS ] ) / float ( izStats [ STATS_KILLS ] + izStats [ STATS_DEATHS ] ) ) : ( 0.0 ) ;
2004-06-24 08:10:52 +00:00
}
// Distance formula (metric)
2005-09-18 03:19:34 +00:00
Float : distance ( iDistance )
{
return float ( iDistance ) * 0.0254
2004-06-24 08:10:52 +00:00
}
// Get plugin config flags.
2005-09-18 03:19:34 +00:00
set_plugin_mode ( id , sFlags [ ] )
{
if ( sFlags [ 0 ] )
g_iPluginMode = read_flags ( sFlags )
2014-05-01 02:57:59 +00:00
2014-05-01 03:05:32 +00:00
get_flags ( g_iPluginMode , t_sText , charsmax ( t_sText ) )
2005-09-18 03:19:34 +00:00
console_print ( id , " %L " , id , " MODE_SET_TO " , t_sText )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return g_iPluginMode
2004-06-24 08:10:52 +00:00
}
// Get config parameters.
2005-09-18 03:19:34 +00:00
get_config_cvars ( )
{
2014-07-26 15:18:40 +00:00
g_fFreezeTime = floatmax ( get_pcvar_float ( g_pFreezeTime ) , 0.0 ) ;
2014-05-01 02:57:59 +00:00
2014-07-26 15:18:40 +00:00
g_fHUDDuration = floatmax ( get_pcvar_float ( g_pHudDuration ) , 1.0 ) ;
2005-09-18 03:19:34 +00:00
2014-05-01 03:08:26 +00:00
g_fFreezeLimitTime = get_pcvar_float ( g_pHudFreezeLimit )
2004-06-24 08:10:52 +00:00
}
// Get and format attackers header and list.
2005-09-18 03:19:34 +00:00
get_attackers ( id , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
{
new izStats [ 8 ] , izBody [ 8 ]
new iAttacker
new iFound , iLen
iFound = 0
sBuffer [ 0 ] = 0
// Get and format header. Add killing attacker statistics if user is dead.
// Make sure shots is greater than zero or division by zero will occur.
// To print a '%', 4 of them must done in a row.
izStats [ STATS_SHOTS ] = 0
iAttacker = g_izKilled [ id ] [ KILLED_KILLER_ID ]
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( iAttacker )
get_user_astats ( id , iAttacker , izStats , izBody )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( izStats [ STATS_SHOTS ] & & ShowFullStats )
{
2014-05-01 03:05:32 +00:00
get_user_name ( iAttacker , t_sName , charsmax ( t_sName ) )
iLen = formatex ( sBuffer , charsmax ( sBuffer ) , " %L -- %s -- %0.2f%% %L:^n " , id , " ATTACKERS " , t_sName , accuracy ( izStats ) , id , " ACC " )
2005-09-18 03:19:34 +00:00
}
else
2014-05-01 03:05:32 +00:00
iLen = formatex ( sBuffer , charsmax ( sBuffer ) , " %L:^n " , id , " ATTACKERS " )
2005-09-18 03:19:34 +00:00
// Get and format attacker list.
2014-07-20 10:27:02 +00:00
for ( iAttacker = 1 ; iAttacker < = MaxClients ; iAttacker + + )
2005-09-18 03:19:34 +00:00
{
2014-05-01 03:05:32 +00:00
if ( get_user_astats ( id , iAttacker , izStats , izBody , t_sWpn , charsmax ( t_sWpn ) ) )
2005-09-18 03:19:34 +00:00
{
iFound = 1
2014-05-01 03:05:32 +00:00
get_user_name ( iAttacker , t_sName , charsmax ( t_sName ) )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( izStats [ STATS_KILLS ] )
{
if ( ! ShowDistHS )
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %s -- %d %L / %d %L / %s^n " , t_sName , izStats [ STATS_HITS ] , id , " HIT_S " ,
2005-09-18 03:19:34 +00:00
izStats [ STATS_DAMAGE ] , id , " DMG " , t_sWpn )
else if ( izStats [ STATS_HS ] )
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %s -- %d %L / %d %L / %s / %0.0f m / HS^n " , t_sName , izStats [ STATS_HITS ] , id , " HIT_S " ,
2005-09-18 03:19:34 +00:00
izStats [ STATS_DAMAGE ] , id , " DMG " , t_sWpn , distance ( g_izUserAttackerDistance [ id ] ) )
else
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %s -- %d %L / %d %L / %s / %0.0f m^n " , t_sName , izStats [ STATS_HITS ] , id , " HIT_S " ,
2005-09-18 03:19:34 +00:00
izStats [ STATS_DAMAGE ] , id , " DMG " , t_sWpn , distance ( g_izUserAttackerDistance [ id ] ) )
}
else
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %s -- %d %L / %d %L^n " , t_sName , izStats [ STATS_HITS ] , id , " HIT_S " , izStats [ STATS_DAMAGE ] , id , " DMG " )
2005-09-18 03:19:34 +00:00
}
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( ! iFound )
sBuffer [ 0 ] = 0
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return iFound
2004-06-24 08:10:52 +00:00
}
// Get and format victims header and list
2005-09-18 03:19:34 +00:00
get_victims ( id , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
{
new izStats [ 8 ] , izBody [ 8 ]
new iVictim
new iFound , iLen
iFound = 0
sBuffer [ 0 ] = 0
// Get and format header.
// Make sure shots is greater than zero or division by zero will occur.
// To print a '%', 4 of them must done in a row.
izStats [ STATS_SHOTS ] = 0
get_user_vstats ( id , 0 , izStats , izBody )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( izStats [ STATS_SHOTS ] )
2014-05-01 03:05:32 +00:00
iLen = formatex ( sBuffer , charsmax ( sBuffer ) , " %L -- %0.2f%% %L:^n " , id , " VICTIMS " , accuracy ( izStats ) , id , " ACC " )
2005-09-18 03:19:34 +00:00
else
2014-05-01 03:05:32 +00:00
iLen = formatex ( sBuffer , charsmax ( sBuffer ) , " %L:^n " , id , " VICTIMS " )
2005-09-18 03:19:34 +00:00
2014-07-20 10:27:02 +00:00
for ( iVictim = 1 ; iVictim < = MaxClients ; iVictim + + )
2005-09-18 03:19:34 +00:00
{
2014-05-01 03:05:32 +00:00
if ( get_user_vstats ( id , iVictim , izStats , izBody , t_sWpn , charsmax ( t_sWpn ) ) )
2005-09-18 03:19:34 +00:00
{
iFound = 1
2014-05-01 03:05:32 +00:00
get_user_name ( iVictim , t_sName , charsmax ( t_sName ) )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( izStats [ STATS_DEATHS ] )
{
if ( ! ShowDistHS )
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %s -- %d %L / %d %L / %s^n " , t_sName , izStats [ STATS_HITS ] , id , " HIT_S " ,
2005-09-18 03:19:34 +00:00
izStats [ STATS_DAMAGE ] , id , " DMG " , t_sWpn )
else if ( izStats [ STATS_HS ] )
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %s -- %d %L / %d %L / %s / %0.0f m / HS^n " , t_sName , izStats [ STATS_HITS ] , id , " HIT_S " ,
2005-09-18 03:19:34 +00:00
izStats [ STATS_DAMAGE ] , id , " DMG " , t_sWpn , distance ( g_izUserVictimDistance [ id ] [ iVictim ] ) )
else
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %s -- %d %L / %d %L / %s / %0.0f m^n " , t_sName , izStats [ STATS_HITS ] , id , " HIT_S " ,
2005-09-18 03:19:34 +00:00
izStats [ STATS_DAMAGE ] , id , " DMG " , t_sWpn , distance ( g_izUserVictimDistance [ id ] [ iVictim ] ) )
}
else
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %s -- %d %L / %d %L^n " , t_sName , izStats [ STATS_HITS ] , id , " HIT_S " , izStats [ STATS_DAMAGE ] , id , " DMG " )
2005-09-18 03:19:34 +00:00
}
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( ! iFound )
sBuffer [ 0 ] = 0
return iFound
2004-06-24 08:10:52 +00:00
}
// Get and format kill info.
2005-09-18 03:19:34 +00:00
get_kill_info ( id , iKiller , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
{
new iFound , iLen
iFound = 0
sBuffer [ 0 ] = 0
if ( iKiller & & iKiller ! = id )
{
new izAStats [ 8 ] , izABody [ 8 ] , izVStats [ 8 ] , iaVBody [ 8 ]
iFound = 1
2014-05-01 03:05:32 +00:00
get_user_name ( iKiller , t_sName , charsmax ( t_sName ) )
2005-09-18 03:19:34 +00:00
izAStats [ STATS_HITS ] = 0
izAStats [ STATS_DAMAGE ] = 0
t_sWpn [ 0 ] = 0
2014-05-01 03:05:32 +00:00
get_user_astats ( id , iKiller , izAStats , izABody , t_sWpn , charsmax ( t_sWpn ) )
2005-09-18 03:19:34 +00:00
izVStats [ STATS_HITS ] = 0
izVStats [ STATS_DAMAGE ] = 0
get_user_vstats ( id , iKiller , izVStats , iaVBody )
2014-05-01 03:05:32 +00:00
iLen = formatex ( sBuffer , charsmax ( sBuffer ) , " %L^n " , id , " KILLED_YOU_DIST " , t_sName , t_sWpn , distance ( g_izUserAttackerDistance [ id ] ) )
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %L^n " , id , " DID_DMG_HITS " , izAStats [ STATS_DAMAGE ] , izAStats [ STATS_HITS ] , g_izKilled [ id ] [ KILLED_KILLER_HEALTH ] , g_izKilled [ id ] [ KILLED_KILLER_ARMOUR ] )
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %L^n " , id , " YOU_DID_DMG " , izVStats [ STATS_DAMAGE ] , izVStats [ STATS_HITS ] )
2005-09-18 03:19:34 +00:00
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return iFound
2004-06-24 08:10:52 +00:00
}
// Get and format most disruptive.
2014-05-01 12:30:42 +00:00
add_most_disruptive ( id , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
2005-09-18 03:19:34 +00:00
{
2014-05-01 12:30:42 +00:00
new iPlayer , iMaxDamageId , iMaxDamage , iMaxHeadShots
2005-09-18 03:19:34 +00:00
iMaxDamageId = 0
iMaxDamage = 0
iMaxHeadShots = 0
// Find player.
2014-07-26 14:56:42 +00:00
for ( iPlayer = 1 ; iPlayer < = MaxClients ; iPlayer + + )
2005-09-18 03:19:34 +00:00
{
2014-05-01 12:30:42 +00:00
if ( g_izUserRndStats [ iPlayer ] [ STATS_DAMAGE ] > = iMaxDamage & & ( g_izUserRndStats [ iPlayer ] [ STATS_DAMAGE ] > iMaxDamage | | g_izUserRndStats [ iPlayer ] [ STATS_HS ] > iMaxHeadShots ) )
2005-09-18 03:19:34 +00:00
{
2014-05-01 12:30:42 +00:00
iMaxDamageId = iPlayer
iMaxDamage = g_izUserRndStats [ iPlayer ] [ STATS_DAMAGE ]
iMaxHeadShots = g_izUserRndStats [ iPlayer ] [ STATS_HS ]
2005-09-18 03:19:34 +00:00
}
}
// Format statistics.
if ( iMaxDamageId )
{
2014-05-01 12:30:42 +00:00
iPlayer = iMaxDamageId
2014-05-01 02:57:59 +00:00
2014-05-01 12:30:42 +00:00
new Float : fGameEff = effec ( g_izUserGameStats [ iPlayer ] )
new Float : fRndAcc = accuracy ( g_izUserRndStats [ iPlayer ] )
2014-05-01 02:57:59 +00:00
2014-05-01 12:30:42 +00:00
formatex ( t_sText , charsmax ( t_sText ) , " %L: %s^n%d %L / %d %L -- %0.2f%% %L / %0.2f%% %L^n " , id , " MOST_DMG " , g_izUserRndName [ iPlayer ] ,
g_izUserRndStats [ iPlayer ] [ STATS_HITS ] , id , " HIT_S " , iMaxDamage , id , " DMG " , fGameEff , id , " EFF " , fRndAcc , id , " ACC " )
2014-05-01 03:05:32 +00:00
add ( sBuffer , charsmax ( sBuffer ) , t_sText )
2005-09-18 03:19:34 +00:00
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return iMaxDamageId
2004-06-24 08:10:52 +00:00
}
// Get and format best score.
2014-05-01 12:30:42 +00:00
add_best_score ( id , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
2005-09-18 03:19:34 +00:00
{
2014-05-01 12:30:42 +00:00
new iPlayer , iMaxKillsId , iMaxKills , iMaxHeadShots
2005-09-18 03:19:34 +00:00
iMaxKillsId = 0
iMaxKills = 0
iMaxHeadShots = 0
// Find player
2014-07-26 14:56:42 +00:00
for ( iPlayer = 1 ; iPlayer < = MaxClients ; iPlayer + + )
2005-09-18 03:19:34 +00:00
{
2014-05-01 12:30:42 +00:00
if ( g_izUserRndStats [ iPlayer ] [ STATS_KILLS ] > = iMaxKills & & ( g_izUserRndStats [ iPlayer ] [ STATS_KILLS ] > iMaxKills | | g_izUserRndStats [ iPlayer ] [ STATS_HS ] > iMaxHeadShots ) )
2005-09-18 03:19:34 +00:00
{
2014-05-01 12:30:42 +00:00
iMaxKillsId = iPlayer
iMaxKills = g_izUserRndStats [ iPlayer ] [ STATS_KILLS ]
iMaxHeadShots = g_izUserRndStats [ iPlayer ] [ STATS_HS ]
2005-09-18 03:19:34 +00:00
}
}
// Format statistics.
if ( iMaxKillsId )
{
2014-05-01 12:30:42 +00:00
iPlayer = iMaxKillsId
2014-05-01 02:57:59 +00:00
2014-05-01 12:30:42 +00:00
new Float : fGameEff = effec ( g_izUserGameStats [ iPlayer ] )
new Float : fRndAcc = accuracy ( g_izUserRndStats [ iPlayer ] )
2014-05-01 02:57:59 +00:00
2014-05-01 12:30:42 +00:00
formatex ( t_sText , charsmax ( t_sText ) , " %L: %s^n%d %L / %d hs -- %0.2f%% %L / %0.2f%% %L^n " , id , " BEST_SCORE " , g_izUserRndName [ iPlayer ] ,
iMaxKills , id , " KILL_S " , iMaxHeadShots , fGameEff , id , " EFF " , fRndAcc , id , " ACC " )
2014-05-01 03:05:32 +00:00
add ( sBuffer , charsmax ( sBuffer ) , t_sText )
2005-09-18 03:19:34 +00:00
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return iMaxKillsId
2004-06-24 08:10:52 +00:00
}
// Get and format team score.
2014-05-01 12:30:42 +00:00
add_team_score ( id , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
2005-09-18 03:19:34 +00:00
{
new Float : fzMapEff [ MAX_TEAMS ] , Float : fzMapAcc [ MAX_TEAMS ] , Float : fzRndAcc [ MAX_TEAMS ]
// Calculate team stats
for ( new iTeam = 0 ; iTeam < MAX_TEAMS ; iTeam + + )
{
fzMapEff [ iTeam ] = effec ( g_izTeamGameStats [ iTeam ] )
fzMapAcc [ iTeam ] = accuracy ( g_izTeamGameStats [ iTeam ] )
fzRndAcc [ iTeam ] = accuracy ( g_izTeamRndStats [ iTeam ] )
}
// Format round team stats, MOTD
2014-05-01 03:05:32 +00:00
formatex ( t_sText , charsmax ( t_sText ) , " TERRORIST %d / %0.2f%% %L / %0.2f%% %L^nCT %d / %0.2f%% %L / %0.2f%% %L^n " , g_izTeamScore [ 0 ] ,
2014-05-01 12:30:42 +00:00
fzMapEff [ 0 ] , id , " EFF " , fzRndAcc [ 0 ] , id , " ACC " , g_izTeamScore [ 1 ] , fzMapEff [ 1 ] , id , " EFF " , fzRndAcc [ 1 ] , id , " ACC " )
2014-05-01 03:05:32 +00:00
add ( sBuffer , charsmax ( sBuffer ) , t_sText )
2004-06-24 08:10:52 +00:00
}
// Get and format team stats, chat version
2014-05-01 12:50:07 +00:00
save_team_chatscore ( id , sBuffer [ MAX_TEXT_LENGTH + 1 ] )
2005-09-18 03:19:34 +00:00
{
new Float : fzMapEff [ MAX_TEAMS ] , Float : fzMapAcc [ MAX_TEAMS ] , Float : fzRndAcc [ MAX_TEAMS ]
// Calculate team stats
for ( new iTeam = 0 ; iTeam < MAX_TEAMS ; iTeam + + )
{
fzMapEff [ iTeam ] = effec ( g_izTeamGameStats [ iTeam ] )
fzMapAcc [ iTeam ] = accuracy ( g_izTeamGameStats [ iTeam ] )
fzRndAcc [ iTeam ] = accuracy ( g_izTeamRndStats [ iTeam ] )
}
// Format game team stats, chat
2014-05-01 12:50:07 +00:00
formatex ( sBuffer , charsmax ( sBuffer ) , " TERRORIST %d / %0.2f%% %L / %0.2f%% %L -- CT %d / %0.2f%% %L / %0.2f%% %L " , g_izTeamScore [ 0 ] ,
2014-05-01 12:30:42 +00:00
fzMapEff [ 0 ] , id , " EFF " , fzMapAcc [ 0 ] , id , " ACC " , g_izTeamScore [ 1 ] , fzMapEff [ 1 ] , id , " EFF " , fzMapAcc [ 1 ] , id , " ACC " )
2004-06-24 08:10:52 +00:00
}
// Get and format total stats.
2014-05-01 12:30:42 +00:00
add_total_stats ( id , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
2005-09-18 03:19:34 +00:00
{
2014-05-01 12:30:42 +00:00
formatex ( t_sText , charsmax ( t_sText ) , " %L: %d %L / %d hs -- %d %L / %d %L^n " , id , " TOTAL " , g_izUserRndStats [ 0 ] [ STATS_KILLS ] , id , " KILL_S " ,
g_izUserRndStats [ 0 ] [ STATS_HS ] , g_izUserRndStats [ 0 ] [ STATS_HITS ] , id , " HITS " , g_izUserRndStats [ 0 ] [ STATS_SHOTS ] , id , " SHOT_S " )
2014-05-01 03:05:32 +00:00
add ( sBuffer , charsmax ( sBuffer ) , t_sText )
2004-06-24 08:10:52 +00:00
}
// Get and format a user's list of body hits from an attacker.
2005-09-18 03:19:34 +00:00
add_attacker_hits ( id , iAttacker , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
{
new iFound = 0
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( iAttacker & & iAttacker ! = id )
{
new izStats [ 8 ] , izBody [ 8 ] , iLen
izStats [ STATS_HITS ] = 0
get_user_astats ( id , iAttacker , izStats , izBody )
if ( izStats [ STATS_HITS ] )
{
iFound = 1
iLen = strlen ( sBuffer )
2014-05-01 03:05:32 +00:00
get_user_name ( iAttacker , t_sName , charsmax ( t_sName ) )
2014-05-01 02:57:59 +00:00
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %L:^n " , id , " HITS_YOU_IN " , t_sName )
2014-05-01 02:57:59 +00:00
2014-10-11 15:46:29 +00:00
for ( new i = 1 ; i < sizeof ( izBody ) ; i + + )
2005-09-18 03:19:34 +00:00
{
if ( ! izBody [ i ] )
continue
2014-05-01 02:57:59 +00:00
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %L: %d^n " , id , BODY_PART [ i ] , izBody [ i ] )
2005-09-18 03:19:34 +00:00
}
}
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return iFound
2004-06-24 08:10:52 +00:00
}
// Get and format killed stats: killer hp, ap, hits.
2005-09-18 03:19:34 +00:00
format_kill_ainfo ( id , iKiller , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
{
new iFound = 0
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( iKiller & & iKiller ! = id )
{
new izStats [ 8 ] , izBody [ 8 ]
new iLen
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
iFound = 1
2014-05-01 03:05:32 +00:00
get_user_name ( iKiller , t_sName , charsmax ( t_sName ) )
2005-09-18 03:19:34 +00:00
izStats [ STATS_HITS ] = 0
2014-05-01 03:05:32 +00:00
get_user_astats ( id , iKiller , izStats , izBody , t_sWpn , charsmax ( t_sWpn ) )
2005-09-18 03:19:34 +00:00
2014-05-01 03:05:32 +00:00
iLen = formatex ( sBuffer , charsmax ( sBuffer ) , " %L (%dhp, %dap) >> " , id , " KILLED_BY_WITH " , t_sName , t_sWpn , distance ( g_izUserAttackerDistance [ id ] ) ,
2005-09-18 03:19:34 +00:00
g_izKilled [ id ] [ KILLED_KILLER_HEALTH ] , g_izKilled [ id ] [ KILLED_KILLER_ARMOUR ] )
if ( izStats [ STATS_HITS ] )
{
2014-10-11 15:46:29 +00:00
for ( new i = 1 ; i < sizeof ( izBody ) ; i + + )
2005-09-18 03:19:34 +00:00
{
if ( ! izBody [ i ] )
continue
2014-05-01 02:57:59 +00:00
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %L: %d " , id , BODY_PART [ i ] , izBody [ i ] )
2005-09-18 03:19:34 +00:00
}
}
else
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %L " , id , " NO_HITS " )
2005-09-18 03:19:34 +00:00
}
else
2014-05-01 03:05:32 +00:00
formatex ( sBuffer , charsmax ( sBuffer ) , " %L " , id , " YOU_NO_KILLER " )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return iFound
2004-06-24 08:10:52 +00:00
}
// Get and format killed stats: hits, damage on killer.
2005-09-18 03:19:34 +00:00
format_kill_vinfo ( id , iKiller , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
{
new iFound = 0
new izStats [ 8 ]
new izBody [ 8 ]
new iLen
izStats [ STATS_HITS ] = 0
izStats [ STATS_DAMAGE ] = 0
get_user_vstats ( id , iKiller , izStats , izBody )
if ( iKiller & & iKiller ! = id )
{
iFound = 1
2014-05-01 03:05:32 +00:00
get_user_name ( iKiller , t_sName , charsmax ( t_sName ) )
iLen = formatex ( sBuffer , charsmax ( sBuffer ) , " %L >> " , id , " YOU_HIT " , t_sName , izStats [ STATS_HITS ] , izStats [ STATS_DAMAGE ] )
2005-09-18 03:19:34 +00:00
}
else
2014-05-01 03:05:32 +00:00
iLen = formatex ( sBuffer , charsmax ( sBuffer ) , " %L >> " , id , " LAST_RES " , izStats [ STATS_HITS ] , izStats [ STATS_DAMAGE ] )
2005-09-18 03:19:34 +00:00
if ( izStats [ STATS_HITS ] )
{
2014-10-11 15:46:29 +00:00
for ( new i = 1 ; i < sizeof ( izBody ) ; i + + )
2005-09-18 03:19:34 +00:00
{
if ( ! izBody [ i ] )
continue
2014-05-01 02:57:59 +00:00
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %L: %d " , id , BODY_PART [ i ] , izBody [ i ] )
2005-09-18 03:19:34 +00:00
}
}
else
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %L " , id , " NO_HITS " )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return iFound
2004-06-24 08:10:52 +00:00
}
// Get and format top 15.
2014-05-01 12:30:42 +00:00
format_top15 ( id , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
2005-09-18 03:19:34 +00:00
{
new iMax = get_statsnum ( )
new izStats [ 8 ] , izBody [ 8 ]
new iLen = 0
if ( iMax > 15 )
iMax = 15
new lKills [ 16 ] , lDeaths [ 16 ] , lHits [ 16 ] , lShots [ 16 ] , lEff [ 16 ] , lAcc [ 16 ]
2014-05-01 02:57:59 +00:00
2014-05-02 11:53:25 +00:00
formatex ( lKills , charsmax ( lKills ) , " %L " , id , " KILLS " )
formatex ( lDeaths , charsmax ( lDeaths ) , " %L " , id , " DEATHS " )
formatex ( lHits , charsmax ( lHits ) , " %L " , id , " HITS " )
formatex ( lShots , charsmax ( lShots ) , " %L " , id , " SHOTS " )
formatex ( lEff , charsmax ( lEff ) , " %L " , id , " EFF " )
formatex ( lAcc , charsmax ( lAcc ) , " %L " , id , " ACC " )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
ucfirst ( lEff )
ucfirst ( lAcc )
2014-05-01 03:05:32 +00:00
iLen = formatex ( sBuffer , charsmax ( sBuffer ) , " <meta charset=utf-8><body bgcolor=#000000><font color=#FFB000><pre> " )
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %2s %-22.22s %6s %6s %6s %6s %4s %4s %4s^n " , " # " , " Nick " , lKills , lDeaths , lHits , lShots , " HS " , lEff , lAcc )
2014-05-01 02:57:59 +00:00
2014-05-01 03:05:32 +00:00
for ( new i = 0 ; i < iMax & & charsmax ( sBuffer ) - iLen > 0 ; i + + )
2005-09-18 03:19:34 +00:00
{
2014-05-01 03:05:32 +00:00
get_stats ( i , izStats , izBody , t_sName , charsmax ( t_sName ) )
2014-05-02 14:44:06 +00:00
replace_string ( t_sName , charsmax ( t_sName ) , " < " , " [ " )
replace_string ( t_sName , charsmax ( t_sName ) , " > " , " ] " )
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %2d %-22.22s %6d %6d %6d %6d %4d %3.0f%% %3.0f%%^n " , i + 1 , t_sName , izStats [ STATS_KILLS ] ,
2005-09-18 03:19:34 +00:00
izStats [ STATS_DEATHS ] , izStats [ STATS_HITS ] , izStats [ STATS_SHOTS ] , izStats [ STATS_HS ] , effec ( izStats ) , accuracy ( izStats ) )
}
2004-06-24 08:10:52 +00:00
}
// Get and format rank stats.
2005-09-18 03:19:34 +00:00
format_rankstats ( id , sBuffer [ MAX_BUFFER_LENGTH + 1 ] , iMyId = 0 )
{
new izStats [ 8 ] = { 0 , . . . }
new izBody [ 8 ]
new iRankPos , iLen
new lKills [ 16 ] , lDeaths [ 16 ] , lHits [ 16 ] , lShots [ 16 ] , lDamage [ 16 ] , lEff [ 16 ] , lAcc [ 16 ]
2014-05-01 02:57:59 +00:00
2014-05-02 11:53:25 +00:00
formatex ( lKills , charsmax ( lKills ) , " %L " , id , " KILLS " )
formatex ( lDeaths , charsmax ( lDeaths ) , " %L " , id , " DEATHS " )
formatex ( lHits , charsmax ( lHits ) , " %L " , id , " HITS " )
formatex ( lShots , charsmax ( lShots ) , " %L " , id , " SHOTS " )
formatex ( lDamage , charsmax ( lDamage ) , " %L " , id , " DAMAGE " )
formatex ( lEff , charsmax ( lEff ) , " %L " , id , " EFF " )
formatex ( lAcc , charsmax ( lAcc ) , " %L " , id , " ACC " )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
ucfirst ( lEff )
ucfirst ( lAcc )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
iRankPos = get_user_stats ( id , izStats , izBody )
2014-09-20 22:42:03 +00:00
iLen = formatex ( sBuffer , charsmax ( sBuffer ) , " <meta charset=utf-8><body bgcolor=#000000><font color=#FFB000><pre> " )
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %L %L^n^n " , id , ( ! iMyId | | iMyId = = id ) ? " YOUR " : " PLAYERS " , id , " RANK_IS " , iRankPos , get_statsnum ( ) )
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %6s: %d (%d with hs)^n%6s: %d^n%6s: %d^n%6s: %d^n%6s: %d^n%6s: %0.2f%%^n%6s: %0.2f%%^n^n " ,
2014-05-01 02:57:59 +00:00
lKills , izStats [ STATS_KILLS ] , izStats [ STATS_HS ] , lDeaths , izStats [ STATS_DEATHS ] , lHits , izStats [ STATS_HITS ] , lShots , izStats [ STATS_SHOTS ] ,
2005-09-18 03:19:34 +00:00
lDamage , izStats [ STATS_DAMAGE ] , lEff , effec ( izStats ) , lAcc , accuracy ( izStats ) )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
new L_BODY_PART [ 8 ] [ 32 ]
2014-05-01 02:57:59 +00:00
2014-10-11 15:46:29 +00:00
for ( new i = 1 ; i < sizeof ( L_BODY_PART ) ; i + + )
2005-09-18 03:19:34 +00:00
{
2014-05-02 11:53:25 +00:00
formatex ( L_BODY_PART [ i ] , charsmax ( L_BODY_PART [ ] ) , " %L " , id , BODY_PART [ i ] )
2005-09-18 03:19:34 +00:00
}
2014-05-01 02:57:59 +00:00
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %10s:^n%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d " , " HITS " ,
2014-05-01 02:57:59 +00:00
L_BODY_PART [ 1 ] , izBody [ 1 ] , L_BODY_PART [ 2 ] , izBody [ 2 ] , L_BODY_PART [ 3 ] , izBody [ 3 ] , L_BODY_PART [ 4 ] , izBody [ 4 ] , L_BODY_PART [ 5 ] ,
2005-09-18 03:19:34 +00:00
izBody [ 5 ] , L_BODY_PART [ 6 ] , izBody [ 6 ] , L_BODY_PART [ 7 ] , izBody [ 7 ] )
2004-06-24 08:10:52 +00:00
}
// Get and format stats.
2005-09-18 03:19:34 +00:00
format_stats ( id , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
{
new izStats [ 8 ] = { 0 , . . . }
new izBody [ 8 ]
new iWeapon , iLen
new lKills [ 16 ] , lDeaths [ 16 ] , lHits [ 16 ] , lShots [ 16 ] , lDamage [ 16 ] , lEff [ 16 ] , lAcc [ 16 ] , lWeapon [ 16 ]
2014-05-01 02:57:59 +00:00
2014-05-02 11:53:25 +00:00
formatex ( lKills , charsmax ( lKills ) , " %L " , id , " KILLS " )
formatex ( lDeaths , charsmax ( lDeaths ) , " %L " , id , " DEATHS " )
formatex ( lHits , charsmax ( lHits ) , " %L " , id , " HITS " )
formatex ( lShots , charsmax ( lShots ) , " %L " , id , " SHOTS " )
formatex ( lDamage , charsmax ( lDamage ) , " %L " , id , " DAMAGE " )
formatex ( lEff , charsmax ( lEff ) , " %L " , id , " EFF " )
formatex ( lAcc , charsmax ( lAcc ) , " %L " , id , " ACC " )
formatex ( lWeapon , charsmax ( lWeapon ) , " %L " , id , " WEAPON " )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
ucfirst ( lEff )
ucfirst ( lAcc )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
get_user_wstats ( id , 0 , izStats , izBody )
2014-05-01 02:57:59 +00:00
2014-09-20 22:42:03 +00:00
iLen = formatex ( sBuffer , charsmax ( sBuffer ) , " <meta charset=utf-8><body bgcolor=#000000><font color=#FFB000><pre> " )
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %6s: %d (%d with hs)^n%6s: %d^n%6s: %d^n%6s: %d^n%6s: %d^n%6s: %0.2f%%^n%6s: %0.2f%%^n^n " ,
2014-05-01 02:57:59 +00:00
lKills , izStats [ STATS_KILLS ] , izStats [ STATS_HS ] , lDeaths , izStats [ STATS_DEATHS ] , lHits , izStats [ STATS_HITS ] , lShots , izStats [ STATS_SHOTS ] ,
2005-09-18 03:19:34 +00:00
lDamage , izStats [ STATS_DAMAGE ] , lEff , effec ( izStats ) , lAcc , accuracy ( izStats ) )
2014-05-01 03:05:32 +00:00
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %-12.12s %6s %6s %6s %6s %6s %4s^n " , lWeapon , lKills , lDeaths , lHits , lShots , lDamage , lAcc )
2014-05-01 02:57:59 +00:00
2014-05-01 03:05:32 +00:00
for ( iWeapon = 1 ; iWeapon < xmod_get_maxweapons ( ) & & charsmax ( sBuffer ) - iLen > 0 ; iWeapon + + )
2005-09-18 03:19:34 +00:00
{
if ( get_user_wstats ( id , iWeapon , izStats , izBody ) )
{
2014-05-01 03:05:32 +00:00
xmod_get_wpnname ( iWeapon , t_sWpn , charsmax ( t_sWpn ) )
iLen + = formatex ( sBuffer [ iLen ] , charsmax ( sBuffer ) - iLen , " %-12.12s %6d %6d %6d %6d %6d %3.0f%%^n " , t_sWpn , izStats [ STATS_KILLS ] , izStats [ STATS_DEATHS ] ,
2005-09-18 03:19:34 +00:00
izStats [ STATS_HITS ] , izStats [ STATS_SHOTS ] , izStats [ STATS_DAMAGE ] , accuracy ( izStats ) )
}
}
2004-06-24 08:10:52 +00:00
}
2014-05-01 12:41:23 +00:00
// Format round end stats
2014-05-01 12:50:07 +00:00
format_roundend_hudstats ( id , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
2014-05-01 12:41:23 +00:00
{
2014-05-01 12:50:07 +00:00
sBuffer [ 0 ] = 0
2014-05-01 12:41:23 +00:00
// Create round awards.
if ( ShowMostDisruptive )
2014-05-01 12:50:07 +00:00
add_most_disruptive ( id , sBuffer )
2014-05-01 12:41:23 +00:00
if ( ShowBestScore )
2014-05-01 12:50:07 +00:00
add_best_score ( id , sBuffer )
2014-05-01 12:41:23 +00:00
// Create round score.
// Compensate HUD message if awards are disabled.
if ( ShowTeamScore | | ShowTotalStats )
{
if ( ShowMostDisruptive & & ShowBestScore )
2014-05-01 12:50:07 +00:00
add ( sBuffer , charsmax ( sBuffer ) , " ^n^n " )
2014-05-01 12:41:23 +00:00
else if ( ShowMostDisruptive | | ShowBestScore )
2014-05-01 12:50:07 +00:00
add ( sBuffer , charsmax ( sBuffer ) , " ^n^n^n^n " )
2014-05-01 12:41:23 +00:00
else
2014-05-01 12:50:07 +00:00
add ( sBuffer , charsmax ( sBuffer ) , " ^n^n^n^n^n^n " )
2014-05-01 12:41:23 +00:00
if ( ShowTeamScore )
2014-05-01 12:50:07 +00:00
add_team_score ( id , sBuffer )
2014-05-01 12:41:23 +00:00
if ( ShowTotalStats )
2014-05-01 12:50:07 +00:00
add_total_stats ( id , sBuffer )
2014-05-01 12:41:23 +00:00
}
}
2014-05-01 02:57:59 +00:00
// Show round end stats. If gametime is zero then use default duration time.
2014-05-01 12:50:07 +00:00
show_roundend_hudstats ( id , Float : fGameTime , sBuffer [ MAX_BUFFER_LENGTH + 1 ] )
2005-09-18 03:19:34 +00:00
{
// Bail out if there no HUD stats should be shown
// for this player or end round stats not created.
if ( ! g_izStatsSwitch [ id ] ) return
2014-05-01 12:50:07 +00:00
if ( ! sBuffer [ 0 ] ) return
2005-09-18 03:19:34 +00:00
// If round end timer is zero clear round end stats.
if ( g_fShowStatsTime = = 0.0 )
{
2006-03-01 02:17:20 +00:00
ClearSyncHud ( id , g_HudSync_EndRound )
2005-09-18 03:19:34 +00:00
# if defined STATSX_DEBUG
log_amx ( " Clear round end HUD stats for #%d " , id )
# endif
}
// Set HUD-duration to default or remaining time.
new Float : fDuration
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( fGameTime = = 0.0 )
fDuration = g_fHUDDuration
else
{
fDuration = g_fShowStatsTime + g_fHUDDuration - fGameTime
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( fDuration > g_fFreezeTime + g_fFreezeLimitTime )
fDuration = g_fFreezeTime + g_fFreezeLimitTime
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
// Show stats only if more time left than coded minimum.
if ( fDuration > = HUD_MIN_DURATION )
{
2006-03-01 02:17:20 +00:00
set_hudtype_endround ( fDuration )
2014-05-01 12:50:07 +00:00
ShowSyncHudMsg ( id , g_HudSync_EndRound , " %s " , sBuffer )
2005-09-18 03:19:34 +00:00
# if defined STATSX_DEBUG
log_amx ( " Show %1.2fs round end HUD stats for #%d " , fDuration , id )
# endif
}
2004-06-24 08:10:52 +00:00
}
// Show round end stats.
2005-09-18 03:19:34 +00:00
show_user_hudstats ( id , Float : fGameTime )
{
// Bail out if there no HUD stats should be shown
// for this player or user stats timer is zero.
if ( ! g_izStatsSwitch [ id ] ) return
if ( g_fzShowUserStatsTime [ id ] = = 0.0 ) return
// Set HUD-duration to default or remaining time.
new Float : fDuration
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( fGameTime = = 0.0 )
fDuration = g_fHUDDuration
else
{
fDuration = g_fzShowUserStatsTime [ id ] + g_fHUDDuration - fGameTime
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( fDuration > g_fFreezeTime + g_fFreezeLimitTime )
fDuration = g_fFreezeTime + g_fFreezeLimitTime
}
// Show stats only if more time left than coded minimum.
if ( fDuration > = HUD_MIN_DURATION )
{
if ( ShowKiller )
{
new iKiller
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
iKiller = g_izKilled [ id ] [ KILLED_KILLER_ID ]
get_kill_info ( id , iKiller , g_sBuffer )
add_attacker_hits ( id , iKiller , g_sBuffer )
set_hudtype_killer ( fDuration )
2005-11-21 20:31:18 +00:00
show_hudmessage ( id , " %s " , g_sBuffer )
2005-09-18 03:19:34 +00:00
# if defined STATSX_DEBUG
log_amx ( " Show %1.2fs %suser HUD k-stats for #%d " , fDuration , g_sBuffer [ 0 ] ? " " : " no " , id )
# endif
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( ShowVictims )
{
get_victims ( id , g_sBuffer )
set_hudtype_victim ( fDuration )
2005-11-21 20:31:18 +00:00
show_hudmessage ( id , " %s " , g_sBuffer )
2005-09-18 03:19:34 +00:00
# if defined STATSX_DEBUG
log_amx ( " Show %1.2fs %suser HUD v-stats for #%d " , fDuration , g_sBuffer [ 0 ] ? " " : " no " , id )
# endif
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( ShowAttackers )
{
get_attackers ( id , g_sBuffer )
set_hudtype_attacker ( fDuration )
2005-11-21 20:31:18 +00:00
show_hudmessage ( id , " %s " , g_sBuffer )
2005-09-18 03:19:34 +00:00
# if defined STATSX_DEBUG
log_amx ( " Show %1.2fs %suser HUD a-stats for #%d " , fDuration , g_sBuffer [ 0 ] ? " " : " no " , id )
# endif
}
}
2004-06-24 08:10:52 +00:00
}
//------------------------------------------------------------
2005-09-18 03:19:34 +00:00
// Plugin commands
2004-06-24 08:10:52 +00:00
//------------------------------------------------------------
// Set or get plugin config flags.
2005-09-18 03:19:34 +00:00
public cmdPluginMode ( id , level , cid )
{
2014-05-01 02:57:59 +00:00
if ( ! cmd_access ( id , level , cid , 1 ) )
2005-09-18 03:19:34 +00:00
return PLUGIN_HANDLED
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( read_argc ( ) > 1 )
2014-05-01 03:05:32 +00:00
read_argv ( 1 , g_sBuffer , charsmax ( g_sBuffer ) )
2005-09-18 03:19:34 +00:00
else
g_sBuffer [ 0 ] = 0
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
set_plugin_mode ( id , g_sBuffer )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_HANDLED
2004-06-24 08:10:52 +00:00
}
// Display MOTD stats.
2005-09-18 03:19:34 +00:00
public cmdStatsMe ( id )
{
if ( ! SayStatsMe )
{
client_print ( id , print_chat , " %L " , id , " DISABLED_MSG " )
return PLUGIN_HANDLED
}
format_stats ( id , g_sBuffer )
2014-05-01 03:05:32 +00:00
get_user_name ( id , t_sName , charsmax ( t_sName ) )
2005-09-18 03:19:34 +00:00
show_motd ( id , g_sBuffer , t_sName )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
// Display MOTD rank.
2005-09-18 03:19:34 +00:00
public cmdRankStats ( id )
{
if ( ! SayRankStats )
{
client_print ( id , print_chat , " %L " , id , " DISABLED_MSG " )
return PLUGIN_HANDLED
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
format_rankstats ( id , g_sBuffer )
2014-05-01 03:05:32 +00:00
get_user_name ( id , t_sName , charsmax ( t_sName ) )
2005-09-18 03:19:34 +00:00
show_motd ( id , g_sBuffer , t_sName )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
// Display MOTD top15 ranked.
2005-09-18 03:19:34 +00:00
public cmdTop15 ( id )
{
if ( ! SayTop15 )
{
client_print ( id , print_chat , " %L " , id , " DISABLED_MSG " )
return PLUGIN_HANDLED
}
2014-05-01 02:57:59 +00:00
2014-05-01 12:30:42 +00:00
format_top15 ( id , g_sBuffer )
2005-09-18 03:19:34 +00:00
show_motd ( id , g_sBuffer , " Top 15 " )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
// Display killer information.
2005-09-18 03:19:34 +00:00
public cmdHp ( id )
{
if ( ! SayHP )
{
client_print ( id , print_chat , " %L " , id , " DISABLED_MSG " )
return PLUGIN_HANDLED
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
new iKiller = g_izKilled [ id ] [ KILLED_KILLER_ID ]
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
format_kill_ainfo ( id , iKiller , g_sBuffer )
client_print ( id , print_chat , " * %s " , g_sBuffer )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
// Display user stats.
2005-09-18 03:19:34 +00:00
public cmdMe ( id )
{
if ( ! SayMe )
{
client_print ( id , print_chat , " %L " , id , " DISABLED_MSG " )
return PLUGIN_HANDLED
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
format_kill_vinfo ( id , 0 , g_sBuffer )
client_print ( id , print_chat , " * %s " , g_sBuffer )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
// Display user rank
2005-09-18 03:19:34 +00:00
public cmdRank ( id )
{
if ( ! SayRank )
{
client_print ( id , print_chat , " %L " , id , " DISABLED_MSG " )
return PLUGIN_HANDLED
}
new izStats [ 8 ] , izBody [ 8 ]
new iRankPos , iRankMax
new Float : fEff , Float : fAcc
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
iRankPos = get_user_stats ( id , izStats , izBody )
iRankMax = get_statsnum ( )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
fEff = effec ( izStats )
fAcc = accuracy ( izStats )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
client_print ( id , print_chat , " * %L " , id , " YOUR_RANK_IS " , iRankPos , iRankMax , izStats [ STATS_KILLS ] , izStats [ STATS_HITS ] , fEff , fAcc )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
// Report user weapon status to team.
2005-09-18 03:19:34 +00:00
public cmdReport ( id )
{
if ( ! SayReport )
{
client_print ( id , print_chat , " %L " , id , " DISABLED_MSG " )
return PLUGIN_HANDLED
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
new iWeapon , iClip , iAmmo , iHealth , iArmor
2014-05-01 02:57:59 +00:00
iWeapon = get_user_weapon ( id , iClip , iAmmo )
2005-11-12 01:22:01 +00:00
if ( iWeapon ! = 0 )
2014-05-01 03:05:32 +00:00
xmod_get_wpnname ( iWeapon , t_sWpn , charsmax ( t_sWpn ) )
2014-05-01 02:57:59 +00:00
iHealth = get_user_health ( id )
2005-09-18 03:19:34 +00:00
iArmor = get_user_armor ( id )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
new lWeapon [ 16 ]
2014-05-01 02:57:59 +00:00
2014-05-02 11:53:25 +00:00
formatex ( lWeapon , charsmax ( lWeapon ) , " %L " , LANG_SERVER , " WEAPON " )
2005-09-18 03:19:34 +00:00
strtolower ( lWeapon )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( iClip > = 0 )
{
2014-05-01 03:05:32 +00:00
formatex ( g_sBuffer , charsmax ( g_sBuffer ) , " %s: %s, %L: %d/%d, %L: %d, %L: %d " , lWeapon , t_sWpn , LANG_SERVER , " AMMO " , iClip , iAmmo , LANG_SERVER , " HEALTH " , iHealth , LANG_SERVER , " ARMOR " , iArmor )
2005-09-18 03:19:34 +00:00
}
else
2014-05-01 03:05:32 +00:00
formatex ( g_sBuffer , charsmax ( g_sBuffer ) , " %s: %s, %L: %d, %L: %d " , lWeapon , t_sWpn [ 7 ] , LANG_SERVER , " HEALTH " , iHealth , LANG_SERVER , " ARMOR " , iArmor )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
engclient_cmd ( id , " say_team " , g_sBuffer )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2014-05-01 02:57:59 +00:00
}
2004-06-24 08:10:52 +00:00
// Display team map score
2005-09-18 03:19:34 +00:00
public cmdScore ( id )
{
if ( ! SayScore )
{
client_print ( id , print_chat , " %L " , id , " DISABLED_MSG " )
return PLUGIN_HANDLED
}
2014-05-01 02:57:59 +00:00
2014-05-01 13:08:20 +00:00
save_team_chatscore ( id , g_sScore )
2005-09-18 03:19:34 +00:00
client_print ( id , print_chat , " %L: %s " , id , " GAME_SCORE " , g_sScore )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
// Client switch to enable or disable stats announcements.
2005-09-18 03:19:34 +00:00
public cmdSwitch ( id )
{
2014-05-01 02:57:59 +00:00
g_izStatsSwitch [ id ] = ( g_izStatsSwitch [ id ] ) ? 0 : - 1
2014-05-01 03:05:32 +00:00
num_to_str ( g_izStatsSwitch [ id ] , t_sText , charsmax ( t_sText ) )
2005-09-18 03:19:34 +00:00
client_cmd ( id , " setinfo _amxstatsx %s " , t_sText )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
new lEnDis [ 32 ]
2014-05-01 02:57:59 +00:00
2014-05-02 11:53:25 +00:00
formatex ( lEnDis , charsmax ( lEnDis ) , " %L " , id , g_izStatsSwitch [ id ] ? " ENABLED " : " DISABLED " )
2005-09-18 03:19:34 +00:00
client_print ( id , print_chat , " * %L " , id , " STATS_ANNOUNCE " , lEnDis )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
// Player stats menu.
2005-09-18 03:19:34 +00:00
public cmdStats ( id )
{
if ( ! SayStatsAll )
{
client_print ( id , print_chat , " %L " , id , " DISABLED_MSG " )
return PLUGIN_HANDLED
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
showStatsMenu ( id , g_izUserMenuPosition [ id ] = 0 )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
//--------------------------------
2005-09-18 03:19:34 +00:00
// Menu
2004-06-24 08:10:52 +00:00
//--------------------------------
2005-09-18 03:19:34 +00:00
public actionStatsMenu ( id , key )
{
switch ( key )
{
// Key '1' to '7', execute action on this option
case 0. .6 :
{
new iOption , iIndex
iOption = ( g_izUserMenuPosition [ id ] * PPL_MENU_OPTIONS ) + key
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( iOption > = 0 & & iOption < 32 )
{
iIndex = g_izUserMenuPlayers [ id ] [ iOption ]
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( is_user_connected ( iIndex ) )
{
switch ( g_izUserMenuAction [ id ] )
{
case 0 : format_stats ( iIndex , g_sBuffer )
case 1 : format_rankstats ( iIndex , g_sBuffer , id )
default : g_sBuffer [ 0 ] = 0
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( g_sBuffer [ 0 ] )
{
2014-05-01 03:05:32 +00:00
get_user_name ( iIndex , t_sName , charsmax ( t_sName ) )
2005-09-18 03:19:34 +00:00
show_motd ( id , g_sBuffer , t_sName )
}
}
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
showStatsMenu ( id , g_izUserMenuPosition [ id ] )
}
// Key '8', change action
case 7 :
{
g_izUserMenuAction [ id ] + +
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( g_izUserMenuAction [ id ] > = MAX_PPL_MENU_ACTIONS )
g_izUserMenuAction [ id ] = 0
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
showStatsMenu ( id , g_izUserMenuPosition [ id ] )
}
// Key '9', select next page of options
case 8 : showStatsMenu ( id , + + g_izUserMenuPosition [ id ] )
// Key '10', cancel or go back to previous menu
case 9 :
{
if ( g_izUserMenuPosition [ id ] > 0 )
showStatsMenu ( id , - - g_izUserMenuPosition [ id ] )
}
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_HANDLED
2004-06-24 08:10:52 +00:00
}
2005-09-18 03:19:34 +00:00
new g_izUserMenuActionText [ MAX_PPL_MENU_ACTIONS ] [ ] = { " Show stats " , " Show rank stats " }
showStatsMenu ( id , iMenuPos )
{
new iLen , iKeyMask , iPlayers
new iUserIndex , iMenuPosMax , iMenuOption , iMenuOptionMax
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
get_players ( g_izUserMenuPlayers [ id ] , iPlayers )
iMenuPosMax = ( ( iPlayers - 1 ) / PPL_MENU_OPTIONS ) + 1
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
// If menu pos does not excist use last menu (if players has left)
if ( iMenuPos > = iMenuPosMax )
iMenuPos = iMenuPosMax - 1
iUserIndex = iMenuPos * PPL_MENU_OPTIONS
2014-05-01 03:05:32 +00:00
iLen = formatex ( g_sBuffer , charsmax ( g_sBuffer ) , " \ y%L \ R%d/%d^n \ w^n " , id , " SERVER_STATS " , iMenuPos + 1 , iMenuPosMax )
2005-09-18 03:19:34 +00:00
iMenuOptionMax = iPlayers - iUserIndex
2014-05-01 02:57:59 +00:00
if ( iMenuOptionMax > PPL_MENU_OPTIONS )
2005-09-18 03:19:34 +00:00
iMenuOptionMax = PPL_MENU_OPTIONS
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
for ( iMenuOption = 0 ; iMenuOption < iMenuOptionMax ; iMenuOption + + )
{
2014-05-01 03:05:32 +00:00
get_user_name ( g_izUserMenuPlayers [ id ] [ iUserIndex + + ] , t_sName , charsmax ( t_sName ) )
2005-09-18 03:19:34 +00:00
iKeyMask | = ( 1 < < iMenuOption )
2014-05-01 03:05:32 +00:00
iLen + = formatex ( g_sBuffer [ iLen ] , charsmax ( g_sBuffer ) - iLen , " %d. %s^n \ w " , iMenuOption + 1 , t_sName )
2005-09-18 03:19:34 +00:00
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
iKeyMask | = MENU_KEY_8 | MENU_KEY_0
2014-05-01 03:05:32 +00:00
iLen + = formatex ( g_sBuffer [ iLen ] , charsmax ( g_sBuffer ) - iLen , " ^n8. %s^n \ w " , g_izUserMenuActionText [ g_izUserMenuAction [ id ] ] )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( iPlayers > iUserIndex )
{
2014-05-01 03:05:32 +00:00
iLen + = formatex ( g_sBuffer [ iLen ] , charsmax ( g_sBuffer ) - iLen , " ^n9. %L... " , id , " MORE " )
2005-09-18 03:19:34 +00:00
iKeyMask | = MENU_KEY_9
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( iMenuPos > 0 )
2014-05-01 03:05:32 +00:00
iLen + = formatex ( g_sBuffer [ iLen ] , charsmax ( g_sBuffer ) - iLen , " ^n0. %L " , id , " BACK " )
2005-09-18 03:19:34 +00:00
else
2014-05-01 03:05:32 +00:00
iLen + = formatex ( g_sBuffer [ iLen ] , charsmax ( g_sBuffer ) - iLen , " ^n0. %L " , id , " EXIT " )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
show_menu ( id , iKeyMask , g_sBuffer , - 1 , " Server Stats " )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_HANDLED
2004-06-24 08:10:52 +00:00
}
//------------------------------------------------------------
2005-09-18 03:19:34 +00:00
// Plugin events
2004-06-24 08:10:52 +00:00
//------------------------------------------------------------
// Reset game stats on game start and restart.
2005-09-18 03:19:34 +00:00
public eventStartGame ( )
{
2014-05-01 03:05:32 +00:00
read_data ( 2 , t_sText , charsmax ( t_sText ) )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( t_sText [ 6 ] = = 'w' )
{
2014-05-01 03:05:32 +00:00
read_data ( 3 , t_sText , charsmax ( t_sText ) )
2005-09-18 03:19:34 +00:00
g_fStartGame = get_gametime ( ) + float ( str_to_num ( t_sText ) )
}
else
g_fStartGame = get_gametime ( )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
// Round start
2005-09-18 03:19:34 +00:00
public eventStartRound ( )
{
new iTeam , id , i
2014-05-01 02:57:59 +00:00
2014-05-01 20:30:17 +00:00
new Float : roundtime = get_pcvar_float ( g_pRoundTime )
2008-04-26 07:52:59 +00:00
if ( read_data ( 1 ) > = floatround ( roundtime * 60.0 , floatround_floor ) | | ( roundtime = = 2.3 & & read_data ( 1 ) = = 137 ) ) // these round too weird for it to work through pawn, have to add an exception for it
2005-09-18 03:19:34 +00:00
{
# if defined STATSX_DEBUG
log_amx ( " Reset round stats " )
# endif
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
// Reset game stats on game start and restart.
if ( g_fStartGame > 0.0 & & g_fStartGame < = get_gametime ( ) )
{
# if defined STATSX_DEBUG
log_amx ( " Reset game stats " )
# endif
g_fStartGame = 0.0
// Clear team and game stats.
for ( iTeam = 0 ; iTeam < MAX_TEAMS ; iTeam + + )
{
g_izTeamEventScore [ iTeam ] = 0
2014-05-01 02:57:59 +00:00
2014-10-11 15:46:29 +00:00
for ( i = 0 ; i < sizeof ( g_izTeamGameStats [ ] ) ; i + + )
2005-09-18 03:19:34 +00:00
g_izTeamGameStats [ iTeam ] [ i ] = 0
}
// Clear game stats, incl '0' that is sum of all users.
2014-07-26 15:30:45 +00:00
for ( id = 0 ; id < = MaxClients ; id + + )
2005-09-18 03:19:34 +00:00
{
2014-10-11 15:46:29 +00:00
for ( i = 0 ; i < sizeof ( g_izUserGameStats [ ] ) ; i + + )
2005-09-18 03:19:34 +00:00
g_izUserGameStats [ id ] [ i ] = 0
}
}
// Update team score with "TeamScore" event values and
// clear team round stats.
for ( iTeam = 0 ; iTeam < MAX_TEAMS ; iTeam + + )
{
g_izTeamScore [ iTeam ] = g_izTeamEventScore [ iTeam ]
2014-05-01 02:57:59 +00:00
2014-10-11 15:46:29 +00:00
for ( i = 0 ; i < sizeof ( g_izTeamRndStats [ ] ) ; i + + )
2005-09-18 03:19:34 +00:00
g_izTeamRndStats [ iTeam ] [ i ] = 0
}
// Clear user round stats, incl '0' that is sum of all users.
2014-07-26 15:30:45 +00:00
for ( id = 0 ; id < = MaxClients ; id + + )
2005-09-18 03:19:34 +00:00
{
g_izUserRndName [ id ] [ 0 ] = 0
2014-05-01 02:57:59 +00:00
2014-10-11 15:46:29 +00:00
for ( i = 0 ; i < sizeof ( g_izUserRndStats [ ] ) ; i + + )
2005-09-18 03:19:34 +00:00
g_izUserRndStats [ id ] [ i ] = 0
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
g_fzShowUserStatsTime [ id ] = 0.0
}
// Allow end round stats and reset end round triggered indicator.
g_iRoundEndTriggered = 0
g_iRoundEndProcessed = 0
g_fShowStatsTime = 0.0
// Update local configuration vars with value in cvars.
get_config_cvars ( )
}
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
// Reset killer info on round restart.
2014-05-01 20:30:17 +00:00
public eventSpawn ( id )
2005-09-18 03:19:34 +00:00
{
2014-05-02 14:59:36 +00:00
if ( ! is_user_alive ( id ) )
return HAM_IGNORED
2005-09-18 03:19:34 +00:00
new args [ 1 ]
args [ 0 ] = id
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( g_iPluginMode & MODE_HUD_DELAY )
2014-10-11 12:10:36 +00:00
set_task ( 0.1 , " delay_spawn " , 200 + id , args , sizeof ( args ) )
2005-09-18 03:19:34 +00:00
else
2014-05-01 20:30:17 +00:00
delay_spawn ( args )
2014-05-01 02:57:59 +00:00
2014-05-01 20:30:17 +00:00
return HAM_IGNORED
2004-06-24 08:10:52 +00:00
}
2014-05-01 20:30:17 +00:00
public delay_spawn ( args [ ] )
2005-09-18 03:19:34 +00:00
{
new id = args [ 0 ]
new Float : fGameTime
2014-05-01 20:30:17 +00:00
// Show user and score round stats after spawn
2005-09-18 03:19:34 +00:00
# if defined STATSX_DEBUG
2014-05-01 20:30:17 +00:00
log_amx ( " Spawn for #%d " , id )
2005-09-18 03:19:34 +00:00
# endif
fGameTime = get_gametime ( )
show_user_hudstats ( id , fGameTime )
2014-05-01 13:19:00 +00:00
if ( g_izStatsSwitch [ id ] & & g_sAwardAndScore [ 0 ] )
{
format_roundend_hudstats ( id , g_sAwardAndScore )
show_roundend_hudstats ( id , fGameTime , g_sAwardAndScore )
}
2005-09-18 03:19:34 +00:00
// Reset round stats
g_izKilled [ id ] [ KILLED_KILLER_ID ] = 0
g_izKilled [ id ] [ KILLED_KILLER_STATSFIX ] = 0
g_izShowStatsFlags [ id ] = - 1 // Initialize flags
g_fzShowUserStatsTime [ id ] = 0.0
g_izUserAttackerDistance [ id ] = 0
2014-05-01 02:57:59 +00:00
2014-07-26 14:58:30 +00:00
for ( new i = 1 ; i < = MaxClients ; i + + )
2005-09-18 03:19:34 +00:00
g_izUserVictimDistance [ id ] [ i ] = 0
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
// Save killer info on death.
2005-09-18 03:19:34 +00:00
public client_death ( killer , victim , wpnindex , hitplace , TK )
{
// Bail out if no killer.
if ( ! killer )
return PLUGIN_CONTINUE
if ( killer ! = victim )
{
new iaVOrigin [ 3 ] , iaKOrigin [ 3 ]
new iDistance
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
get_user_origin ( victim , iaVOrigin )
get_user_origin ( killer , iaKOrigin )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
g_izKilled [ victim ] [ KILLED_KILLER_ID ] = killer
g_izKilled [ victim ] [ KILLED_KILLER_HEALTH ] = get_user_health ( killer )
g_izKilled [ victim ] [ KILLED_KILLER_ARMOUR ] = get_user_armor ( killer )
g_izKilled [ victim ] [ KILLED_KILLER_STATSFIX ] = 0
iDistance = get_distance ( iaVOrigin , iaKOrigin )
g_izUserAttackerDistance [ victim ] = iDistance
g_izUserVictimDistance [ killer ] [ victim ] = iDistance
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
g_izKilled [ victim ] [ KILLED_TEAM ] = get_user_team ( victim )
g_izKilled [ victim ] [ KILLED_KILLER_STATSFIX ] = 1
// Display kill stats for the player if round
// end stats was not processed.
if ( ! g_iRoundEndProcessed )
kill_stats ( victim )
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
// Display hudmessage stats on death.
// This will also update all round and game stats.
// Must be called at least once per round.
2005-09-18 03:19:34 +00:00
kill_stats ( id )
{
2014-05-01 02:57:59 +00:00
// Bail out if user stats timer is non-zero,
2005-09-18 03:19:34 +00:00
// ie function already called.
if ( g_fzShowUserStatsTime [ id ] > 0.0 )
2006-09-25 23:04:33 +00:00
{
return
}
2014-05-01 02:57:59 +00:00
2006-09-25 23:04:33 +00:00
new team = get_user_team ( id )
if ( team < 1 | | team > 2 )
{
2005-09-18 03:19:34 +00:00
return
2006-09-25 23:04:33 +00:00
}
2005-09-18 03:19:34 +00:00
// Flag kill stats displayed for this player.
g_fzShowUserStatsTime [ id ] = get_gametime ( )
// Add user death stats to user round stats
new izStats [ 8 ] , izBody [ 8 ]
new iTeam , i
new iKiller
iKiller = g_izKilled [ id ] [ KILLED_KILLER_ID ]
// Get user's team (if dead use the saved team)
if ( iKiller )
iTeam = g_izKilled [ id ] [ KILLED_TEAM ] - 1
else
iTeam = get_user_team ( id ) - 1
2014-05-01 03:05:32 +00:00
get_user_name ( id , g_izUserRndName [ id ] , charsmax ( g_izUserRndName [ ] ) )
2005-09-18 03:19:34 +00:00
if ( get_user_rstats ( id , izStats , izBody ) )
{
// Update user's team round stats
if ( iTeam > = 0 & & iTeam < MAX_TEAMS )
{
2014-10-11 15:46:29 +00:00
for ( i = 0 ; i < sizeof ( izStats ) ; i + + )
2005-09-18 03:19:34 +00:00
{
g_izTeamRndStats [ iTeam ] [ i ] + = izStats [ i ]
g_izTeamGameStats [ iTeam ] [ i ] + = izStats [ i ]
g_izUserRndStats [ 0 ] [ i ] + = izStats [ i ]
g_izUserGameStats [ 0 ] [ i ] + = izStats [ i ]
}
}
// Update user's round stats
if ( g_izUserUserID [ id ] = = get_user_userid ( id ) )
{
2014-10-11 15:46:29 +00:00
for ( i = 0 ; i < sizeof ( izStats ) ; i + + )
2005-09-18 03:19:34 +00:00
{
g_izUserRndStats [ id ] [ i ] + = izStats [ i ]
g_izUserGameStats [ id ] [ i ] + = izStats [ i ]
}
} else {
g_izUserUserID [ id ] = get_user_userid ( id )
2014-05-01 02:57:59 +00:00
2014-10-11 15:46:29 +00:00
for ( i = 0 ; i < sizeof ( izStats ) ; i + + )
2005-09-18 03:19:34 +00:00
{
g_izUserRndStats [ id ] [ i ] = izStats [ i ]
g_izUserGameStats [ id ] [ i ] = izStats [ i ]
}
}
} // endif (get_user_rstats())
// Report stats in the chat section, if player is killed.
if ( KillerChat & & iKiller & & iKiller ! = id )
{
if ( format_kill_ainfo ( id , iKiller , g_sBuffer ) )
{
client_print ( id , print_chat , " * %s " , g_sBuffer )
format_kill_vinfo ( id , iKiller , g_sBuffer )
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
client_print ( id , print_chat , " * %s " , g_sBuffer )
}
// Display player stats info.
# if defined STATSX_DEBUG
log_amx ( " Kill stats for #%d " , id )
# endif
show_user_hudstats ( id , 0.0 )
2004-06-24 08:10:52 +00:00
}
2005-09-18 03:19:34 +00:00
public eventEndRound ( )
{
// Update local configuration vars with value in cvars.
get_config_cvars ( )
// If first end round event in the round, calculate team score.
if ( ! g_iRoundEndTriggered )
{
2014-05-01 03:05:32 +00:00
read_data ( 2 , t_sText , charsmax ( t_sText ) )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( t_sText [ 7 ] = = 't' ) // Terrorist wins
g_izTeamScore [ 0 ] + +
else if ( t_sText [ 7 ] = = 'c' ) // CT wins
g_izTeamScore [ 1 ] + +
}
set_task ( 0.3 , " ERTask " , 997 )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-10-16 17:03:53 +00:00
}
2005-09-18 03:19:34 +00:00
public ERTask ( )
{
// Flag round end triggered.
g_iRoundEndTriggered = 1
2004-07-29 14:56:47 +00:00
2005-09-18 03:19:34 +00:00
// Display round end stats to all players.
endround_stats ( )
2004-06-24 08:10:52 +00:00
}
2005-09-18 03:19:34 +00:00
endround_stats ( )
{
// Bail out if end round stats has already been processed
// or round end not triggered.
if ( g_iRoundEndProcessed | | ! g_iRoundEndTriggered )
return
2015-02-01 18:20:55 +00:00
new iaPlayers [ MAX_PLAYERS ] , iPlayer , iPlayers , id
2005-09-18 03:19:34 +00:00
get_players ( iaPlayers , iPlayers )
// Display attacker & victim list for all living players.
// This will also update all round and game stats for all players
// not killed.
# if defined STATSX_DEBUG
log_amx ( " End round stats " )
# endif
2014-05-01 02:57:59 +00:00
2014-05-01 12:56:01 +00:00
// Get and save round end stats time.
g_fShowStatsTime = get_gametime ( )
2005-09-18 03:19:34 +00:00
for ( iPlayer = 0 ; iPlayer < iPlayers ; iPlayer + + )
{
id = iaPlayers [ iPlayer ]
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( g_fzShowUserStatsTime [ id ] = = 0.0 )
2006-09-25 23:04:33 +00:00
{
2005-09-18 03:19:34 +00:00
kill_stats ( id )
2006-09-25 23:04:33 +00:00
}
2005-09-18 03:19:34 +00:00
2014-05-01 13:19:00 +00:00
if ( ! g_izStatsSwitch [ id ] )
continue
2014-05-01 12:56:01 +00:00
format_roundend_hudstats ( id , g_sAwardAndScore )
2014-05-01 12:50:07 +00:00
show_roundend_hudstats ( id , 0.0 , g_sAwardAndScore )
2005-09-18 03:19:34 +00:00
}
// Flag round end processed.
g_iRoundEndProcessed = 1
2004-06-24 08:10:52 +00:00
}
2005-09-18 03:19:34 +00:00
public eventTeamScore ( )
{
new sTeamID [ 1 + 1 ] , iTeamScore
2014-10-08 13:03:51 +00:00
read_data ( 1 , sTeamID , charsmax ( sTeamID ) )
2005-09-18 03:19:34 +00:00
iTeamScore = read_data ( 2 )
g_izTeamEventScore [ ( sTeamID [ 0 ] = = 'C' ) ? 1 : 0 ] = iTeamScore
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
2005-09-18 03:19:34 +00:00
public eventIntermission ( )
{
if ( EndPlayer | | EndTop15 )
set_task ( 1.0 , " end_game_stats " , 900 )
2004-06-24 08:10:52 +00:00
}
2005-09-18 03:19:34 +00:00
public end_game_stats ( )
{
2015-02-01 18:20:55 +00:00
new iaPlayers [ MAX_PLAYERS ] , iPlayer , iPlayers , id
2005-09-18 03:19:34 +00:00
if ( EndPlayer )
{
get_players ( iaPlayers , iPlayers )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
for ( iPlayer = 0 ; iPlayer < iPlayers ; iPlayer + + )
{
id = iaPlayers [ iPlayer ]
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( ! g_izStatsSwitch [ id ] )
continue // Do not show any stats
2014-05-01 02:57:59 +00:00
2014-05-01 12:57:35 +00:00
cmdStatsMe ( id )
2005-09-18 03:19:34 +00:00
}
}
else if ( EndTop15 )
{
get_players ( iaPlayers , iPlayers )
2014-05-01 12:30:42 +00:00
format_top15 ( 0 , g_sBuffer )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
for ( iPlayer = 0 ; iPlayer < iPlayers ; iPlayer + + )
{
id = iaPlayers [ iPlayer ]
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( ! g_izStatsSwitch [ id ] )
continue // Do not show any stats
2014-05-01 02:57:59 +00:00
2014-05-01 12:57:35 +00:00
show_motd ( id , g_sBuffer , " Top 15 " )
2005-09-18 03:19:34 +00:00
}
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
2005-09-18 03:19:34 +00:00
public eventSpecMode ( id )
{
new sData [ 12 ]
2014-10-08 13:03:51 +00:00
read_data ( 2 , sData , charsmax ( sData ) )
2005-09-18 03:19:34 +00:00
g_izSpecMode [ id ] = ( sData [ 10 ] = = '2' )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2014-05-01 02:57:59 +00:00
}
2004-06-24 08:10:52 +00:00
2005-09-18 03:19:34 +00:00
public eventShowRank ( id )
{
if ( SpecRankInfo & & g_izSpecMode [ id ] )
{
new iPlayer = read_data ( 2 )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
if ( is_user_connected ( iPlayer ) )
{
new izStats [ 8 ] , izBody [ 8 ]
new iRankPos , iRankMax
2014-05-01 02:57:59 +00:00
2014-05-01 03:05:32 +00:00
get_user_name ( iPlayer , t_sName , charsmax ( t_sName ) )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
iRankPos = get_user_stats ( iPlayer , izStats , izBody )
iRankMax = get_statsnum ( )
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
set_hudtype_specmode ( )
2007-06-28 04:25:04 +00:00
ShowSyncHudMsg ( id , g_HudSync_SpecInfo , " %L " , id , " X_RANK_IS " , t_sName , iRankPos , iRankMax )
2005-09-18 03:19:34 +00:00
}
}
2014-05-01 02:57:59 +00:00
2005-09-18 03:19:34 +00:00
return PLUGIN_CONTINUE
2004-06-24 08:10:52 +00:00
}
2005-09-18 03:19:34 +00:00
public client_connect ( id )
{
if ( ShowStats )
{
2014-05-01 03:05:32 +00:00
get_user_info ( id , " _amxstatsx " , t_sText , charsmax ( t_sText ) )
2005-09-18 03:19:34 +00:00
g_izStatsSwitch [ id ] = ( t_sText [ 0 ] ) ? str_to_num ( t_sText ) : - 1
}
else
g_izStatsSwitch [ id ] = 0
g_izKilled [ id ] [ KILLED_KILLER_ID ] = 0
g_izKilled [ id ] [ KILLED_KILLER_STATSFIX ] = 0
g_izShowStatsFlags [ id ] = 0 // Clear all flags
g_fzShowUserStatsTime [ id ] = 0.0
return PLUGIN_CONTINUE
2004-09-10 05:18:57 +00:00
}