hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2025.06.16. 12:59



Jelenlévő felhasználók

Jelenleg 334 felhasználó van jelen :: 2 regisztrált, 0 rejtett és 332 vendég

A legtöbb felhasználó (2761 fő) 2025.01.09. 20:06-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot], Google [Bot]az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása Hozzászólás a témához  [2 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Rank
HozzászólásElküldve:2014.12.02. 18:36 
Offline
Újonc

Csatlakozott:2014.12.02. 18:32
Hozzászólások:2
Sziasztok !
Ezt a plugint szeretném ha valaki meg csinálná tudom hogy lehet szerkeszteni de nem nagyon értek hozzá úgy hogy gondoltam itt segítséget kérek hogy valaki elkészítse ezt a plugint nekem :)

Kép

Aki meg csinálja megy a gomb !


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Rank
HozzászólásElküldve:2014.12.02. 19:24 
Offline
Jómunkásember
Avatar

Csatlakozott:2013.12.18. 17:35
Hozzászólások:365
Megköszönt másnak: 152 alkalommal
Megköszönték neki: 31 alkalommal
Tessék!

1062. sorban tudod szerkeszteni!

SMA Forráskód: [ Mindet kijelol ]
  1. ColorChat(0,NORMAL,"^4%s ^3helyezése ^4%d ^3a ^4%d^3-ból ^4%d ^3öléssel, ^4%d ^3találattal, ^4%0.2f% ^3effel és ^4%0.2f% ^3accal!", nev, iRankPos, iRankMax, izStats[STATS_KILLS], izStats[STATS_HITS], fEff, fAcc)



