hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.03.28. 11:33



Jelenlévő felhasználók

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

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-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  [ 15 hozzászólás ]  Oldal Előző 1 2
Szerző Üzenet
 Hozzászólás témája: Re: /rank
HozzászólásElküldve: 2014.12.31. 11:23 
Offline
Jómunkásember
Avatar

Csatlakozott: 2014.10.31. 14:51
Hozzászólások: 462
Megköszönt másnak: 73 alkalommal
Megköszönték neki: 29 alkalommal
amit attál


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.31. 11:43 
Offline
Nagyúr

Csatlakozott: 2014.05.10. 16:41
Hozzászólások: 721
Megköszönt másnak: 43 alkalommal
Megköszönték neki: 64 alkalommal
attál --> adtál*

És az nem hud, hanem motd...


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.31. 11:56 
Offline
Jómunkásember
Avatar

Csatlakozott: 2014.10.31. 14:51
Hozzászólások: 462
Megköszönt másnak: 73 alkalommal
Megköszönték neki: 29 alkalommal
meny már
akkor se kell.. chates kell.


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.31. 12:00 
Offline
Beavatott

Csatlakozott: 2014.12.30. 14:09
Hozzászólások: 94
Megköszönt másnak: 1 alkalommal
Megköszönték neki: 16 alkalommal
Be$t.# írta:
meny már
akkor se kell.. chates kell.


Átírod 2 perc alatt meg van :)

Meg nyitod a statsx.sma-t.

Legelejére:
SMA Forráskód: [ Mindet kijelol ]
  1. #include <colorchat>

Meg keresed ezt a részt:

SMA Forráskód: [ Mindet kijelol ]
  1. public cmdRank(id)
  2. {
  3. if (!SayRank)
  4. {
  5. client_print(id, print_chat, "%L", id, "DISABLED_MSG")
  6. return PLUGIN_HANDLED
  7. }
  8.  
  9. new izStats[8], izBody[8]
  10. new iRankPos, iRankMax
  11. new Float:fEff, Float:fAcc
  12.  
  13. iRankPos = get_user_stats(id, izStats, izBody)
  14. iRankMax = get_statsnum()
  15.  
  16. fEff = effec(izStats)
  17. fAcc = accuracy(izStats)
  18.  
  19. ColorChat(id, GREEN,"A te helyezésed ^3%d/%d^4 - ^3%d ^4ölés - ^3%d ^4halál -^3 %0.2f%^4 hatékonyság -^3 %0.2f%^4 pontosság.",iRankPos, iRankMax, izStats[STATS_KILLS], izStats[STATS_DEATHS], izStats[STATS_HITS], fEff, fAcc)
  20.  
  21. return PLUGIN_CONTINUE
  22. }


És bemásolod oda én ezt már szerkesztetem!

És átalakítod amxx-re berakod és kész!

_________________
https://www.youtube.com/watch?v=UAg0wCTanbM

Ők köszönték meg Hydra ツ nek ezt a hozzászólást: Be$t.# (2014.12.31. 12:16)
  Népszerűség: 2.27%


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.31. 12:31 
Offline
Nagyúr

Csatlakozott: 2014.05.10. 16:41
Hozzászólások: 721
Megköszönt másnak: 43 alkalommal
Megköszönték neki: 64 alkalommal
Tessék ^^ :)
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. ColorChat(id, RED,"A te helyezésed ^x03%d/%d^x04 - ^x03%d ^x04ölés - ^x03%d ^x04halál -^x03 %0.2f%^x04 hatékonyság -^x03 %0.2f%^x04 pontosság.",iRankPos, iRankMax, izStats[STATS_KILLS], izStats[STATS_DEATHS], izStats[STATS_HITS], fEff, fAcc)
  1060.  
  1061. return PLUGIN_CONTINUE
  1062. }
  1063.  
  1064. // Report user weapon status to team.
  1065. public cmdReport(id)
  1066. {
  1067. if (!SayReport)
  1068. {
  1069. client_print(id, print_chat, "%L", id, "DISABLED_MSG")
  1070. return PLUGIN_HANDLED
  1071. }
  1072.  
  1073. new iWeapon, iClip, iAmmo, iHealth, iArmor
  1074.  
  1075. iWeapon = get_user_weapon(id, iClip, iAmmo)
  1076.  
  1077. if (iWeapon != 0)
  1078. xmod_get_wpnname(iWeapon, t_sWpn, MAX_WEAPON_LENGTH)
  1079.  
  1080. iHealth = get_user_health(id)
  1081. iArmor = get_user_armor(id)
  1082.  
  1083. new lWeapon[16]
  1084.  
  1085. format(lWeapon, 15, "%L", id, "WEAPON")
  1086. strtolower(lWeapon)
  1087.  
  1088. if (iClip >= 0)
  1089. {
  1090. 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)
  1091. }
  1092. else
  1093. format(g_sBuffer, MAX_BUFFER_LENGTH, "%s: %s, %L: %d, %L: %d", lWeapon, t_sWpn[7], LANG_SERVER, "HEALTH", iHealth, LANG_SERVER, "ARMOR", iArmor)
  1094.  
  1095. engclient_cmd(id, "say_team", g_sBuffer)
  1096.  
  1097. return PLUGIN_CONTINUE
  1098. }
  1099.  
  1100. // Display team map score
  1101. public cmdScore(id)
  1102. {
  1103. if (!SayScore)
  1104. {
  1105. client_print(id, print_chat, "%L", id, "DISABLED_MSG")
  1106. return PLUGIN_HANDLED
  1107. }
  1108.  
  1109. client_print(id, print_chat, "%L: %s", id, "GAME_SCORE", g_sScore)
  1110.  
  1111. return PLUGIN_CONTINUE
  1112. }
  1113.  
  1114. // Client switch to enable or disable stats announcements.
  1115. public cmdSwitch(id)
  1116. {
  1117. g_izStatsSwitch[id] = (g_izStatsSwitch[id]) ? 0 : -1
  1118. num_to_str(g_izStatsSwitch[id], t_sText, MAX_TEXT_LENGTH)
  1119. client_cmd(id, "setinfo _amxstatsx %s", t_sText)
  1120.  
  1121. new lEnDis[32]
  1122.  
  1123. format(lEnDis, 31, "%L", id, g_izStatsSwitch[id] ? "ENABLED" : "DISABLED")
  1124. client_print(id, print_chat, "* %L", id, "STATS_ANNOUNCE", lEnDis)
  1125.  
  1126. return PLUGIN_CONTINUE
  1127. }
  1128.  
  1129. // Player stats menu.
  1130. public cmdStats(id)
  1131. {
  1132. if (!SayStatsAll)
  1133. {
  1134. client_print(id, print_chat, "%L", id, "DISABLED_MSG")
  1135. return PLUGIN_HANDLED
  1136. }
  1137.  
  1138. showStatsMenu(id, g_izUserMenuPosition[id] = 0)
  1139.  
  1140. return PLUGIN_CONTINUE
  1141. }
  1142.  
  1143. //--------------------------------
  1144. // Menu
  1145. //--------------------------------
  1146.  
  1147. public actionStatsMenu(id, key)
  1148. {
  1149. switch (key)
  1150. {
  1151. // Key '1' to '7', execute action on this option
  1152. case 0..6:
  1153. {
  1154. new iOption, iIndex
  1155. iOption = (g_izUserMenuPosition[id] * PPL_MENU_OPTIONS) + key
  1156.  
  1157. if (iOption >= 0 && iOption < 32)
  1158. {
  1159. iIndex = g_izUserMenuPlayers[id][iOption]
  1160.  
  1161. if (is_user_connected(iIndex))
  1162. {
  1163. switch (g_izUserMenuAction[id])
  1164. {
  1165. case 0: format_stats(iIndex, g_sBuffer)
  1166. case 1: format_rankstats(iIndex, g_sBuffer, id)
  1167. default: g_sBuffer[0] = 0
  1168. }
  1169.  
  1170. if (g_sBuffer[0])
  1171. {
  1172. get_user_name(iIndex, t_sName, MAX_NAME_LENGTH)
  1173. show_motd(id, g_sBuffer, t_sName)
  1174. }
  1175. }
  1176. }
  1177.  
  1178. showStatsMenu(id, g_izUserMenuPosition[id])
  1179. }
  1180. // Key '8', change action
  1181. case 7:
  1182. {
  1183. g_izUserMenuAction[id]++
  1184.  
  1185. if (g_izUserMenuAction[id] >= MAX_PPL_MENU_ACTIONS)
  1186. g_izUserMenuAction[id] = 0
  1187.  
  1188. showStatsMenu(id, g_izUserMenuPosition[id])
  1189. }
  1190. // Key '9', select next page of options
  1191. case 8: showStatsMenu(id, ++g_izUserMenuPosition[id])
  1192. // Key '10', cancel or go back to previous menu
  1193. case 9:
  1194. {
  1195. if (g_izUserMenuPosition[id] > 0)
  1196. showStatsMenu(id, --g_izUserMenuPosition[id])
  1197. }
  1198. }
  1199.  
  1200. return PLUGIN_HANDLED
  1201. }
  1202.  
  1203. new g_izUserMenuActionText[MAX_PPL_MENU_ACTIONS][] = {"Show stats", "Show rank stats"}
  1204.  
  1205. showStatsMenu(id, iMenuPos)
  1206. {
  1207. new iLen, iKeyMask, iPlayers
  1208. new iUserIndex, iMenuPosMax, iMenuOption, iMenuOptionMax
  1209.  
  1210. get_players(g_izUserMenuPlayers[id], iPlayers)
  1211. iMenuPosMax = ((iPlayers - 1) / PPL_MENU_OPTIONS) + 1
  1212.  
  1213. // If menu pos does not excist use last menu (if players has left)
  1214. if (iMenuPos >= iMenuPosMax)
  1215. iMenuPos = iMenuPosMax - 1
  1216.  
  1217. iUserIndex = iMenuPos * PPL_MENU_OPTIONS
  1218. iLen = format(g_sBuffer, MAX_BUFFER_LENGTH, "\y%L\R%d/%d^n\w^n", id, "SERVER_STATS", iMenuPos + 1, iMenuPosMax)
  1219. iMenuOptionMax = iPlayers - iUserIndex
  1220.  
  1221. if (iMenuOptionMax > PPL_MENU_OPTIONS)
  1222. iMenuOptionMax = PPL_MENU_OPTIONS
  1223.  
  1224. for (iMenuOption = 0; iMenuOption < iMenuOptionMax; iMenuOption++)
  1225. {
  1226. get_user_name(g_izUserMenuPlayers[id][iUserIndex++], t_sName, MAX_NAME_LENGTH)
  1227. iKeyMask |= (1<<iMenuOption)
  1228. iLen += format(g_sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%d. %s^n\w", iMenuOption + 1, t_sName)
  1229. }
  1230.  
  1231. iKeyMask |= MENU_KEY_8|MENU_KEY_0
  1232. iLen += format(g_sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "^n8. %s^n\w", g_izUserMenuActionText[g_izUserMenuAction[id]])
  1233.  
  1234. if (iPlayers > iUserIndex)
  1235. {
  1236. iLen += format(g_sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "^n9. %L...", id, "MORE")
  1237. iKeyMask |= MENU_KEY_9
  1238. }
  1239.  
  1240. if (iMenuPos > 0)
  1241. iLen += format(g_sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "^n0. %L", id, "BACK")
  1242. else
  1243. iLen += format(g_sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "^n0. %L", id, "EXIT")
  1244.  
  1245. show_menu(id, iKeyMask, g_sBuffer, -1, "Server Stats")
  1246.  
  1247. return PLUGIN_HANDLED
  1248. }
  1249.  
  1250. //------------------------------------------------------------
  1251. // Plugin events
  1252. //------------------------------------------------------------
  1253.  
  1254. // Reset game stats on game start and restart.
  1255. public eventStartGame()
  1256. {
  1257. read_data(2, t_sText, MAX_TEXT_LENGTH)
  1258.  
  1259. if (t_sText[6] == 'w')
  1260. {
  1261. read_data(3, t_sText, MAX_TEXT_LENGTH)
  1262. g_fStartGame = get_gametime() + float(str_to_num(t_sText))
  1263. }
  1264. else
  1265. g_fStartGame = get_gametime()
  1266.  
  1267. return PLUGIN_CONTINUE
  1268. }
  1269.  
  1270. // Round start
  1271. public eventStartRound()
  1272. {
  1273. new iTeam, id, i
  1274.  
  1275. new Float:roundtime = get_cvar_float("mp_roundtime");
  1276. 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
  1277. {
  1278. #if defined STATSX_DEBUG
  1279. log_amx("Reset round stats")
  1280. #endif
  1281.  
  1282. // Reset game stats on game start and restart.
  1283. if (g_fStartGame > 0.0 && g_fStartGame <= get_gametime())
  1284. {
  1285. #if defined STATSX_DEBUG
  1286. log_amx("Reset game stats")
  1287. #endif
  1288. g_fStartGame = 0.0
  1289.  
  1290. // Clear team and game stats.
  1291. for (iTeam = 0; iTeam < MAX_TEAMS; iTeam++)
  1292. {
  1293. g_izTeamEventScore[iTeam] = 0
  1294.  
  1295. for (i = 0; i < 8; i++)
  1296. g_izTeamGameStats[iTeam][i] = 0
  1297. }
  1298.  
  1299. // Clear game stats, incl '0' that is sum of all users.
  1300. for (id = 0; id < MAX_PLAYERS; id++)
  1301. {
  1302. for (i = 0; i < 8; i++)
  1303. g_izUserGameStats[id][i] = 0
  1304. }
  1305. }
  1306.  
  1307. // Update team score with "TeamScore" event values and
  1308. // clear team round stats.
  1309. for (iTeam = 0; iTeam < MAX_TEAMS; iTeam++)
  1310. {
  1311. g_izTeamScore[iTeam] = g_izTeamEventScore[iTeam]
  1312.  
  1313. for (i = 0; i < 8; i++)
  1314. g_izTeamRndStats[iTeam][i] = 0
  1315. }
  1316.  
  1317. // Clear user round stats, incl '0' that is sum of all users.
  1318. for (id = 0; id < MAX_PLAYERS; id++)
  1319. {
  1320. g_izUserRndName[id][0] = 0
  1321.  
  1322. for (i = 0; i < 8; i++)
  1323. g_izUserRndStats[id][i] = 0
  1324.  
  1325. g_fzShowUserStatsTime[id] = 0.0
  1326. }
  1327.  
  1328. // Allow end round stats and reset end round triggered indicator.
  1329. g_iRoundEndTriggered = 0
  1330. g_iRoundEndProcessed = 0
  1331. g_fShowStatsTime = 0.0
  1332.  
  1333. // Update local configuration vars with value in cvars.
  1334. get_config_cvars()
  1335. }
  1336.  
  1337. return PLUGIN_CONTINUE
  1338. }
  1339.  
  1340. // Reset killer info on round restart.
  1341. public eventResetHud(id)
  1342. {
  1343. new args[1]
  1344. args[0] = id
  1345.  
  1346. if (g_iPluginMode & MODE_HUD_DELAY)
  1347. set_task(0.01, "delay_resethud", 200 + id, args, 1)
  1348. else
  1349. delay_resethud(args)
  1350.  
  1351. return PLUGIN_CONTINUE
  1352. }
  1353.  
  1354. public delay_resethud(args[])
  1355. {
  1356. new id = args[0]
  1357. new Float:fGameTime
  1358.  
  1359. // Show user and score round stats after HUD-reset
  1360. #if defined STATSX_DEBUG
  1361. log_amx("Reset HUD for #%d", id)
  1362. #endif
  1363. fGameTime = get_gametime()
  1364. show_user_hudstats(id, fGameTime)
  1365. show_roundend_hudstats(id, fGameTime)
  1366.  
  1367. // Reset round stats
  1368. g_izKilled[id][KILLED_KILLER_ID] = 0
  1369. g_izKilled[id][KILLED_KILLER_STATSFIX] = 0
  1370. g_izShowStatsFlags[id] = -1 // Initialize flags
  1371. g_fzShowUserStatsTime[id] = 0.0
  1372. g_izUserAttackerDistance[id] = 0
  1373.  
  1374. for (new i = 0; i < MAX_PLAYERS; i++)
  1375. g_izUserVictimDistance[id][i] = 0
  1376.  
  1377. return PLUGIN_CONTINUE
  1378. }
  1379.  
  1380. // Save killer info on death.
  1381. public client_death(killer, victim, wpnindex, hitplace, TK)
  1382. {
  1383. // Bail out if no killer.
  1384. if (!killer)
  1385. return PLUGIN_CONTINUE
  1386.  
  1387. if (killer != victim)
  1388. {
  1389. new iaVOrigin[3], iaKOrigin[3]
  1390. new iDistance
  1391.  
  1392. get_user_origin(victim, iaVOrigin)
  1393. get_user_origin(killer, iaKOrigin)
  1394.  
  1395. g_izKilled[victim][KILLED_KILLER_ID] = killer
  1396. g_izKilled[victim][KILLED_KILLER_HEALTH] = get_user_health(killer)
  1397. g_izKilled[victim][KILLED_KILLER_ARMOUR] = get_user_armor(killer)
  1398. g_izKilled[victim][KILLED_KILLER_STATSFIX] = 0
  1399.  
  1400. iDistance = get_distance(iaVOrigin, iaKOrigin)
  1401. g_izUserAttackerDistance[victim] = iDistance
  1402. g_izUserVictimDistance[killer][victim] = iDistance
  1403. }
  1404.  
  1405. g_izKilled[victim][KILLED_TEAM] = get_user_team(victim)
  1406. g_izKilled[victim][KILLED_KILLER_STATSFIX] = 1
  1407.  
  1408. // Display kill stats for the player if round
  1409. // end stats was not processed.
  1410. if (!g_iRoundEndProcessed)
  1411. kill_stats(victim)
  1412.  
  1413. return PLUGIN_CONTINUE
  1414. }
  1415.  
  1416. // Display hudmessage stats on death.
  1417. // This will also update all round and game stats.
  1418. // Must be called at least once per round.
  1419. kill_stats(id)
  1420. {
  1421. // Bail out if user stats timer is non-zero,
  1422. // ie function already called.
  1423. if (g_fzShowUserStatsTime[id] > 0.0)
  1424. {
  1425. return
  1426. }
  1427.  
  1428. new team = get_user_team(id)
  1429. if (team < 1 || team > 2)
  1430. {
  1431. return
  1432. }
  1433.  
  1434. // Flag kill stats displayed for this player.
  1435. g_fzShowUserStatsTime[id] = get_gametime()
  1436.  
  1437. // Add user death stats to user round stats
  1438. new izStats[8], izBody[8]
  1439. new iTeam, i
  1440. new iKiller
  1441.  
  1442. iKiller = g_izKilled[id][KILLED_KILLER_ID]
  1443.  
  1444. // Get user's team (if dead use the saved team)
  1445. if (iKiller)
  1446. iTeam = g_izKilled[id][KILLED_TEAM] - 1
  1447. else
  1448. iTeam = get_user_team(id) - 1
  1449.  
  1450. get_user_name(id, g_izUserRndName[id], MAX_NAME_LENGTH)
  1451.  
  1452. if (get_user_rstats(id, izStats, izBody))
  1453. {
  1454. // Update user's team round stats
  1455. if (iTeam >= 0 && iTeam < MAX_TEAMS)
  1456. {
  1457. for (i = 0; i < 8; i++)
  1458. {
  1459. g_izTeamRndStats[iTeam][i] += izStats[i]
  1460. g_izTeamGameStats[iTeam][i] += izStats[i]
  1461. g_izUserRndStats[0][i] += izStats[i]
  1462. g_izUserGameStats[0][i] += izStats[i]
  1463. }
  1464. }
  1465.  
  1466. // Update user's round stats
  1467. if (g_izUserUserID[id] == get_user_userid(id))
  1468. {
  1469. for (i = 0; i < 8; i++)
  1470. {
  1471. g_izUserRndStats[id][i] += izStats[i]
  1472. g_izUserGameStats[id][i] += izStats[i]
  1473. }
  1474. } else {
  1475. g_izUserUserID[id] = get_user_userid(id)
  1476.  
  1477. for (i = 0; i < 8; i++)
  1478. {
  1479. g_izUserRndStats[id][i] = izStats[i]
  1480. g_izUserGameStats[id][i] = izStats[i]
  1481. }
  1482. }
  1483.  
  1484. } // endif (get_user_rstats())
  1485.  
  1486. // Report stats in the chat section, if player is killed.
  1487. if (KillerChat && iKiller && iKiller != id)
  1488. {
  1489. if (format_kill_ainfo(id, iKiller, g_sBuffer))
  1490. {
  1491. client_print(id, print_chat, "* %s", g_sBuffer)
  1492. format_kill_vinfo(id, iKiller, g_sBuffer)
  1493. }
  1494.  
  1495. client_print(id, print_chat, "* %s", g_sBuffer)
  1496. }
  1497.  
  1498. // Display player stats info.
  1499. #if defined STATSX_DEBUG
  1500. log_amx("Kill stats for #%d", id)
  1501. #endif
  1502. show_user_hudstats(id, 0.0)
  1503. }
  1504.  
  1505. public eventEndRound()
  1506. {
  1507. // Update local configuration vars with value in cvars.
  1508. get_config_cvars()
  1509.  
  1510. // If first end round event in the round, calculate team score.
  1511. if (!g_iRoundEndTriggered)
  1512. {
  1513. read_data(2, t_sText, MAX_TEXT_LENGTH)
  1514.  
  1515. if (t_sText[7] == 't') // Terrorist wins
  1516. g_izTeamScore[0]++
  1517. else if (t_sText[7] == 'c') // CT wins
  1518. g_izTeamScore[1]++
  1519. }
  1520.  
  1521. set_task(0.3, "ERTask", 997)
  1522.  
  1523. return PLUGIN_CONTINUE
  1524. }
  1525.  
  1526. public ERTask()
  1527. {
  1528. // Flag round end triggered.
  1529. g_iRoundEndTriggered = 1
  1530.  
  1531. // Display round end stats to all players.
  1532. endround_stats()
  1533. }
  1534.  
  1535. endround_stats()
  1536. {
  1537. // Bail out if end round stats has already been processed
  1538. // or round end not triggered.
  1539. if (g_iRoundEndProcessed || !g_iRoundEndTriggered)
  1540. return
  1541.  
  1542. new iaPlayers[32], iPlayer, iPlayers, id
  1543.  
  1544. get_players(iaPlayers, iPlayers)
  1545.  
  1546. // Display attacker & victim list for all living players.
  1547. // This will also update all round and game stats for all players
  1548. // not killed.
  1549. #if defined STATSX_DEBUG
  1550. log_amx("End round stats")
  1551. #endif
  1552.  
  1553. for (iPlayer = 0; iPlayer < iPlayers; iPlayer++)
  1554. {
  1555. id = iaPlayers[iPlayer]
  1556.  
  1557. if (g_fzShowUserStatsTime[id] == 0.0)
  1558. {
  1559. kill_stats(id)
  1560. }
  1561. }
  1562.  
  1563. g_sAwardAndScore[0] = 0
  1564.  
  1565. // Create round awards.
  1566. if (ShowMostDisruptive)
  1567. add_most_disruptive(g_sAwardAndScore)
  1568. if (ShowBestScore)
  1569. add_best_score(g_sAwardAndScore)
  1570.  
  1571. // Create round score.
  1572. // Compensate HUD message if awards are disabled.
  1573. if (ShowTeamScore || ShowTotalStats)
  1574. {
  1575. if (ShowMostDisruptive && ShowBestScore)
  1576. add(g_sAwardAndScore, MAX_BUFFER_LENGTH, "^n^n")
  1577. else if (ShowMostDisruptive || ShowBestScore)
  1578. add(g_sAwardAndScore, MAX_BUFFER_LENGTH, "^n^n^n^n")
  1579. else
  1580. add(g_sAwardAndScore, MAX_BUFFER_LENGTH, "^n^n^n^n^n^n")
  1581.  
  1582. if (ShowTeamScore)
  1583. add_team_score(g_sAwardAndScore)
  1584.  
  1585. if (ShowTotalStats)
  1586. add_total_stats(g_sAwardAndScore)
  1587. }
  1588.  
  1589. save_team_chatscore()
  1590.  
  1591. // Get and save round end stats time.
  1592. g_fShowStatsTime = get_gametime()
  1593.  
  1594. // Display round end stats to all players.
  1595. for (iPlayer = 0; iPlayer < iPlayers; iPlayer++)
  1596. {
  1597. id = iaPlayers[iPlayer]
  1598. show_roundend_hudstats(id, 0.0)
  1599. }
  1600.  
  1601. // Flag round end processed.
  1602. g_iRoundEndProcessed = 1
  1603. }
  1604.  
  1605. public eventTeamScore()
  1606. {
  1607. new sTeamID[1 + 1], iTeamScore
  1608. read_data(1, sTeamID, 1)
  1609. iTeamScore = read_data(2)
  1610. g_izTeamEventScore[(sTeamID[0] == 'C') ? 1 : 0] = iTeamScore
  1611.  
  1612. return PLUGIN_CONTINUE
  1613. }
  1614.  
  1615. public eventIntermission()
  1616. {
  1617. if (EndPlayer || EndTop15)
  1618. set_task(1.0, "end_game_stats", 900)
  1619. }
  1620.  
  1621. public end_game_stats()
  1622. {
  1623. new iaPlayers[32], iPlayer, iPlayers, id
  1624.  
  1625. if (EndPlayer)
  1626. {
  1627. get_players(iaPlayers, iPlayers)
  1628.  
  1629. for (iPlayer = 0; iPlayer < iPlayers; iPlayer++)
  1630. {
  1631. id = iaPlayers[iPlayer]
  1632.  
  1633. if (!g_izStatsSwitch[id])
  1634. continue // Do not show any stats
  1635.  
  1636. cmdStatsMe(iaPlayers[iPlayer])
  1637. }
  1638. }
  1639. else if (EndTop15)
  1640. {
  1641. get_players(iaPlayers, iPlayers)
  1642. format_top15(g_sBuffer)
  1643.  
  1644. for (iPlayer = 0; iPlayer < iPlayers; iPlayer++)
  1645. {
  1646. id = iaPlayers[iPlayer]
  1647.  
  1648. if (!g_izStatsSwitch[id])
  1649. continue // Do not show any stats
  1650.  
  1651. show_motd(iaPlayers[iPlayer], g_sBuffer, "Top 15")
  1652. }
  1653. }
  1654.  
  1655. return PLUGIN_CONTINUE
  1656. }
  1657.  
  1658. public eventSpecMode(id)
  1659. {
  1660. new sData[12]
  1661. read_data(2, sData, 11)
  1662. g_izSpecMode[id] = (sData[10] == '2')
  1663.  
  1664. return PLUGIN_CONTINUE
  1665. }
  1666.  
  1667. public eventShowRank(id)
  1668. {
  1669. if (SpecRankInfo && g_izSpecMode[id])
  1670. {
  1671. new iPlayer = read_data(2)
  1672.  
  1673. if (is_user_connected(iPlayer))
  1674. {
  1675. new izStats[8], izBody[8]
  1676. new iRankPos, iRankMax
  1677.  
  1678. get_user_name(iPlayer, t_sName, MAX_NAME_LENGTH)
  1679.  
  1680. iRankPos = get_user_stats(iPlayer, izStats, izBody)
  1681. iRankMax = get_statsnum()
  1682.  
  1683. set_hudtype_specmode()
  1684. ShowSyncHudMsg(id, g_HudSync_SpecInfo, "%L", id, "X_RANK_IS", t_sName, iRankPos, iRankMax)
  1685. }
  1686. }
  1687.  
  1688. return PLUGIN_CONTINUE
  1689. }
  1690.  
  1691. public client_connect(id)
  1692. {
  1693. if (ShowStats)
  1694. {
  1695. get_user_info(id, "_amxstatsx", t_sText, MAX_TEXT_LENGTH)
  1696. g_izStatsSwitch[id] = (t_sText[0]) ? str_to_num(t_sText) : -1
  1697. }
  1698. else
  1699. g_izStatsSwitch[id] = 0
  1700.  
  1701. g_izKilled[id][KILLED_KILLER_ID] = 0
  1702. g_izKilled[id][KILLED_KILLER_STATSFIX] = 0
  1703. g_izShowStatsFlags[id] = 0 // Clear all flags
  1704. g_fzShowUserStatsTime[id] = 0.0
  1705.  
  1706. return PLUGIN_CONTINUE
  1707. }
  1708.  

Ők köszönték meg NuD[!]e nek ezt a hozzászólást: Be$t.# (2014.12.31. 12:34)
  Népszerűség: 2.27%


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  [ 15 hozzászólás ]  Oldal Előző 1 2


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 24 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