SMA Forráskód: [ Mindet kijelol ]
  1. AMX Mod X
  2. * StatsX Plugin
  3. *
  4. * by the AMX Mod X Development Team
  5. * originally developed by OLO
  6. *
  7. * This file is part of AMX Mod X.
  8. *
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at
  13. * your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software Foundation,
  22. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. *
  24. * In addition, as a special exception, the author gives permission to
  25. * link the code of this program with the Half-Life Game Engine ("HL
  26. * Engine") and Modified Game Libraries ("MODs") developed by Valve,
  27. * L.L.C ("Valve"). You must obey the GNU General Public License in all
  28. * respects for all of the code used other than the HL Engine and MODs
  29. * from Valve. If you modify this file, you may extend this exception
  30. * to your version of the file, but you are not obligated to do so. If
  31. * you do not wish to do so, delete this exception statement from your
  32. * version.
  33. */
  34.  
  35. //--------------------------------
  36. #include <amxmodx>
  37. #include <amxmisc>
  38. #include <csx>
  39. #include <colorchat>
  40. //--------------------------------
  41.  
  42. // Uncomment to activate log debug messages.
  43. //#define STATSX_DEBUG
  44.  
  45. // HUD statistics duration in seconds (minimum 1.0 seconds).
  46. #define HUD_DURATION_CVAR "amx_statsx_duration"
  47. #define HUD_DURATION "12.0"
  48.  
  49. // HUD statistics stop relative freeze end in seconds.
  50. // To stop before freeze end use a negative value.
  51. #define HUD_FREEZE_LIMIT_CVAR "amx_statsx_freeze"
  52. #define HUD_FREEZE_LIMIT "-2.0"
  53.  
  54. // HUD statistics minimum duration, in seconds, to trigger the display logic.
  55. #define HUD_MIN_DURATION 0.2
  56.  
  57. // Config plugin constants.
  58. #define MODE_HUD_DELAY 0 // Make a 0.01 sec delay on HUD reset process.
  59.  
  60. // You can also manualy enable or disable these options by setting them to 1
  61. // For example:
  62. // public ShowAttackers = 1
  63. // However amx_statscfg command is recommended
  64.  
  65. public KillerChat = 0 // displays killer hp&ap to victim console
  66. // and screen
  67.  
  68. public ShowAttackers = 0 // shows attackers
  69. public ShowVictims = 0 // shows victims
  70. public ShowKiller = 0 // shows killer
  71. public ShowTeamScore = 0 // shows team score at round end
  72. public ShowTotalStats = 0 // shows round total stats
  73. public ShowBestScore = 0 // shows rounds best scored player
  74. public ShowMostDisruptive = 0 // shows rounds most disruptive player
  75.  
  76. public EndPlayer = 0 // displays player stats at the end of map
  77. public EndTop15 = 0 // displays top15 at the end of map
  78.  
  79. public SayHP = 0 // displays information about user killer
  80. public SayStatsMe = 0 // displays user's stats and rank
  81. public SayRankStats = 0 // displays user's rank stats
  82. public SayMe = 0 // displays user's stats
  83. public SayRank = 0 // displays user's rank
  84. public SayReport = 0 // report user's weapon status to team
  85. public SayScore = 0 // displays team's map score
  86. public SayTop15 = 0 // displays first 15 players
  87. public SayStatsAll = 0 // displays all players stats and rank
  88.  
  89. public ShowStats = 1 // set client HUD-stats switched off by default
  90. public ShowDistHS = 0 // show distance and HS in attackers and
  91. // victims HUD lists
  92. public ShowFullStats = 0 // show full HUD stats (more than 78 chars)
  93.  
  94. public SpecRankInfo = 0 // displays rank info when spectating
  95.  
  96. // Standard Contstants.
  97. #define MAX_TEAMS 2
  98. #define MAX_PLAYERS 32 + 1
  99.  
  100. #define MAX_NAME_LENGTH 31
  101. #define MAX_WEAPON_LENGTH 31
  102. #define MAX_TEXT_LENGTH 255
  103. #define MAX_BUFFER_LENGTH 2047
  104.  
  105. // User stats parms id
  106. #define STATS_KILLS 0
  107. #define STATS_DEATHS 1
  108. #define STATS_HS 2
  109. #define STATS_TKS 3
  110. #define STATS_SHOTS 4
  111. #define STATS_HITS 5
  112. #define STATS_DAMAGE 6
  113.  
  114. // Global player flags.
  115. new BODY_PART[8][] =
  116. {
  117. "WHOLEBODY",
  118. "HEAD",
  119. "CHEST",
  120. "STOMACH",
  121. "LEFTARM",
  122. "RIGHTARM",
  123. "LEFTLEG",
  124. "RIGHTLEG"
  125. }
  126.  
  127. // Killer information, save killer info at the time when player is killed.
  128. #define KILLED_KILLER_ID 0 // Killer userindex/user-ID
  129. #define KILLED_KILLER_HEALTH 1 // Killer's health
  130. #define KILLED_KILLER_ARMOUR 2 // Killer's armour
  131. #define KILLED_TEAM 3 // Killer's team
  132. #define KILLED_KILLER_STATSFIX 4 // Fix to register the last hit/kill
  133.  
  134. new g_izKilled[MAX_PLAYERS][5]
  135.  
  136. // Menu variables and configuration
  137. #define MAX_PPL_MENU_ACTIONS 2 // Number of player menu actions
  138. #define PPL_MENU_OPTIONS 7 // Number of player options per displayed menu
  139.  
  140. new g_iPluginMode = 0
  141.  
  142. new g_izUserMenuPosition[MAX_PLAYERS] = {0, ...}
  143. new g_izUserMenuAction[MAX_PLAYERS] = {0, ...}
  144. new g_izUserMenuPlayers[MAX_PLAYERS][32]
  145.  
  146. new g_izSpecMode[MAX_PLAYERS] = {0, ...}
  147.  
  148. new g_izShowStatsFlags[MAX_PLAYERS] = {0, ...}
  149. new g_izStatsSwitch[MAX_PLAYERS] = {0, ...}
  150. new Float:g_fzShowUserStatsTime[MAX_PLAYERS] = {0.0, ...}
  151. new Float:g_fShowStatsTime = 0.0
  152. new Float:g_fFreezeTime = 0.0
  153. new Float:g_fFreezeLimitTime = 0.0
  154. new Float:g_fHUDDuration = 0.0
  155.  
  156. new g_iRoundEndTriggered = 0
  157. new g_iRoundEndProcessed = 0
  158.  
  159. new Float:g_fStartGame = 0.0
  160. new g_izTeamScore[MAX_TEAMS] = {0, ...}
  161. new g_izTeamEventScore[MAX_TEAMS] = {0, ...}
  162. new g_izTeamRndStats[MAX_TEAMS][8]
  163. new g_izTeamGameStats[MAX_TEAMS][8]
  164. new g_izUserUserID[MAX_PLAYERS] = {0, ...}
  165. new g_izUserAttackerDistance[MAX_PLAYERS] = {0, ...}
  166. new g_izUserVictimDistance[MAX_PLAYERS][MAX_PLAYERS]
  167. new g_izUserRndName[MAX_PLAYERS][MAX_NAME_LENGTH + 1]
  168. new g_izUserRndStats[MAX_PLAYERS][8]
  169. new g_izUserGameStats[MAX_PLAYERS][8]
  170.  
  171. // Common buffer to improve performance, as Small always zero-initializes all vars
  172. new g_sBuffer[MAX_BUFFER_LENGTH + 1] = ""
  173. new g_sScore[MAX_TEXT_LENGTH + 1] = ""
  174. new g_sAwardAndScore[MAX_BUFFER_LENGTH + 1] = ""
  175.  
  176. new t_sText[MAX_TEXT_LENGTH + 1] = ""
  177. new t_sName[MAX_NAME_LENGTH + 1] = ""
  178. new t_sWpn[MAX_WEAPON_LENGTH + 1] = ""
  179.  
  180. new g_HudSync_EndRound
  181. new g_HudSync_SpecInfo
  182.  
  183. //--------------------------------
  184. // Initialize
  185. //--------------------------------
  186. public plugin_init()
  187. {
  188. // Register plugin.
  189. register_plugin("StatsX", AMXX_VERSION_STR, "AMXX Dev Team")
  190. register_dictionary("statsx.txt")
  191.  
  192. // Register events.
  193. register_event("TextMsg", "eventStartGame", "a", "2=#Game_Commencing", "2=#Game_will_restart_in")
  194. register_event("ResetHUD", "eventResetHud", "be")
  195. register_event("RoundTime", "eventStartRound", "bc")
  196. register_event("SendAudio", "eventEndRound", "a", "2=%!MRAD_terwin", "2=%!MRAD_ctwin", "2=%!MRAD_rounddraw")
  197. register_event("TeamScore", "eventTeamScore", "a")
  198. register_event("30", "eventIntermission", "a")
  199. register_event("TextMsg", "eventSpecMode", "bd", "2&ec_Mod")
  200. register_event("StatusValue", "eventShowRank", "bd", "1=2")
  201.  
  202. // Register commands.
  203. register_clcmd("say /hp", "cmdHp", 0, "- display info. about your killer (chat)")
  204. register_clcmd("say /statsme", "cmdStatsMe", 0, "- display your stats (MOTD)")
  205. register_clcmd("say /rankstats", "cmdRankStats", 0, "- display your server stats (MOTD)")
  206. register_clcmd("say /me", "cmdMe", 0, "- display current round stats (chat)")
  207. register_clcmd("say /score", "cmdScore", 0, "- display last score (chat)")
  208. register_clcmd("say /rank", "cmdRank", 0, "- display your rank (chat)")
  209. register_clcmd("say /report", "cmdReport", 0, "- display weapon status (say_team)")
  210. register_clcmd("say /top15", "cmdTop15", 0, "- display top 15 players (MOTD)")
  211. register_clcmd("say /stats", "cmdStats", 0, "- display players stats (menu/MOTD)")
  212. register_clcmd("say /switch", "cmdSwitch", 0, "- switch client's stats on or off")
  213. register_clcmd("say_team /hp", "cmdHp", 0, "- display info. about your killer (chat)")
  214. register_clcmd("say_team /statsme", "cmdStatsMe", 0, "- display your stats (MOTD)")
  215. register_clcmd("say_team /rankstats", "cmdRankStats", 0, "- display your server stats (MOTD)")
  216. register_clcmd("say_team /me", "cmdMe", 0, "- display current round stats (chat)")
  217. register_clcmd("say_team /score", "cmdScore", 0, "- display last score (chat)")
  218. register_clcmd("say_team /rank", "cmdRank", 0, "- display your rank (chat)")
  219. register_clcmd("say_team /report", "cmdReport", 0, "- display weapon status (say_team_team)")
  220. register_clcmd("say_team /top15", "cmdTop15", 0, "- display top 15 players (MOTD)")
  221. register_clcmd("say_team /stats", "cmdStats", 0, "- display players stats (menu/MOTD)")
  222. register_clcmd("say_team /switch", "cmdSwitch", 0, "- switch client's stats on or off")
  223.  
  224. // Register menus.
  225. register_menucmd(register_menuid("Server Stats"), 1023, "actionStatsMenu")
  226.  
  227. // Register special configuration setting and default value.
  228. register_srvcmd("amx_statsx_mode", "cmdPluginMode", ADMIN_CFG, "<flags> - sets plugin options")
  229.  
  230. #if defined STATSX_DEBUG
  231. register_clcmd("say /hudtest", "cmdHudTest")
  232. #endif
  233.  
  234. register_cvar(HUD_DURATION_CVAR, HUD_DURATION)
  235. register_cvar(HUD_FREEZE_LIMIT_CVAR, HUD_FREEZE_LIMIT)
  236.  
  237. // Init buffers and some global vars.
  238. g_sBuffer[0] = 0
  239. save_team_chatscore()
  240.  
  241. g_HudSync_EndRound = CreateHudSyncObj()
  242. g_HudSync_SpecInfo = CreateHudSyncObj()
  243. }
  244.  
  245. public plugin_cfg()
  246. {
  247. new addStast[] = "amx_statscfg add ^"%s^" %s"
  248.  
  249. server_cmd(addStast, "ST_SHOW_KILLER_CHAT", "KillerChat")
  250. server_cmd(addStast, "ST_SHOW_ATTACKERS", "ShowAttackers")
  251. server_cmd(addStast, "ST_SHOW_VICTIMS", "ShowVictims")
  252. server_cmd(addStast, "ST_SHOW_KILLER", "ShowKiller")
  253. server_cmd(addStast, "ST_SHOW_TEAM_SCORE", "ShowTeamScore")
  254. server_cmd(addStast, "ST_SHOW_TOTAL_STATS", "ShowTotalStats")
  255. server_cmd(addStast, "ST_SHOW_BEST_SCORE", "ShowBestScore")
  256. server_cmd(addStast, "ST_SHOW_MOST_DISRUPTIVE", "ShowMostDisruptive")
  257. server_cmd(addStast, "ST_SHOW_HUD_STATS_DEF", "ShowStats")
  258. server_cmd(addStast, "ST_SHOW_DIST_HS_HUD", "ShowDistHS")
  259. server_cmd(addStast, "ST_STATS_PLAYER_MAP_END", "EndPlayer")
  260. server_cmd(addStast, "ST_STATS_TOP15_MAP_END", "EndTop15")
  261. server_cmd(addStast, "ST_SAY_HP", "SayHP")
  262. server_cmd(addStast, "ST_SAY_STATSME", "SayStatsMe")
  263. server_cmd(addStast, "ST_SAY_RANKSTATS", "SayRankStats")
  264. server_cmd(addStast, "ST_SAY_ME", "SayMe")
  265. server_cmd(addStast, "ST_SAY_RANK", "SayRank")
  266. server_cmd(addStast, "ST_SAY_REPORT", "SayReport")
  267. server_cmd(addStast, "ST_SAY_SCORE", "SayScore")
  268. server_cmd(addStast, "ST_SAY_TOP15", "SayTop15")
  269. server_cmd(addStast, "ST_SAY_STATS", "SayStatsAll")
  270. server_cmd(addStast, "ST_SPEC_RANK", "SpecRankInfo")
  271.  
  272. // Update local configuration vars with value in cvars.
  273. get_config_cvars()
  274. }
  275.  
  276. // Set hudmessage format.
  277. set_hudtype_killer(Float:fDuration)
  278. set_hudmessage(220, 80, 0, 0.05, 0.15, 0, 6.0, fDuration, (fDuration >= g_fHUDDuration) ? 1.0 : 0.0, 1.0, -1)
  279.  
  280. set_hudtype_endround(Float:fDuration)
  281. {
  282. set_hudmessage(100, 200, 0, 0.05, 0.55, 0, 0.02, fDuration, (fDuration >= g_fHUDDuration) ? 1.0 : 0.0, 1.0)
  283. }
  284.  
  285. set_hudtype_attacker(Float:fDuration)
  286. set_hudmessage(220, 80, 0, 0.55, 0.35, 0, 6.0, fDuration, (fDuration >= g_fHUDDuration) ? 1.0 : 0.0, 1.0, -1)
  287.  
  288. set_hudtype_victim(Float:fDuration)
  289. set_hudmessage(0, 80, 220, 0.55, 0.60, 0, 6.0, fDuration, (fDuration >= g_fHUDDuration) ? 1.0 : 0.0, 1.0, -1)
  290.  
  291. set_hudtype_specmode()
  292. {
  293. set_hudmessage(255, 255, 255, 0.02, 0.96, 2, 0.05, 0.1, 0.01, 3.0, -1)
  294. }
  295.  
  296. #if defined STATSX_DEBUG
  297. public cmdHudTest(id)
  298. {
  299. new i, iLen
  300. iLen = 0
  301.  
  302. for (i = 1; i < 20; i++)
  303. iLen += format(g_sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "....x....1....x....2....x....3....x....4....x....^n")
  304.  
  305. set_hudtype_killer(50.0)
  306. show_hudmessage(id, "%s", g_sBuffer)
  307. }
  308. #endif
  309.  
  310. // Stats formulas
  311. Float:accuracy(izStats[8])
  312. {
  313. if (!izStats[STATS_SHOTS])
  314. return (0.0)
  315.  
  316. return (100.0 * float(izStats[STATS_HITS]) / float(izStats[STATS_SHOTS]))
  317. }
  318.  
  319. Float:effec(izStats[8])
  320. {
  321. if (!izStats[STATS_KILLS])
  322. return (0.0)
  323.  
  324. return (100.0 * float(izStats[STATS_KILLS]) / float(izStats[STATS_KILLS] + izStats[STATS_DEATHS]))
  325. }
  326.  
  327. // Distance formula (metric)
  328. Float:distance(iDistance)
  329. {
  330. return float(iDistance) * 0.0254
  331. }
  332.  
  333. // Get plugin config flags.
  334. set_plugin_mode(id, sFlags[])
  335. {
  336. if (sFlags[0])
  337. g_iPluginMode = read_flags(sFlags)
  338.  
  339. get_flags(g_iPluginMode, t_sText, MAX_TEXT_LENGTH)
  340. console_print(id, "%L", id, "MODE_SET_TO", t_sText)
  341.  
  342. return g_iPluginMode
  343. }
  344.  
  345. // Get config parameters.
  346. get_config_cvars()
  347. {
  348. g_fFreezeTime = get_cvar_float("mp_freezetime")
  349.  
  350. if (g_fFreezeTime < 0.0)
  351. g_fFreezeTime = 0.0
  352.  
  353. g_fHUDDuration = get_cvar_float(HUD_DURATION_CVAR)
  354.  
  355. if (g_fHUDDuration < 1.0)
  356. g_fHUDDuration = 1.0
  357.  
  358. g_fFreezeLimitTime = get_cvar_float(HUD_FREEZE_LIMIT_CVAR)
  359. }
  360.  
  361. // Get and format attackers header and list.
  362. get_attackers(id, sBuffer[MAX_BUFFER_LENGTH + 1])
  363. {
  364. new izStats[8], izBody[8]
  365. new iAttacker
  366. new iFound, iLen
  367. new iMaxPlayer = get_maxplayers()
  368.  
  369. iFound = 0
  370. sBuffer[0] = 0
  371.  
  372. // Get and format header. Add killing attacker statistics if user is dead.
  373. // Make sure shots is greater than zero or division by zero will occur.
  374. // To print a '%', 4 of them must done in a row.
  375. izStats[STATS_SHOTS] = 0
  376. iAttacker = g_izKilled[id][KILLED_KILLER_ID]
  377.  
  378. if (iAttacker)
  379. get_user_astats(id, iAttacker, izStats, izBody)
  380.  
  381. if (izStats[STATS_SHOTS] && ShowFullStats)
  382. {
  383. get_user_name(iAttacker, t_sName, MAX_NAME_LENGTH)
  384. iLen = format(sBuffer, MAX_BUFFER_LENGTH, "%L -- %s -- %0.2f%% %L:^n", id, "ATTACKERS", t_sName, accuracy(izStats), id, "ACC")
  385. }
  386. else
  387. iLen = format(sBuffer, MAX_BUFFER_LENGTH, "%L:^n", id, "ATTACKERS")
  388.  
  389. // Get and format attacker list.
  390. for (iAttacker = 1; iAttacker <= iMaxPlayer; iAttacker++)
  391. {
  392. if (get_user_astats(id, iAttacker, izStats, izBody, t_sWpn, MAX_WEAPON_LENGTH))
  393. {
  394. iFound = 1
  395. get_user_name(iAttacker, t_sName, MAX_NAME_LENGTH)
  396.  
  397. if (izStats[STATS_KILLS])
  398. {
  399. if (!ShowDistHS)
  400. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%s -- %d %L / %d %L / %s^n", t_sName, izStats[STATS_HITS], id, "HIT_S",
  401. izStats[STATS_DAMAGE], id, "DMG", t_sWpn)
  402. else if (izStats[STATS_HS])
  403. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%s -- %d %L / %d %L / %s / %0.0f m / HS^n", t_sName, izStats[STATS_HITS], id, "HIT_S",
  404. izStats[STATS_DAMAGE], id, "DMG", t_sWpn, distance(g_izUserAttackerDistance[id]))
  405. else
  406. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%s -- %d %L / %d %L / %s / %0.0f m^n", t_sName, izStats[STATS_HITS], id, "HIT_S",
  407. izStats[STATS_DAMAGE], id, "DMG", t_sWpn, distance(g_izUserAttackerDistance[id]))
  408. }
  409. else
  410. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%s -- %d %L / %d %L^n", t_sName, izStats[STATS_HITS], id, "HIT_S", izStats[STATS_DAMAGE], id, "DMG")
  411. }
  412. }
  413.  
  414. if (!iFound)
  415. sBuffer[0] = 0
  416.  
  417. return iFound
  418. }
  419.  
  420. // Get and format victims header and list
  421. get_victims(id, sBuffer[MAX_BUFFER_LENGTH + 1])
  422. {
  423. new izStats[8], izBody[8]
  424. new iVictim
  425. new iFound, iLen
  426. new iMaxPlayer = get_maxplayers()
  427.  
  428. iFound = 0
  429. sBuffer[0] = 0
  430.  
  431. // Get and format header.
  432. // Make sure shots is greater than zero or division by zero will occur.
  433. // To print a '%', 4 of them must done in a row.
  434. izStats[STATS_SHOTS] = 0
  435. get_user_vstats(id, 0, izStats, izBody)
  436.  
  437. if (izStats[STATS_SHOTS])
  438. iLen = format(sBuffer, MAX_BUFFER_LENGTH, "%L -- %0.2f%% %L:^n", id, "VICTIMS", accuracy(izStats), id, "ACC")
  439. else
  440. iLen = format(sBuffer, MAX_BUFFER_LENGTH, "%L:^n", id, "VICTIMS")
  441.  
  442. for (iVictim = 1; iVictim <= iMaxPlayer; iVictim++)
  443. {
  444. if (get_user_vstats(id, iVictim, izStats, izBody, t_sWpn, MAX_WEAPON_LENGTH))
  445. {
  446. iFound = 1
  447. get_user_name(iVictim, t_sName, MAX_NAME_LENGTH)
  448.  
  449. if (izStats[STATS_DEATHS])
  450. {
  451. if (!ShowDistHS)
  452. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%s -- %d %L / %d %L / %s^n", t_sName, izStats[STATS_HITS], id, "HIT_S",
  453. izStats[STATS_DAMAGE], id, "DMG", t_sWpn)
  454. else if (izStats[STATS_HS])
  455. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%s -- %d %L / %d %L / %s / %0.0f m / HS^n", t_sName, izStats[STATS_HITS], id, "HIT_S",
  456. izStats[STATS_DAMAGE], id, "DMG", t_sWpn, distance(g_izUserVictimDistance[id][iVictim]))
  457. else
  458. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%s -- %d %L / %d %L / %s / %0.0f m^n", t_sName, izStats[STATS_HITS], id, "HIT_S",
  459. izStats[STATS_DAMAGE], id, "DMG", t_sWpn, distance(g_izUserVictimDistance[id][iVictim]))
  460. }
  461. else
  462. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%s -- %d %L / %d %L^n", t_sName, izStats[STATS_HITS], id, "HIT_S", izStats[STATS_DAMAGE], id, "DMG")
  463. }
  464. }
  465.  
  466. if (!iFound)
  467. sBuffer[0] = 0
  468.  
  469. return iFound
  470. }
  471.  
  472. // Get and format kill info.
  473. get_kill_info(id, iKiller, sBuffer[MAX_BUFFER_LENGTH + 1])
  474. {
  475. new iFound, iLen
  476.  
  477. iFound = 0
  478. sBuffer[0] = 0
  479.  
  480. if (iKiller && iKiller != id)
  481. {
  482. new izAStats[8], izABody[8], izVStats[8], iaVBody[8]
  483.  
  484. iFound = 1
  485. get_user_name(iKiller, t_sName, MAX_NAME_LENGTH)
  486.  
  487. izAStats[STATS_HITS] = 0
  488. izAStats[STATS_DAMAGE] = 0
  489. t_sWpn[0] = 0
  490. get_user_astats(id, iKiller, izAStats, izABody, t_sWpn, MAX_WEAPON_LENGTH)
  491.  
  492. izVStats[STATS_HITS] = 0
  493. izVStats[STATS_DAMAGE] = 0
  494. get_user_vstats(id, iKiller, izVStats, iaVBody)
  495.  
  496. iLen = format(sBuffer, MAX_BUFFER_LENGTH, "%L^n", id, "KILLED_YOU_DIST", t_sName, t_sWpn, distance(g_izUserAttackerDistance[id]))
  497. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - 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])
  498. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%L^n", id, "YOU_DID_DMG", izVStats[STATS_DAMAGE], izVStats[STATS_HITS])
  499. }
  500.  
  501. return iFound
  502. }
  503.  
  504. // Get and format most disruptive.
  505. add_most_disruptive(sBuffer[MAX_BUFFER_LENGTH + 1])
  506. {
  507. new id, iMaxDamageId, iMaxDamage, iMaxHeadShots
  508.  
  509. iMaxDamageId = 0
  510. iMaxDamage = 0
  511. iMaxHeadShots = 0
  512.  
  513. // Find player.
  514. for (id = 1; id < MAX_PLAYERS; id++)
  515. {
  516. if (g_izUserRndStats[id][STATS_DAMAGE] >= iMaxDamage && (g_izUserRndStats[id][STATS_DAMAGE] > iMaxDamage || g_izUserRndStats[id][STATS_HS] > iMaxHeadShots))
  517. {
  518. iMaxDamageId = id
  519. iMaxDamage = g_izUserRndStats[id][STATS_DAMAGE]
  520. iMaxHeadShots = g_izUserRndStats[id][STATS_HS]
  521. }
  522. }
  523.  
  524. // Format statistics.
  525. if (iMaxDamageId)
  526. {
  527. id = iMaxDamageId
  528.  
  529. new Float:fGameEff = effec(g_izUserGameStats[id])
  530. new Float:fRndAcc = accuracy(g_izUserRndStats[id])
  531.  
  532. format(t_sText, MAX_TEXT_LENGTH, "%L: %s^n%d %L / %d %L -- %0.2f%% %L / %0.2f%% %L^n", LANG_SERVER, "MOST_DMG", g_izUserRndName[id],
  533. g_izUserRndStats[id][STATS_HITS], LANG_SERVER, "HIT_S", iMaxDamage, LANG_SERVER, "DMG", fGameEff, LANG_SERVER, "EFF", fRndAcc, LANG_SERVER, "ACC")
  534. add(sBuffer, MAX_BUFFER_LENGTH, t_sText)
  535. }
  536.  
  537. return iMaxDamageId
  538. }
  539.  
  540. // Get and format best score.
  541. add_best_score(sBuffer[MAX_BUFFER_LENGTH + 1])
  542. {
  543. new id, iMaxKillsId, iMaxKills, iMaxHeadShots
  544.  
  545. iMaxKillsId = 0
  546. iMaxKills = 0
  547. iMaxHeadShots = 0
  548.  
  549. // Find player
  550. for (id = 1; id < MAX_PLAYERS; id++)
  551. {
  552. if (g_izUserRndStats[id][STATS_KILLS] >= iMaxKills && (g_izUserRndStats[id][STATS_KILLS] > iMaxKills || g_izUserRndStats[id][STATS_HS] > iMaxHeadShots))
  553. {
  554. iMaxKillsId = id
  555. iMaxKills = g_izUserRndStats[id][STATS_KILLS]
  556. iMaxHeadShots = g_izUserRndStats[id][STATS_HS]
  557. }
  558. }
  559.  
  560. // Format statistics.
  561. if (iMaxKillsId)
  562. {
  563. id = iMaxKillsId
  564.  
  565. new Float:fGameEff = effec(g_izUserGameStats[id])
  566. new Float:fRndAcc = accuracy(g_izUserRndStats[id])
  567.  
  568. format(t_sText, MAX_TEXT_LENGTH, "%L: %s^n%d %L / %d hs -- %0.2f%% %L / %0.2f%% %L^n", LANG_SERVER, "BEST_SCORE", g_izUserRndName[id],
  569. iMaxKills, LANG_SERVER, "KILL_S", iMaxHeadShots, fGameEff, LANG_SERVER, "EFF", fRndAcc, LANG_SERVER, "ACC")
  570. add(sBuffer, MAX_BUFFER_LENGTH, t_sText)
  571. }
  572.  
  573. return iMaxKillsId
  574. }
  575.  
  576. // Get and format team score.
  577. add_team_score(sBuffer[MAX_BUFFER_LENGTH + 1])
  578. {
  579. new Float:fzMapEff[MAX_TEAMS], Float:fzMapAcc[MAX_TEAMS], Float:fzRndAcc[MAX_TEAMS]
  580.  
  581. // Calculate team stats
  582. for (new iTeam = 0; iTeam < MAX_TEAMS; iTeam++)
  583. {
  584. fzMapEff[iTeam] = effec(g_izTeamGameStats[iTeam])
  585. fzMapAcc[iTeam] = accuracy(g_izTeamGameStats[iTeam])
  586. fzRndAcc[iTeam] = accuracy(g_izTeamRndStats[iTeam])
  587. }
  588.  
  589. // Format round team stats, MOTD
  590. format(t_sText, MAX_TEXT_LENGTH, "TERRORIST %d / %0.2f%% %L / %0.2f%% %L^nCT %d / %0.2f%% %L / %0.2f%% %L^n", g_izTeamScore[0],
  591. fzMapEff[0], LANG_SERVER, "EFF", fzRndAcc[0], LANG_SERVER, "ACC", g_izTeamScore[1], fzMapEff[1], LANG_SERVER, "EFF", fzRndAcc[1], LANG_SERVER, "ACC")
  592. add(sBuffer, MAX_BUFFER_LENGTH, t_sText)
  593. }
  594.  
  595. // Get and format team stats, chat version
  596. save_team_chatscore()
  597. {
  598. new Float:fzMapEff[MAX_TEAMS], Float:fzMapAcc[MAX_TEAMS], Float:fzRndAcc[MAX_TEAMS]
  599.  
  600. // Calculate team stats
  601. for (new iTeam = 0; iTeam < MAX_TEAMS; iTeam++)
  602. {
  603. fzMapEff[iTeam] = effec(g_izTeamGameStats[iTeam])
  604. fzMapAcc[iTeam] = accuracy(g_izTeamGameStats[iTeam])
  605. fzRndAcc[iTeam] = accuracy(g_izTeamRndStats[iTeam])
  606. }
  607.  
  608. // Format game team stats, chat
  609. format(g_sScore, MAX_BUFFER_LENGTH, "TERRORIST %d / %0.2f%% %L / %0.2f%% %L -- CT %d / %0.2f%% %L / %0.2f%% %L", g_izTeamScore[0],
  610. fzMapEff[0], LANG_SERVER, "EFF", fzMapAcc[0], LANG_SERVER, "ACC", g_izTeamScore[1], fzMapEff[1], LANG_SERVER, "EFF", fzMapAcc[1], LANG_SERVER, "ACC")
  611. }
  612.  
  613. // Get and format total stats.
  614. add_total_stats(sBuffer[MAX_BUFFER_LENGTH + 1])
  615. {
  616. format(t_sText, MAX_TEXT_LENGTH, "%L: %d %L / %d hs -- %d %L / %d %L^n", LANG_SERVER, "TOTAL", g_izUserRndStats[0][STATS_KILLS], LANG_SERVER, "KILL_S",
  617. g_izUserRndStats[0][STATS_HS], g_izUserRndStats[0][STATS_HITS], LANG_SERVER, "HITS", g_izUserRndStats[0][STATS_SHOTS], LANG_SERVER, "SHOT_S")
  618. add(sBuffer, MAX_BUFFER_LENGTH, t_sText)
  619. }
  620.  
  621. // Get and format a user's list of body hits from an attacker.
  622. add_attacker_hits(id, iAttacker, sBuffer[MAX_BUFFER_LENGTH + 1])
  623. {
  624. new iFound = 0
  625.  
  626. if (iAttacker && iAttacker != id)
  627. {
  628. new izStats[8], izBody[8], iLen
  629.  
  630. izStats[STATS_HITS] = 0
  631. get_user_astats(id, iAttacker, izStats, izBody)
  632.  
  633. if (izStats[STATS_HITS])
  634. {
  635. iFound = 1
  636. iLen = strlen(sBuffer)
  637. get_user_name(iAttacker, t_sName, MAX_NAME_LENGTH)
  638.  
  639. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%L:^n", id, "HITS_YOU_IN", t_sName)
  640.  
  641. for (new i = 1; i < 8; i++)
  642. {
  643. if (!izBody[i])
  644. continue
  645.  
  646. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%L: %d^n", id, BODY_PART[i], izBody[i])
  647. }
  648. }
  649. }
  650.  
  651. return iFound
  652. }
  653.  
  654. // Get and format killed stats: killer hp, ap, hits.
  655. format_kill_ainfo(id, iKiller, sBuffer[MAX_BUFFER_LENGTH + 1])
  656. {
  657. new iFound = 0
  658.  
  659. if (iKiller && iKiller != id)
  660. {
  661. new izStats[8], izBody[8]
  662. new iLen
  663.  
  664. iFound = 1
  665. get_user_name(iKiller, t_sName, MAX_NAME_LENGTH)
  666. izStats[STATS_HITS] = 0
  667. get_user_astats(id, iKiller, izStats, izBody, t_sWpn, MAX_WEAPON_LENGTH)
  668.  
  669. iLen = format(sBuffer, MAX_BUFFER_LENGTH, "%L (%dhp, %dap) >>", id, "KILLED_BY_WITH", t_sName, t_sWpn, distance(g_izUserAttackerDistance[id]),
  670. g_izKilled[id][KILLED_KILLER_HEALTH], g_izKilled[id][KILLED_KILLER_ARMOUR])
  671.  
  672. if (izStats[STATS_HITS])
  673. {
  674. for (new i = 1; i < 8; i++)
  675. {
  676. if (!izBody[i])
  677. continue
  678.  
  679. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, " %L: %d", id, BODY_PART[i], izBody[i])
  680. }
  681. }
  682. else
  683. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, " %L", id, "NO_HITS")
  684. }
  685. else
  686. format(sBuffer, MAX_BUFFER_LENGTH, "%L", id, "YOU_NO_KILLER")
  687.  
  688. return iFound
  689. }
  690.  
  691. // Get and format killed stats: hits, damage on killer.
  692. format_kill_vinfo(id, iKiller, sBuffer[MAX_BUFFER_LENGTH + 1])
  693. {
  694. new iFound = 0
  695. new izStats[8]
  696. new izBody[8]
  697. new iLen
  698.  
  699. izStats[STATS_HITS] = 0
  700. izStats[STATS_DAMAGE] = 0
  701. get_user_vstats(id, iKiller, izStats, izBody)
  702.  
  703. if (iKiller && iKiller != id)
  704. {
  705. iFound = 1
  706. get_user_name(iKiller, t_sName, MAX_NAME_LENGTH)
  707. iLen = format(sBuffer, MAX_BUFFER_LENGTH, "%L >>", id, "YOU_HIT", t_sName, izStats[STATS_HITS], izStats[STATS_DAMAGE])
  708. }
  709. else
  710. iLen = format(sBuffer, MAX_BUFFER_LENGTH, "%L >>", id, "LAST_RES", izStats[STATS_HITS], izStats[STATS_DAMAGE])
  711.  
  712. if (izStats[STATS_HITS])
  713. {
  714. for (new i = 1; i < 8; i++)
  715. {
  716. if (!izBody[i])
  717. continue
  718.  
  719. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, " %L: %d", id, BODY_PART[i], izBody[i])
  720. }
  721. }
  722. else
  723. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, " %L", id, "NO_HITS")
  724.  
  725. return iFound
  726. }
  727.  
  728. // Get and format top 15.
  729. format_top15(sBuffer[MAX_BUFFER_LENGTH + 1])
  730. {
  731. new iMax = get_statsnum()
  732. new izStats[8], izBody[8]
  733. new iLen = 0
  734.  
  735. if (iMax > 15)
  736. iMax = 15
  737.  
  738. new lKills[16], lDeaths[16], lHits[16], lShots[16], lEff[16], lAcc[16]
  739.  
  740. format(lKills, 15, "%L", LANG_SERVER, "KILLS")
  741. format(lDeaths, 15, "%L", LANG_SERVER, "DEATHS")
  742. format(lHits, 15, "%L", LANG_SERVER, "HITS")
  743. format(lShots, 15, "%L", LANG_SERVER, "SHOTS")
  744. format(lEff, 15, "%L", LANG_SERVER, "EFF")
  745. format(lAcc, 15, "%L", LANG_SERVER, "ACC")
  746.  
  747. ucfirst(lEff)
  748. ucfirst(lAcc)
  749.  
  750. iLen = format(sBuffer, MAX_BUFFER_LENGTH, "<body bgcolor=#000000><font color=#FFB000><pre>")
  751. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%2s %-22.22s %6s %6s %6s %6s %4s %4s %4s^n", "#", "Nick", lKills, lDeaths, lHits, lShots, "HS", lEff, lAcc)
  752.  
  753. for (new i = 0; i < iMax && MAX_BUFFER_LENGTH - iLen > 0; i++)
  754. {
  755. get_stats(i, izStats, izBody, t_sName, MAX_NAME_LENGTH)
  756. replace_all(t_sName, MAX_NAME_LENGTH, "<", "[")
  757. replace_all(t_sName, MAX_NAME_LENGTH, ">", "]")
  758. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%2d %-22.22s %6d %6d %6d %6d %4d %3.0f%% %3.0f%%^n", i + 1, t_sName, izStats[STATS_KILLS],
  759. izStats[STATS_DEATHS], izStats[STATS_HITS], izStats[STATS_SHOTS], izStats[STATS_HS], effec(izStats), accuracy(izStats))
  760. }
  761. }
  762.  
  763. // Get and format rank stats.
  764. format_rankstats(id, sBuffer[MAX_BUFFER_LENGTH + 1], iMyId = 0)
  765. {
  766. new izStats[8] = {0, ...}
  767. new izBody[8]
  768. new iRankPos, iLen
  769. new lKills[16], lDeaths[16], lHits[16], lShots[16], lDamage[16], lEff[16], lAcc[16]
  770.  
  771. format(lKills, 15, "%L", id, "KILLS")
  772. format(lDeaths, 15, "%L", id, "DEATHS")
  773. format(lHits, 15, "%L", id, "HITS")
  774. format(lShots, 15, "%L", id, "SHOTS")
  775. format(lDamage, 15, "%L", id, "DAMAGE")
  776. format(lEff, 15, "%L", id, "EFF")
  777. format(lAcc, 15, "%L", id, "ACC")
  778.  
  779. ucfirst(lEff)
  780. ucfirst(lAcc)
  781.  
  782. iRankPos = get_user_stats(id, izStats, izBody)
  783. iLen = format(sBuffer, MAX_BUFFER_LENGTH, "<body bgcolor=#000000><font color=#FFB000><pre>")
  784. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%L %L^n^n", id, (!iMyId || iMyId == id) ? "YOUR" : "PLAYERS", id, "RANK_IS", iRankPos, get_statsnum())
  785. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - 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",
  786. lKills, izStats[STATS_KILLS], izStats[STATS_HS], lDeaths, izStats[STATS_DEATHS], lHits, izStats[STATS_HITS], lShots, izStats[STATS_SHOTS],
  787. lDamage, izStats[STATS_DAMAGE], lEff, effec(izStats), lAcc, accuracy(izStats))
  788.  
  789. new L_BODY_PART[8][32]
  790.  
  791. for (new i = 1; i < 8; i++)
  792. {
  793. format(L_BODY_PART[i], 31, "%L", id, BODY_PART[i])
  794. }
  795.  
  796. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%10s:^n%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d", "HITS",
  797. 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],
  798. izBody[5], L_BODY_PART[6], izBody[6], L_BODY_PART[7], izBody[7])
  799. }
  800.  
  801. // Get and format stats.
  802. format_stats(id, sBuffer[MAX_BUFFER_LENGTH + 1])
  803. {
  804. new izStats[8] = {0, ...}
  805. new izBody[8]
  806. new iWeapon, iLen
  807. new lKills[16], lDeaths[16], lHits[16], lShots[16], lDamage[16], lEff[16], lAcc[16], lWeapon[16]
  808.  
  809. format(lKills, 15, "%L", id, "KILLS")
  810. format(lDeaths, 15, "%L", id, "DEATHS")
  811. format(lHits, 15, "%L", id, "HITS")
  812. format(lShots, 15, "%L", id, "SHOTS")
  813. format(lDamage, 15, "%L", id, "DAMAGE")
  814. format(lEff, 15, "%L", id, "EFF")
  815. format(lAcc, 15, "%L", id, "ACC")
  816. format(lWeapon, 15, "%L", id, "WEAPON")
  817.  
  818. ucfirst(lEff)
  819. ucfirst(lAcc)
  820.  
  821. get_user_wstats(id, 0, izStats, izBody)
  822.  
  823. iLen = format(sBuffer, MAX_BUFFER_LENGTH, "<body bgcolor=#000000><font color=#FFB000><pre>")
  824. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - 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",
  825. lKills, izStats[STATS_KILLS], izStats[STATS_HS], lDeaths, izStats[STATS_DEATHS], lHits, izStats[STATS_HITS], lShots, izStats[STATS_SHOTS],
  826. lDamage, izStats[STATS_DAMAGE], lEff, effec(izStats), lAcc, accuracy(izStats))
  827. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%-12.12s %6s %6s %6s %6s %6s %4s^n", lWeapon, lKills, lDeaths, lHits, lShots, lDamage, lAcc)
  828.  
  829. for (iWeapon = 1; iWeapon < xmod_get_maxweapons() && MAX_BUFFER_LENGTH - iLen > 0 ; iWeapon++)
  830. {
  831. if (get_user_wstats(id, iWeapon, izStats, izBody))
  832. {
  833. xmod_get_wpnname(iWeapon, t_sWpn, MAX_WEAPON_LENGTH)
  834. iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%-12.12s %6d %6d %6d %6d %6d %3.0f%%^n", t_sWpn, izStats[STATS_KILLS], izStats[STATS_DEATHS],
  835. izStats[STATS_HITS], izStats[STATS_SHOTS], izStats[STATS_DAMAGE], accuracy(izStats))
  836. }
  837. }
  838. }
  839.  
  840. // Show round end stats. If gametime is zero then use default duration time.
  841. show_roundend_hudstats(id, Float:fGameTime)
  842. {
  843. // Bail out if there no HUD stats should be shown
  844. // for this player or end round stats not created.
  845. if (!g_izStatsSwitch[id]) return
  846. if (!g_sAwardAndScore[0]) return
  847.  
  848. // If round end timer is zero clear round end stats.
  849. if (g_fShowStatsTime == 0.0)
  850. {
  851. ClearSyncHud(id, g_HudSync_EndRound)
  852. #if defined STATSX_DEBUG
  853. log_amx("Clear round end HUD stats for #%d", id)
  854. #endif
  855. }
  856.  
  857. // Set HUD-duration to default or remaining time.
  858. new Float:fDuration
  859.  
  860. if (fGameTime == 0.0)
  861. fDuration = g_fHUDDuration
  862. else
  863. {
  864. fDuration = g_fShowStatsTime + g_fHUDDuration - fGameTime
  865.  
  866. if (fDuration > g_fFreezeTime + g_fFreezeLimitTime)
  867. fDuration = g_fFreezeTime + g_fFreezeLimitTime
  868. }
  869.  
  870. // Show stats only if more time left than coded minimum.
  871. if (fDuration >= HUD_MIN_DURATION)
  872. {
  873. set_hudtype_endround(fDuration)
  874. ShowSyncHudMsg(id, g_HudSync_EndRound, "%s", g_sAwardAndScore)
  875. #if defined STATSX_DEBUG
  876. log_amx("Show %1.2fs round end HUD stats for #%d", fDuration, id)
  877. #endif
  878. }
  879. }
  880.  
  881. // Show round end stats.
  882. show_user_hudstats(id, Float:fGameTime)
  883. {
  884. // Bail out if there no HUD stats should be shown
  885. // for this player or user stats timer is zero.
  886. if (!g_izStatsSwitch[id]) return
  887. if (g_fzShowUserStatsTime[id] == 0.0) return
  888.  
  889. // Set HUD-duration to default or remaining time.
  890. new Float:fDuration
  891.  
  892. if (fGameTime == 0.0)
  893. fDuration = g_fHUDDuration
  894. else
  895. {
  896. fDuration = g_fzShowUserStatsTime[id] + g_fHUDDuration - fGameTime
  897.  
  898. if (fDuration > g_fFreezeTime + g_fFreezeLimitTime)
  899. fDuration = g_fFreezeTime + g_fFreezeLimitTime
  900. }
  901.  
  902. // Show stats only if more time left than coded minimum.
  903. if (fDuration >= HUD_MIN_DURATION)
  904. {
  905. if (ShowKiller)
  906. {
  907. new iKiller
  908.  
  909. iKiller = g_izKilled[id][KILLED_KILLER_ID]
  910. get_kill_info(id, iKiller, g_sBuffer)
  911. add_attacker_hits(id, iKiller, g_sBuffer)
  912. set_hudtype_killer(fDuration)
  913. show_hudmessage(id, "%s", g_sBuffer)
  914. #if defined STATSX_DEBUG
  915. log_amx("Show %1.2fs %suser HUD k-stats for #%d", fDuration, g_sBuffer[0] ? "" : "no ", id)
  916. #endif
  917. }
  918.  
  919. if (ShowVictims)
  920. {
  921. get_victims(id, g_sBuffer)
  922. set_hudtype_victim(fDuration)
  923. show_hudmessage(id, "%s", g_sBuffer)
  924. #if defined STATSX_DEBUG
  925. log_amx("Show %1.2fs %suser HUD v-stats for #%d", fDuration, g_sBuffer[0] ? "" : "no ", id)
  926. #endif
  927. }
  928.  
  929. if (ShowAttackers)
  930. {
  931. get_attackers(id, g_sBuffer)
  932. set_hudtype_attacker(fDuration)
  933. show_hudmessage(id, "%s", g_sBuffer)
  934. #if defined STATSX_DEBUG
  935. log_amx("Show %1.2fs %suser HUD a-stats for #%d", fDuration, g_sBuffer[0] ? "" : "no ", id)
  936. #endif
  937. }
  938. }
  939. }
  940.  
  941. //------------------------------------------------------------
  942. // Plugin commands
  943. //------------------------------------------------------------
  944.  
  945. // Set or get plugin config flags.
  946. public cmdPluginMode(id, level, cid)
  947. {
  948. if (!cmd_access(id, level, cid, 1))
  949. return PLUGIN_HANDLED
  950.  
  951. if (read_argc() > 1)
  952. read_argv(1, g_sBuffer, MAX_BUFFER_LENGTH)
  953. else
  954. g_sBuffer[0] = 0
  955.  
  956. set_plugin_mode(id, g_sBuffer)
  957.  
  958. return PLUGIN_HANDLED
  959. }
  960.  
  961. // Display MOTD stats.
  962. public cmdStatsMe(id)
  963. {
  964. if (!SayStatsMe)
  965. {
  966. client_print(id, print_chat, "%L", id, "DISABLED_MSG")
  967. return PLUGIN_HANDLED
  968. }
  969.  
  970. format_stats(id, g_sBuffer)
  971. get_user_name(id, t_sName, MAX_NAME_LENGTH)
  972. show_motd(id, g_sBuffer, t_sName)
  973.  
  974. return PLUGIN_CONTINUE
  975. }
  976.  
  977. // Display MOTD rank.
  978. public cmdRankStats(id)
  979. {
  980. if (!SayRankStats)
  981. {
  982. client_print(id, print_chat, "%L", id, "DISABLED_MSG")
  983. return PLUGIN_HANDLED
  984. }
  985.  
  986. format_rankstats(id, g_sBuffer)
  987. get_user_name(id, t_sName, MAX_NAME_LENGTH)
  988. show_motd(id, g_sBuffer, t_sName)
  989.  
  990. return PLUGIN_CONTINUE
  991. }
  992.  
  993. // Display MOTD top15 ranked.
  994. public cmdTop15(id)
  995. {
  996. if (!SayTop15)
  997. {
  998. client_print(id, print_chat, "%L", id, "DISABLED_MSG")
  999. return PLUGIN_HANDLED
  1000. }
  1001.  
  1002. format_top15(g_sBuffer)
  1003. show_motd(id, g_sBuffer, "Top 15")
  1004.  
  1005. return PLUGIN_CONTINUE
  1006. }
  1007.  
  1008. // Display killer information.
  1009. public cmdHp(id)
  1010. {
  1011. if (!SayHP)
  1012. {
  1013. client_print(id, print_chat, "%L", id, "DISABLED_MSG")
  1014. return PLUGIN_HANDLED
  1015. }
  1016.  
  1017. new iKiller = g_izKilled[id][KILLED_KILLER_ID]
  1018.  
  1019. format_kill_ainfo(id, iKiller, g_sBuffer)
  1020. client_print(id, print_chat, "* %s", g_sBuffer)
  1021.  
  1022. return PLUGIN_CONTINUE
  1023. }
  1024.  
  1025. // Display user stats.
  1026. public cmdMe(id)
  1027. {
  1028. if (!SayMe)
  1029. {
  1030. client_print(id, print_chat, "%L", id, "DISABLED_MSG")
  1031. return PLUGIN_HANDLED
  1032. }
  1033.  
  1034. format_kill_vinfo(id, 0, g_sBuffer)
  1035. client_print(id, print_chat, "* %s", g_sBuffer)
  1036.  
  1037. return PLUGIN_CONTINUE
  1038. }
  1039.  
  1040. // Display user rank
  1041. public cmdRank(id)
  1042. {
  1043. if (!SayRank)
  1044. {
  1045. client_print(id, print_chat, "%L", id, "DISABLED_MSG")
  1046. return PLUGIN_HANDLED
  1047. }
  1048.  
  1049. new izStats[8], izBody[8]
  1050. new iRankPos, iRankMax
  1051. new Float:fEff, Float:fAcc
  1052.  
  1053. iRankPos = get_user_stats(id, izStats, izBody)
  1054. iRankMax = get_statsnum()
  1055.  
  1056. fEff = effec(izStats)
  1057. fAcc = accuracy(izStats)
  1058.  
  1059. new nev[ 32 ];
  1060. get_user_name( id, nev, 31 );
  1061.  
  1062. ColorChat(0,NORMAL,"^4%s ^3helyezése ^4%d ^3a ^4%d^3-ból ^4%d ^3öléssel, ^4%d ^3találattal, ^4%0.2f% ^3effel és ^4%0.2f% ^3accal!", nev, iRankPos, iRankMax, izStats[STATS_KILLS], izStats[STATS_HITS], fEff, fAcc)
  1063.  
  1064. return PLUGIN_CONTINUE
  1065. }
  1066.  
  1067. // Report user weapon status to team.
  1068. public cmdReport(id)
  1069. {
  1070. if (!SayReport)
  1071. {
  1072. client_print(id, print_chat, "%L", id, "DISABLED_MSG")
  1073. return PLUGIN_HANDLED
  1074. }
  1075.  
  1076. new iWeapon, iClip, iAmmo, iHealth, iArmor
  1077.  
  1078. iWeapon = get_user_weapon(id, iClip, iAmmo)
  1079.  
  1080. if (iWeapon != 0)
  1081. xmod_get_wpnname(iWeapon, t_sWpn, MAX_WEAPON_LENGTH)
  1082.  
  1083. iHealth = get_user_health(id)
  1084. iArmor = get_user_armor(id)
  1085.  
  1086. new lWeapon[16]
  1087.  
  1088. format(lWeapon, 15, "%L", id, "WEAPON")
  1089. strtolower(lWeapon)
  1090.  
  1091. if (iClip >= 0)
  1092. {
  1093. format(g_sBuffer, MAX_BUFFER_LENGTH, "%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)
  1094. }
  1095. else
  1096. format(g_sBuffer, MAX_BUFFER_LENGTH, "%s: %s, %L: %d, %L: %d", lWeapon, t_sWpn[7], LANG_SERVER, "HEALTH", iHealth, LANG_SERVER, "ARMOR", iArmor)
  1097.  
  1098. engclient_cmd(id, "say_team", g_sBuffer)
  1099.  
  1100. return PLUGIN_CONTINUE
  1101. }
  1102.  
  1103. // Display team map score
  1104. public cmdScore(id)
  1105. {
  1106. if (!SayScore)
  1107. {
  1108. client_print(id, print_chat, "%L", id, "DISABLED_MSG")
  1109. return PLUGIN_HANDLED
  1110. }
  1111.  
  1112. client_print(id, print_chat, "%L: %s", id, "GAME_SCORE", g_sScore)
  1113.  
  1114. return PLUGIN_CONTINUE
  1115. }
  1116.  
  1117. // Client switch to enable or disable stats announcements.
  1118. public cmdSwitch(id)
  1119. {
  1120. g_izStatsSwitch[id] = (g_izStatsSwitch[id]) ? 0 : -1
  1121. num_to_str(g_izStatsSwitch[id], t_sText, MAX_TEXT_LENGTH)
  1122. client_cmd(id, "setinfo _amxstatsx %s", t_sText)
  1123.  
  1124. new lEnDis[32]
  1125.  
  1126. format(lEnDis, 31, "%L", id, g_izStatsSwitch[id] ? "ENABLED" : "DISABLED")
  1127. client_print(id, print_chat, "* %L", id, "STATS_ANNOUNCE", lEnDis)
  1128.  
  1129. return PLUGIN_CONTINUE
  1130. }
  1131.  
  1132. // Player stats menu.
  1133. public cmdStats(id)
  1134. {
  1135. if (!SayStatsAll)
  1136. {
  1137. client_print(id, print_chat, "%L", id, "DISABLED_MSG")
  1138. return PLUGIN_HANDLED
  1139. }
  1140.  
  1141. showStatsMenu(id, g_izUserMenuPosition[id] = 0)
  1142.  
  1143. return PLUGIN_CONTINUE
  1144. }
  1145.  
  1146. //--------------------------------
  1147. // Menu
  1148. //--------------------------------
  1149.  
  1150. public actionStatsMenu(id, key)
  1151. {
  1152. switch (key)
  1153. {
  1154. // Key '1' to '7', execute action on this option
  1155. case 0..6:
  1156. {
  1157. new iOption, iIndex
  1158. iOption = (g_izUserMenuPosition[id] * PPL_MENU_OPTIONS) + key
  1159.  
  1160. if (iOption >= 0 && iOption < 32)
  1161. {
  1162. iIndex = g_izUserMenuPlayers[id][iOption]
  1163.  
  1164. if (is_user_connected(iIndex))
  1165. {
  1166. switch (g_izUserMenuAction[id])
  1167. {
  1168. case 0: format_stats(iIndex, g_sBuffer)
  1169. case 1: format_rankstats(iIndex, g_sBuffer, id)
  1170. default: g_sBuffer[0] = 0
  1171. }
  1172.  
  1173. if (g_sBuffer[0])
  1174. {
  1175. get_user_name(iIndex, t_sName, MAX_NAME_LENGTH)
  1176. show_motd(id, g_sBuffer, t_sName)
  1177. }
  1178. }
  1179. }
  1180.  
  1181. showStatsMenu(id, g_izUserMenuPosition[id])
  1182. }
  1183. // Key '8', change action
  1184. case 7:
  1185. {
  1186. g_izUserMenuAction[id]++
  1187.  
  1188. if (g_izUserMenuAction[id] >= MAX_PPL_MENU_ACTIONS)
  1189. g_izUserMenuAction[id] = 0
  1190.  
  1191. showStatsMenu(id, g_izUserMenuPosition[id])
  1192. }
  1193. // Key '9', select next page of options
  1194. case 8: showStatsMenu(id, ++g_izUserMenuPosition[id])
  1195. // Key '10', cancel or go back to previous menu
  1196. case 9:
  1197. {
  1198. if (g_izUserMenuPosition[id] > 0)
  1199. showStatsMenu(id, --g_izUserMenuPosition[id])
  1200. }
  1201. }
  1202.  
  1203. return PLUGIN_HANDLED
  1204. }
  1205.  
  1206. new g_izUserMenuActionText[MAX_PPL_MENU_ACTIONS][] = {"Show stats", "Show rank stats"}
  1207.  
  1208. showStatsMenu(id, iMenuPos)
  1209. {
  1210. new iLen, iKeyMask, iPlayers
  1211. new iUserIndex, iMenuPosMax, iMenuOption, iMenuOptionMax
  1212.  
  1213. get_players(g_izUserMenuPlayers[id], iPlayers)
  1214. iMenuPosMax = ((iPlayers - 1) / PPL_MENU_OPTIONS) + 1
  1215.  
  1216. // If menu pos does not excist use last menu (if players has left)
  1217. if (iMenuPos >= iMenuPosMax)
  1218. iMenuPos = iMenuPosMax - 1
  1219.  
  1220. iUserIndex = iMenuPos * PPL_MENU_OPTIONS
  1221. iLen = format(g_sBuffer, MAX_BUFFER_LENGTH, "\y%L\R%d/%d^n\w^n", id, "SERVER_STATS", iMenuPos + 1, iMenuPosMax)
  1222. iMenuOptionMax = iPlayers - iUserIndex
  1223.  
  1224. if (iMenuOptionMax > PPL_MENU_OPTIONS)
  1225. iMenuOptionMax = PPL_MENU_OPTIONS
  1226.  
  1227. for (iMenuOption = 0; iMenuOption < iMenuOptionMax; iMenuOption++)
  1228. {
  1229. get_user_name(g_izUserMenuPlayers[id][iUserIndex++], t_sName, MAX_NAME_LENGTH)
  1230. iKeyMask |= (1<<iMenuOption)
  1231. iLen += format(g_sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%d. %s^n\w", iMenuOption + 1, t_sName)
  1232. }
  1233.  
  1234. iKeyMask |= MENU_KEY_8|MENU_KEY_0
  1235. iLen += format(g_sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "^n8. %s^n\w", g_izUserMenuActionText[g_izUserMenuAction[id]])
  1236.  
  1237. if (iPlayers > iUserIndex)
  1238. {
  1239. iLen += format(g_sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "^n9. %L...", id, "MORE")
  1240. iKeyMask |= MENU_KEY_9
  1241. }
  1242.  
  1243. if (iMenuPos > 0)
  1244. iLen += format(g_sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "^n0. %L", id, "BACK")
  1245. else
  1246. iLen += format(g_sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "^n0. %L", id, "EXIT")
  1247.  
  1248. show_menu(id, iKeyMask, g_sBuffer, -1, "Server Stats")
  1249.  
  1250. return PLUGIN_HANDLED
  1251. }
  1252.  
  1253. //------------------------------------------------------------
  1254. // Plugin events
  1255. //------------------------------------------------------------
  1256.  
  1257. // Reset game stats on game start and restart.
  1258. public eventStartGame()
  1259. {
  1260. read_data(2, t_sText, MAX_TEXT_LENGTH)
  1261.  
  1262. if (t_sText[6] == 'w')
  1263. {
  1264. read_data(3, t_sText, MAX_TEXT_LENGTH)
  1265. g_fStartGame = get_gametime() + float(str_to_num(t_sText))
  1266. }
  1267. else
  1268. g_fStartGame = get_gametime()
  1269.  
  1270. return PLUGIN_CONTINUE
  1271. }
  1272.  
  1273. // Round start
  1274. public eventStartRound()
  1275. {
  1276. new iTeam, id, i
  1277.  
  1278. new Float:roundtime = get_cvar_float("mp_roundtime");
  1279. 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
  1280. {
  1281. #if defined STATSX_DEBUG
  1282. log_amx("Reset round stats")
  1283. #endif
  1284.  
  1285. // Reset game stats on game start and restart.
  1286. if (g_fStartGame > 0.0 && g_fStartGame <= get_gametime())
  1287. {
  1288. #if defined STATSX_DEBUG
  1289. log_amx("Reset game stats")
  1290. #endif
  1291. g_fStartGame = 0.0
  1292.  
  1293. // Clear team and game stats.
  1294. for (iTeam = 0; iTeam < MAX_TEAMS; iTeam++)
  1295. {
  1296. g_izTeamEventScore[iTeam] = 0
  1297.  
  1298. for (i = 0; i < 8; i++)
  1299. g_izTeamGameStats[iTeam][i] = 0
  1300. }
  1301.  
  1302. // Clear game stats, incl '0' that is sum of all users.
  1303. for (id = 0; id < MAX_PLAYERS; id++)
  1304. {
  1305. for (i = 0; i < 8; i++)
  1306. g_izUserGameStats[id][i] = 0
  1307. }
  1308. }
  1309.  
  1310. // Update team score with "TeamScore" event values and
  1311. // clear team round stats.
  1312. for (iTeam = 0; iTeam < MAX_TEAMS; iTeam++)
  1313. {
  1314. g_izTeamScore[iTeam] = g_izTeamEventScore[iTeam]
  1315.  
  1316. for (i = 0; i < 8; i++)
  1317. g_izTeamRndStats[iTeam][i] = 0
  1318. }
  1319.  
  1320. // Clear user round stats, incl '0' that is sum of all users.
  1321. for (id = 0; id < MAX_PLAYERS; id++)
  1322. {
  1323. g_izUserRndName[id][0] = 0
  1324.  
  1325. for (i = 0; i < 8; i++)
  1326. g_izUserRndStats[id][i] = 0
  1327.  
  1328. g_fzShowUserStatsTime[id] = 0.0
  1329. }
  1330.  
  1331. // Allow end round stats and reset end round triggered indicator.
  1332. g_iRoundEndTriggered = 0
  1333. g_iRoundEndProcessed = 0
  1334. g_fShowStatsTime = 0.0
  1335.  
  1336. // Update local configuration vars with value in cvars.
  1337. get_config_cvars()
  1338. }
  1339.  
  1340. return PLUGIN_CONTINUE
  1341. }
  1342.  
  1343. // Reset killer info on round restart.
  1344. public eventResetHud(id)
  1345. {
  1346. new args[1]
  1347. args[0] = id
  1348.  
  1349. if (g_iPluginMode & MODE_HUD_DELAY)
  1350. set_task(0.01, "delay_resethud", 200 + id, args, 1)
  1351. else
  1352. delay_resethud(args)
  1353.  
  1354. return PLUGIN_CONTINUE
  1355. }
  1356.  
  1357. public delay_resethud(args[])
  1358. {
  1359. new id = args[0]
  1360. new Float:fGameTime
  1361.  
  1362. // Show user and score round stats after HUD-reset
  1363. #if defined STATSX_DEBUG
  1364. log_amx("Reset HUD for #%d", id)
  1365. #endif
  1366. fGameTime = get_gametime()
  1367. show_user_hudstats(id, fGameTime)
  1368. show_roundend_hudstats(id, fGameTime)
  1369.  
  1370. // Reset round stats
  1371. g_izKilled[id][KILLED_KILLER_ID] = 0
  1372. g_izKilled[id][KILLED_KILLER_STATSFIX] = 0
  1373. g_izShowStatsFlags[id] = -1 // Initialize flags
  1374. g_fzShowUserStatsTime[id] = 0.0
  1375. g_izUserAttackerDistance[id] = 0
  1376.  
  1377. for (new i = 0; i < MAX_PLAYERS; i++)
  1378. g_izUserVictimDistance[id][i] = 0
  1379.  
  1380. return PLUGIN_CONTINUE
  1381. }
  1382.  
  1383. // Save killer info on death.
  1384. public client_death(killer, victim, wpnindex, hitplace, TK)
  1385. {
  1386. // Bail out if no killer.
  1387. if (!killer)
  1388. return PLUGIN_CONTINUE
  1389.  
  1390. if (killer != victim)
  1391. {
  1392. new iaVOrigin[3], iaKOrigin[3]
  1393. new iDistance
  1394.  
  1395. get_user_origin(victim, iaVOrigin)
  1396. get_user_origin(killer, iaKOrigin)
  1397.  
  1398. g_izKilled[victim][KILLED_KILLER_ID] = killer
  1399. g_izKilled[victim][KILLED_KILLER_HEALTH] = get_user_health(killer)
  1400. g_izKilled[victim][KILLED_KILLER_ARMOUR] = get_user_armor(killer)
  1401. g_izKilled[victim][KILLED_KILLER_STATSFIX] = 0
  1402.  
  1403. iDistance = get_distance(iaVOrigin, iaKOrigin)
  1404. g_izUserAttackerDistance[victim] = iDistance
  1405. g_izUserVictimDistance[killer][victim] = iDistance
  1406. }
  1407.  
  1408. g_izKilled[victim][KILLED_TEAM] = get_user_team(victim)
  1409. g_izKilled[victim][KILLED_KILLER_STATSFIX] = 1
  1410.  
  1411. // Display kill stats for the player if round
  1412. // end stats was not processed.
  1413. if (!g_iRoundEndProcessed)
  1414. kill_stats(victim)
  1415.  
  1416. return PLUGIN_CONTINUE
  1417. }
  1418.  
  1419. // Display hudmessage stats on death.
  1420. // This will also update all round and game stats.
  1421. // Must be called at least once per round.
  1422. kill_stats(id)
  1423. {
  1424. // Bail out if user stats timer is non-zero,
  1425. // ie function already called.
  1426. if (g_fzShowUserStatsTime[id] > 0.0)
  1427. {
  1428. return
  1429. }
  1430.  
  1431. new team = get_user_team(id)
  1432. if (team < 1 || team > 2)
  1433. {
  1434. return
  1435. }
  1436.  
  1437. // Flag kill stats displayed for this player.
  1438. g_fzShowUserStatsTime[id] = get_gametime()
  1439.  
  1440. // Add user death stats to user round stats
  1441. new izStats[8], izBody[8]
  1442. new iTeam, i
  1443. new iKiller
  1444.  
  1445. iKiller = g_izKilled[id][KILLED_KILLER_ID]
  1446.  
  1447. // Get user's team (if dead use the saved team)
  1448. if (iKiller)
  1449. iTeam = g_izKilled[id][KILLED_TEAM] - 1
  1450. else
  1451. iTeam = get_user_team(id) - 1
  1452.  
  1453. get_user_name(id, g_izUserRndName[id], MAX_NAME_LENGTH)
  1454.  
  1455. if (get_user_rstats(id, izStats, izBody))
  1456. {
  1457. // Update user's team round stats
  1458. if (iTeam >= 0 && iTeam < MAX_TEAMS)
  1459. {
  1460. for (i = 0; i < 8; i++)
  1461. {
  1462. g_izTeamRndStats[iTeam][i] += izStats[i]
  1463. g_izTeamGameStats[iTeam][i] += izStats[i]
  1464. g_izUserRndStats[0][i] += izStats[i]
  1465. g_izUserGameStats[0][i] += izStats[i]
  1466. }
  1467. }
  1468.  
  1469. // Update user's round stats
  1470. if (g_izUserUserID[id] == get_user_userid(id))
  1471. {
  1472. for (i = 0; i < 8; i++)
  1473. {
  1474. g_izUserRndStats[id][i] += izStats[i]
  1475. g_izUserGameStats[id][i] += izStats[i]
  1476. }
  1477. } else {
  1478. g_izUserUserID[id] = get_user_userid(id)
  1479.  
  1480. for (i = 0; i < 8; i++)
  1481. {
  1482. g_izUserRndStats[id][i] = izStats[i]
  1483. g_izUserGameStats[id][i] = izStats[i]
  1484. }
  1485. }
  1486.  
  1487. } // endif (get_user_rstats())
  1488.  
  1489. // Report stats in the chat section, if player is killed.
  1490. if (KillerChat && iKiller && iKiller != id)
  1491. {
  1492. if (format_kill_ainfo(id, iKiller, g_sBuffer))
  1493. {
  1494. client_print(id, print_chat, "* %s", g_sBuffer)
  1495. format_kill_vinfo(id, iKiller, g_sBuffer)
  1496. }
  1497.  
  1498. client_print(id, print_chat, "* %s", g_sBuffer)
  1499. }
  1500.  
  1501. // Display player stats info.
  1502. #if defined STATSX_DEBUG
  1503. log_amx("Kill stats for #%d", id)
  1504. #endif
  1505. show_user_hudstats(id, 0.0)
  1506. }
  1507.  
  1508. public eventEndRound()
  1509. {
  1510. // Update local configuration vars with value in cvars.
  1511. get_config_cvars()
  1512.  
  1513. // If first end round event in the round, calculate team score.
  1514. if (!g_iRoundEndTriggered)
  1515. {
  1516. read_data(2, t_sText, MAX_TEXT_LENGTH)
  1517.  
  1518. if (t_sText[7] == 't') // Terrorist wins
  1519. g_izTeamScore[0]++
  1520. else if (t_sText[7] == 'c') // CT wins
  1521. g_izTeamScore[1]++
  1522. }
  1523.  
  1524. set_task(0.3, "ERTask", 997)
  1525.  
  1526. return PLUGIN_CONTINUE
  1527. }
  1528.  
  1529. public ERTask()
  1530. {
  1531. // Flag round end triggered.
  1532. g_iRoundEndTriggered = 1
  1533.  
  1534. // Display round end stats to all players.
  1535. endround_stats()
  1536. }
  1537.  
  1538. endround_stats()
  1539. {
  1540. // Bail out if end round stats has already been processed
  1541. // or round end not triggered.
  1542. if (g_iRoundEndProcessed || !g_iRoundEndTriggered)
  1543. return
  1544.  
  1545. new iaPlayers[32], iPlayer, iPlayers, id
  1546.  
  1547. get_players(iaPlayers, iPlayers)
  1548.  
  1549. // Display attacker & victim list for all living players.
  1550. // This will also update all round and game stats for all players
  1551. // not killed.
  1552. #if defined STATSX_DEBUG
  1553. log_amx("End round stats")
  1554. #endif
  1555.  
  1556. for (iPlayer = 0; iPlayer < iPlayers; iPlayer++)
  1557. {
  1558. id = iaPlayers[iPlayer]
  1559.  
  1560. if (g_fzShowUserStatsTime[id] == 0.0)
  1561. {
  1562. kill_stats(id)
  1563. }
  1564. }
  1565.  
  1566. g_sAwardAndScore[0] = 0
  1567.  
  1568. // Create round awards.
  1569. if (ShowMostDisruptive)
  1570. add_most_disruptive(g_sAwardAndScore)
  1571. if (ShowBestScore)
  1572. add_best_score(g_sAwardAndScore)
  1573.  
  1574. // Create round score.
  1575. // Compensate HUD message if awards are disabled.
  1576. if (ShowTeamScore || ShowTotalStats)
  1577. {
  1578. if (ShowMostDisruptive && ShowBestScore)
  1579. add(g_sAwardAndScore, MAX_BUFFER_LENGTH, "^n^n")
  1580. else if (ShowMostDisruptive || ShowBestScore)
  1581. add(g_sAwardAndScore, MAX_BUFFER_LENGTH, "^n^n^n^n")
  1582. else
  1583. add(g_sAwardAndScore, MAX_BUFFER_LENGTH, "^n^n^n^n^n^n")
  1584.  
  1585. if (ShowTeamScore)
  1586. add_team_score(g_sAwardAndScore)
  1587.  
  1588. if (ShowTotalStats)
  1589. add_total_stats(g_sAwardAndScore)
  1590. }
  1591.  
  1592. save_team_chatscore()
  1593.  
  1594. // Get and save round end stats time.
  1595. g_fShowStatsTime = get_gametime()
  1596.  
  1597. // Display round end stats to all players.
  1598. for (iPlayer = 0; iPlayer < iPlayers; iPlayer++)
  1599. {
  1600. id = iaPlayers[iPlayer]
  1601. show_roundend_hudstats(id, 0.0)
  1602. }
  1603.  
  1604. // Flag round end processed.
  1605. g_iRoundEndProcessed = 1
  1606. }
  1607.  
  1608. public eventTeamScore()
  1609. {
  1610. new sTeamID[1 + 1], iTeamScore
  1611. read_data(1, sTeamID, 1)
  1612. iTeamScore = read_data(2)
  1613. g_izTeamEventScore[(sTeamID[0] == 'C') ? 1 : 0] = iTeamScore
  1614.  
  1615. return PLUGIN_CONTINUE
  1616. }
  1617.  
  1618. public eventIntermission()
  1619. {
  1620. if (EndPlayer || EndTop15)
  1621. set_task(1.0, "end_game_stats", 900)
  1622. }
  1623.  
  1624. public end_game_stats()
  1625. {
  1626. new iaPlayers[32], iPlayer, iPlayers, id
  1627.  
  1628. if (EndPlayer)
  1629. {
  1630. get_players(iaPlayers, iPlayers)
  1631.  
  1632. for (iPlayer = 0; iPlayer < iPlayers; iPlayer++)
  1633. {
  1634. id = iaPlayers[iPlayer]
  1635.  
  1636. if (!g_izStatsSwitch[id])
  1637. continue // Do not show any stats
  1638.  
  1639. cmdStatsMe(iaPlayers[iPlayer])
  1640. }
  1641. }
  1642. else if (EndTop15)
  1643. {
  1644. get_players(iaPlayers, iPlayers)
  1645. format_top15(g_sBuffer)
  1646.  
  1647. for (iPlayer = 0; iPlayer < iPlayers; iPlayer++)
  1648. {
  1649. id = iaPlayers[iPlayer]
  1650.  
  1651. if (!g_izStatsSwitch[id])
  1652. continue // Do not show any stats
  1653.  
  1654. show_motd(iaPlayers[iPlayer], g_sBuffer, "Top 15")
  1655. }
  1656. }
  1657.  
  1658. return PLUGIN_CONTINUE
  1659. }
  1660.  
  1661. public eventSpecMode(id)
  1662. {
  1663. new sData[12]
  1664. read_data(2, sData, 11)
  1665. g_izSpecMode[id] = (sData[10] == '2')
  1666.  
  1667. return PLUGIN_CONTINUE
  1668. }
  1669.  
  1670. public eventShowRank(id)
  1671. {
  1672. if (SpecRankInfo && g_izSpecMode[id])
  1673. {
  1674. new iPlayer = read_data(2)
  1675.  
  1676. if (is_user_connected(iPlayer))
  1677. {
  1678. new izStats[8], izBody[8]
  1679. new iRankPos, iRankMax
  1680.  
  1681. get_user_name(iPlayer, t_sName, MAX_NAME_LENGTH)
  1682.  
  1683. iRankPos = get_user_stats(iPlayer, izStats, izBody)
  1684. iRankMax = get_statsnum()
  1685.  
  1686. set_hudtype_specmode()
  1687. ShowSyncHudMsg(id, g_HudSync_SpecInfo, "%L", id, "X_RANK_IS", t_sName, iRankPos, iRankMax)
  1688. }
  1689. }
  1690.  
  1691. return PLUGIN_CONTINUE
  1692. }
  1693.  
  1694. public client_connect(id)
  1695. {
  1696. if (ShowStats)
  1697. {
  1698. get_user_info(id, "_amxstatsx", t_sText, MAX_TEXT_LENGTH)
  1699. g_izStatsSwitch[id] = (t_sText[0]) ? str_to_num(t_sText) : -1
  1700. }
  1701. else
  1702. g_izStatsSwitch[id] = 0
  1703.  
  1704. g_izKilled[id][KILLED_KILLER_ID] = 0
  1705. g_izKilled[id][KILLED_KILLER_STATSFIX] = 0
  1706. g_izShowStatsFlags[id] = 0 // Clear all flags
  1707. g_fzShowUserStatsTime[id] = 0.0
  1708.  
  1709. return PLUGIN_CONTINUE
  1710. }
  1711. stock print_color(const id, const input[], any:...)
  1712. {
  1713. new count = 1, players[32]
  1714. static msg[191]
  1715. vformat(msg, 190, input, 3)
  1716.  
  1717. replace_all(msg, 190, "!g", "^4")
  1718. replace_all(msg, 190, "!y", "^1")
  1719. replace_all(msg, 190, "!t", "^3")
  1720. replace_all(msg, 190, "á", "á")
  1721. replace_all(msg, 190, "é", "Ă©")
  1722. replace_all(msg, 190, "í", "Ă­")
  1723. replace_all(msg, 190, "ó", "Ăł")
  1724. replace_all(msg, 190, "ö", "ö")
  1725. replace_all(msg, 190, "ő", "Ĺ‘")
  1726. replace_all(msg, 190, "ú", "Ăş")
  1727. replace_all(msg, 190, "ü", "ĂĽ")
  1728. replace_all(msg, 190, "ű", "ű")
  1729. replace_all(msg, 190, "Á", "Á")
  1730. replace_all(msg, 190, "É", "É")
  1731. replace_all(msg, 190, "Í", "ĂŤ")
  1732. replace_all(msg, 190, "Ó", "Ă“")
  1733. replace_all(msg, 190, "Ö", "Ă–")
  1734. replace_all(msg, 190, "Ő", "Ő")
  1735. replace_all(msg, 190, "Ú", "Ăš")
  1736. replace_all(msg, 190, "Ü", "Ăś")
  1737. replace_all(msg, 190, "Ű", "Ű")
  1738.  
  1739. if (id) players[0] = id; else get_players(players, count, "ch")
  1740. {
  1741. for (new i = 0; i < count; i++)
  1742. {
  1743. if (is_user_connected(players[i]))
  1744. {
  1745. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
  1746. write_byte(players[i])
  1747. write_string(msg)
  1748. message_end()
  1749. }
  1750. }
  1751. }
  1752. return PLUGIN_HANDLED
  1753. }

 

_________________
Ha segítettem használd a gombot!

Kép
KépKép


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése: Rendezés 
Új téma nyitása Hozzászólás a témához  [2 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 6 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole