搜索
查看: 1918|回复: 0

如何在另一個排名插件上新增命中率與生存率

[复制链接]
发表于 2007-6-7 00:14:41 | 显示全部楼层 |阅读模式 来自 中国–香港
請問如何在此插件上新增命中率與生存率?
已知官方插件其兩條公式
// Stats formulas
Float:accuracy( izStats[8] ) {
  if ( !izStats[STATS_SHOTS] ) return ( 0.0 )
  return ( 100.0 * float( izStats[STATS_HITS] ) / float( izStats[STATS_SHOTS] ) )
}
Float:effec( izStats[8] ) {
  if ( !izStats[STATS_KILLS] ) return ( 0.0 )
  return ( 100.0 * float( izStats[STATS_KILLS] ) / float( izStats[STATS_KILLS] + izStats[STATS_DEATHS] ) )
}
然而想修改的插件碼如下
感謝幫助.
  1. /* AMX Mod X
  2. *   CS Stats 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. *  Modifications by: skywalker
  35. *
  36. *  Chinese version by: skywalker
  37. */
  38. #include <amxmodx>
  39. #include <amxmisc>
  40. #include <csstats>
  41. // You can also manualy enable these options by setting them to 1
  42. // For example:
  43. // public ShowAttackers = 1
  44. // However amx_statscfg command is recommended
  45. public ShowAttackers      // shows attackers
  46. public ShowVictims        // shows victims
  47. public ShowKiller         // shows killer
  48. public EndPlayer          // displays player stats at the end of map
  49. public EndTop15           // displays top15 at the end of map
  50. public KillerHpAp         // displays killer hp&ap to victim console and screen
  51. public SpecRankInfo       // displays rank info when spectating
  52. public SayHP              // displays information about user killer
  53. public SayStatsAll        // displays players stats and rank
  54. public SayTop15           // displays first 15. players
  55. public SayRank            // displays user position in rank
  56. public SayStatsMe         // displays user stats
  57. public EndTeamScore       // displays at the end of round team score
  58. public EndMostKills       // displays at the end of who made most kills
  59. public EndMostDamage      // displays at the end of who made most damage
  60. new g_Killers[33][4]
  61. new g_Buffer[2048]
  62. new g_userPosition[33]
  63. new g_userszszState[33]
  64. new g_userPlayers[33][32]
  65. new g_bodyParts[8][] = {"全身","頭部","胸部","腹部","左臂","右臂","左腿","右腿"}
  66. new bool:g_specMode[33]
  67. new g_teamScore[2]
  68. new g_disabledMsg[] = "伺服器禁止了這個參數"
  69. public plugin_init() {
  70. register_plugin("CS Stats","0.16","AMXX Dev Team")
  71. register_event("CS_DeathMsg","eCSDeathMsg","a")
  72. register_event("ResetHUD","eResetHud","b")
  73. register_event("SendAudio","eRoundEnd","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
  74. register_event("30","eInterMission","a")
  75. register_clcmd("say /hp","cmdKiller",0,"- 顯示殺你的人的狀況")
  76. register_clcmd("say /statsme","cmdStatsMe",0,"- 顯示你的系統")
  77. register_clcmd("say /stats","cmdStats",0,"- 顯示其他人的數據統計")
  78. register_clcmd("say /top15","cmdTop15",0,"- 顯示排名榜前15名")
  79. register_clcmd("say /rank","cmdRank",0,"- 顯示你在這伺服器上的排名情况")
  80. register_menucmd(register_menuid("Server Stats"),1023,"actionStatsMenu")
  81. register_event("TextMsg","setSpecMode","bd","2&ec_Mod")
  82. register_event("StatusValue","showRank","bd","1=2")
  83. register_event( "TeamScore", "eTeamScore", "a" )
  84. }
  85. public plugin_cfg(){
  86. new g_addStast[] = "amx_statscfg add ^"%s^" %s"
  87. server_cmd(g_addStast,"Show Attackers","ShowAttackers")
  88. server_cmd(g_addStast,"Show Victims","ShowVictims")
  89. server_cmd(g_addStast,"Show killer","ShowKiller")
  90. server_cmd(g_addStast,"Stats at the end of map","EndPlayer")  
  91. server_cmd(g_addStast,"Top15 at the end of map","EndTop15")  
  92. server_cmd(g_addStast,"Show killer hp&ap","KillerHpAp")
  93. server_cmd(g_addStast,"Say /hp","SayHP")  
  94. server_cmd(g_addStast,"Say /stats","SayStatsAll")
  95. server_cmd(g_addStast,"Say /top15","SayTop15")
  96. server_cmd(g_addStast,"Say /rank","SayRank")
  97. server_cmd(g_addStast,"Say /statsme","SayStatsMe")
  98. server_cmd(g_addStast,"Spec. Rank Info","SpecRankInfo")
  99. server_cmd(g_addStast,"Team Score","EndTeamScore")
  100. server_cmd(g_addStast,"Most Kills","EndMostKills")
  101. server_cmd(g_addStast,"Most Damage","EndMostDamage")  
  102. }
  103. public eTeamScore(){
  104. new team[2]
  105. read_data( 1, team, 1 )
  106. g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
  107. }
  108. public setSpecMode(id) {
  109. new arg[12]
  110. read_data( 2 , arg , 11 )
  111. g_specMode[ id ] = ( arg[10] == '2' )
  112. }
  113. public showRank(id)
  114. if ( SpecRankInfo && g_specMode[id] ){
  115. new a = read_data(2)
  116. if ( is_user_connected( a ) ){
  117.   new name[32], data[8]
  118.   get_user_name( a ,name,31)
  119.   new pos = get_user_stats( a ,data,data)
  120.   set_hudmessage(255,255,255,0.02,0.85,2, 0.05, 0.1, 0.01, 3.0, 1)
  121.   show_hudmessage(id,"%s的名次是 %d人中排第 %d",name,get_statsnum(),pos)
  122. }
  123. }
  124. /* build list of attackers */
  125. getAttackers(id) {
  126. new name[32],wpn[32], stats[8],body[8],found=0
  127. new pos = copy(g_Buffer,2047,"Attackers:^n")
  128. new amax = get_maxplayers()
  129. for(new a = 1; a <= amax; ++a){
  130.   if(get_user_astats(id,a,stats,body,wpn,31)){
  131.    found = 1
  132.    if (stats[0])
  133.     format(wpn,31," -- %s",wpn)
  134.    else
  135.     wpn[0] = 0
  136.    get_user_name(a,name,31)
  137.    pos += format(g_Buffer[pos],2047-pos,"%s --  擊中%d 次/ %d 點傷害,武器 %s^n",name,stats[5],stats[6],wpn)
  138.   }
  139. }
  140. return found
  141. }
  142. /* build list of victims */
  143. getVictims(id) {
  144. new name[32],wpn[32], stats[8],body[8],found=0
  145. new pos = copy(g_Buffer,2047,"被你打中的:^n")
  146. new amax = get_maxplayers()
  147. for(new a = 1; a <= amax; ++a){
  148.   if(get_user_vstats(id,a,stats,body,wpn,31)){
  149.    found = 1
  150.    if (stats[1])
  151.     format(wpn,31," -- %s",wpn)
  152.    else
  153.     wpn[0] = 0
  154.    get_user_name(a,name,31)
  155.    pos += format(g_Buffer[pos],2047-pos,"%s -- 你使用武器 %s 擊中他%d 次/ 造成%d點傷害,^n",name,wpn,stats[5],stats[6])
  156.   }
  157. }
  158. return found
  159. }
  160. /* build list of hita for AV List */
  161. getHits(id,killer) {
  162. new stats[8], body[8], pos = 0
  163. g_Buffer[0] = 0
  164. get_user_astats(id,killer,stats,body)
  165. for(new a = 1; a < 8; ++a)
  166.   if(body[a])
  167.   pos += format(g_Buffer[pos],2047-pos,"%s: %d^n",g_bodyParts[a],body[a])
  168. }
  169. /* get top 15 */
  170. getTop15() {
  171. new pos, stats[8], body[8], name[32],szState[4]
  172. //#if !defined NO_STEAM
  173. pos = copy(g_Buffer,2047,"<html><head><META http-equiv=Content-Type content='text/html ;charset=UTF-8'></head><body><style type=^"text/css^">")
  174. pos = format(g_Buffer,2047,"<style>body{color:#FFCC99;background-color:black;margin-top:5}.one{background-color:#1E90FF}.two{background-color:#00BFFF}td{font-size:14px}</style><center><b><font size=4>.*香港平安夜伺服*.排行榜</b><table width=550>")
  175. pos += format(g_Buffer[pos],2047-pos,"%s","<tr bgcolor=#800080 align=center><td>#<td>玩家姓名<td>殺敵<td>死亡<td>擊中<td>射擊<td>爆頭</tr>")
  176. new imax = get_statsnum()
  177. if (imax > 15) imax = 15
  178. for(new a = 0; a < imax; ++a){
  179.   if (equal(szState,"one")) copy(szState,3,"two")
  180.   else copy(szState,3,"one")
  181.   get_stats(a,stats,body,name,31)
  182.   pos += format(g_Buffer[pos],2047-pos,
  183.   "<tr class=%s><td>%d<td>%s<td>%d<td>%d<td>%d<td>%d<td>%d",szState,a+1,name,stats[0],stats[1],stats[5],stats[4],stats[2])
  184. }
  185. /*#else
  186. pos = format(g_Buffer,2047," #  %-28.27s %6s %6s %6s %6s %6s^n",
  187. "nick", "kills" , "deaths" , "hits","shots","hs" )
  188. new imax = get_statsnum()
  189. if (imax > 15) imax = 15
  190. for(new a = 0; a < imax; ++a){
  191.   get_stats(a,stats,body,name,31)
  192.   pos += format(g_Buffer[pos],2047-pos,"%2d. %-28.27s %6d %6d %6d %6d %6d^n",a+1,name,stats[0],stats[1],stats[5],stats[4],stats[2])
  193. }
  194. #endif*/
  195. }  
  196. /* build list of hits for say hp */
  197. getMyHits(id,killed) {
  198. new name[32], stats[8], body[8]
  199. get_user_name(killed,name,31)
  200. new pos = format(g_Buffer,2047,"「平安夜戰績統計系統」你擊中 %s 的:",name)
  201. get_user_vstats(id,killed,stats,body)
  202. for(new a = 1; a < 8; ++a){
  203.   if(body[a])
  204.    pos += format(g_Buffer[pos],2047-pos," %s: %d ",g_bodyParts[a],body[a])
  205. }
  206. }
  207. /* save hits and damage */
  208. public eCSDeathMsg() {
  209. new killer = read_data(1)
  210. new victim = read_data(2)
  211. if ( killer == victim ) return
  212. new vorigin[3], korigin[3]
  213. get_user_origin(victim,vorigin)
  214. get_user_origin(killer,korigin)
  215. g_Killers[victim][0] = killer
  216. g_Killers[victim][1] = get_user_health(killer)
  217. g_Killers[victim][2] = get_user_armor(killer)      
  218. g_Killers[victim][3] = get_distance(vorigin,korigin)
  219. if ( ShowKiller ){
  220.   new name[32], stats[8], body[8], wpn[33], mstats[8], mbody[8]
  221.   get_user_name(killer,name,31)
  222.   get_user_astats(victim,killer,stats,body,wpn,31)
  223.   if ( !get_user_vstats(victim,killer,mstats,mbody) )
  224.    mstats[5] = mstats[6] = 0
  225.   set_hudmessage(220,80,0,0.05,0.15,0, 6.0, 12.0, 1.0, 2.0, 1)
  226.   getHits(victim,killer)
  227.   show_hudmessage(victim,"%s 用 %s 將你殺死^n距離你 %.2f 米.^n他對你造成 %d 的傷害,打中你 %d 次^n他還有 %d 生命值 和 %d 獲甲.^n你對他造成了 %d 的傷害, 擊中他 %d次.^n他擊中了你下列部位:^n%s",
  228.   name,wpn,float(g_Killers[victim][3]) * 0.0254,  stats[6],stats[5],   g_Killers[victim][1],g_Killers[victim][2],
  229.   mstats[6],mstats[5],g_Buffer )
  230. }
  231. if ( ShowVictims && getVictims(victim) ){
  232.   set_hudmessage(0,80,220,0.55,0.60,0, 6.0, 12.0, 1.0, 2.0, 4)
  233.   show_hudmessage(victim,g_Buffer)
  234. }
  235. if ( ShowAttackers  && getAttackers(victim)){
  236.   set_hudmessage(220,80,0,0.55,0.35,0, 6.0, 12.0, 1.0, 2.0, 3)
  237.   show_hudmessage(victim,g_Buffer)
  238. }
  239. if (  KillerHpAp ){
  240.   new name[32], kmsg[128]
  241.   get_user_name(killer,name,31)
  242.   format(kmsg,127,"%s 還有 %d 生命值 和 %d 獲甲",name,g_Killers[victim][1],g_Killers[victim][2])
  243.   client_print(victim,print_console,kmsg)
  244.   set_hudmessage(255,255,255,0.02,0.85,2, 1.5, 3.0, 0.02, 5.0, 1)
  245.   show_hudmessage(victim,kmsg)
  246. }
  247. }
  248. public eResetHud( id )
  249. g_Killers[ id ][0] = 0
  250. public eRoundEnd()
  251. set_task( 0.3 , "eRoundEndTask" )
  252. public eRoundEndTask() {
  253. if (  ShowVictims || ShowAttackers ) {
  254.   new players[32], pnum
  255.   get_players( players , pnum, "a"  )
  256.   for(new i = 0; i < pnum; ++i ) {
  257.    if ( ShowVictims &&getVictims( players[ i ] )){
  258.     set_hudmessage(0,80,220,0.55,0.60,0, 6.0, 12.0, 1.0, 2.0, 4)
  259.     show_hudmessage( players[ i ] ,g_Buffer)
  260.    }
  261.    if ( ShowAttackers && getAttackers( players[ i ] ) ){
  262.     set_hudmessage(220,80,0,0.55,0.35,0, 6.0, 12.0, 1.0, 2.0, 3)
  263.     show_hudmessage( players[ i ] ,g_Buffer)
  264.    }
  265.   }
  266. }
  267. if ( EndMostKills || EndTeamScore || EndMostDamage  ){
  268.   new players[32], pnum, stats[8],bodyhits[8], len = 0
  269.   get_players( players , pnum )
  270.   g_Buffer[0] = 0
  271.   if ( EndMostKills ){
  272.    new kills = 0, who = 0, hs = 0
  273.    for(new i = 0; i < pnum; ++i){
  274.     get_user_rstats( players[i],stats, bodyhits )
  275.     if ( stats[0] > kills ){
  276.      who = players[i]
  277.      kills = stats[0]
  278.      hs = stats[2]
  279.     }  
  280.    }
  281.    if ( is_user_connected(who) ) {
  282.     new name[32]
  283.     get_user_name( who, name, 31 )
  284.     len += format(g_Buffer[len] , 512 - len ,
  285.     "最佳殺手: %s^n殺敵 %d 個 / 爆頭 %d 個^n", name , kills , hs )
  286.    }
  287.   }
  288.   if ( EndMostDamage ) {
  289.    new damage = 0, who = 0, hits = 0
  290.    for(new i = 0; i < pnum; ++i){
  291.     get_user_rstats( players[i],stats, bodyhits )
  292.     if ( stats[6] > damage ){
  293.      who = players[i]
  294.      hits = stats[5]
  295.      damage = stats[6]
  296.     }  
  297.    }
  298.    if ( is_user_connected(who) ) {
  299.     new name[32]
  300.     get_user_name( who, name, 31 )
  301.     len += format(g_Buffer[len] , 512 - len ,
  302.     "_________________________________^n最具殺傷力: %s^n擊中敵人 %d 次並造成 %d 傷害^n", name , hits , damage)
  303.    }
  304.   }
  305.   if ( EndTeamScore )
  306.    format(g_Buffer[len] , 512 - len , "_________________________________^n恐怖份子 %d 次勝利 -- 反恐精英 %d 次勝利^n", g_teamScore[0] , g_teamScore[1] )
  307.   set_hudmessage(0,191,255,-1.0,0.17,2, 0.01, 5.0, 0.01, 0.01, 3 )
  308.   show_hudmessage( 0 , g_Buffer )
  309. }
  310. }
  311. public cmdKiller(id) {
  312. if ( !SayHP ){
  313.   client_print(id,print_chat, g_disabledMsg )
  314.   return PLUGIN_HANDLED
  315. }
  316. if (g_Killers[id][0]) {
  317.   new name[32], stats[8], body[8], wpn[33], mstats[8], mbody[8]
  318.   get_user_name(g_Killers[id][0],name,31)
  319.   get_user_astats(id,g_Killers[id][0],stats,body,wpn,31)
  320.   client_print(id,print_chat,"「平安夜戰績統計系統」%s 使用 %s 在 %.2f米外將你殺死了",  name,wpn,float(g_Killers[id][3]) * 0.0254 )
  321.   client_print(id,print_chat,"「平安夜戰績統計系統」他擊中你%d 槍,對你造成 %d 點傷害,並且他還有 %d 生命和 %d 獲甲",
  322.   stats[5],stats[6], g_Killers[id][1],g_Killers[id][2] )
  323.   if ( get_user_vstats(id,g_Killers[id][0],mstats,mbody) )  {
  324.    client_print(id,print_chat,"「平安夜戰績統計系統」你擊中他 %d 槍,對他造成 %d 傷害",mstats[5], mstats[6])
  325.    getMyHits(id,g_Killers[id][0])
  326.    client_print(id,print_chat,g_Buffer)
  327.   }
  328.   else client_print(id,print_chat,"「平安夜戰績統計系統」你沒有打中他..好好反省吧!")
  329. }
  330. else {
  331.   client_print(id,print_chat,"「平安夜戰績統計系統」你沒有死亡紀錄!")
  332. }
  333. return PLUGIN_CONTINUE
  334. }
  335. public cmdStatsMe(id){
  336. if ( !SayStatsMe ){
  337.   client_print(id,print_chat, g_disabledMsg )
  338.   return PLUGIN_HANDLED
  339. }
  340. displayStats(id,id)
  341. return PLUGIN_CONTINUE
  342. }
  343. public displayStats(id,dest) {
  344. new pos, name[32], stats[8], body[8]
  345. get_user_wstats(id,0,stats,body)
  346. #if !defined NO_STEAM
  347. new szszState[4]
  348.         pos = copy(g_Buffer,2047,"<html><head><META http-equiv=Content-Type content='text/html ;charset=UTF-8'></head><body><style type=^"text/css^">")
  349. pos += copy(g_Buffer[pos],2047-pos,"body{font-family:Arial,sans-serif;font-size:12px;color:#FFCC99;background-color:#000000;margin-left:8px;margin-top:3px}.header{background-color:#800080;}.one{background-color:#1E90FF;}.two{background-color:#00BFFF;}")
  350. pos += format(g_Buffer[pos],2047-pos,"</style></head><body><table><tr class=^"one^"><td>殺敵:</td><td>%d</td></tr><tr class=^"two^"><td>被殺:</td><td>%d</td></tr><tr class=^"one^"><td>傷害:</td><td>%d</td></tr><tr class=^"two^"><td>擊中:</td><td>%d</td></tr><tr class=^"one^"><td>射擊:</td><td>%d</td></tr></table><br><br>",
  351. stats[0],stats[1],stats[6],stats[5],stats[4])
  352. pos += copy(g_Buffer[pos],2047-pos,"<table><tr class=^"header^"><td>武器</td><td>射擊</td><td>擊中</td><td>傷害</td><td>殺敵</td><td>死亡</td></tr>")
  353. for(new a = 1; a < 31; ++a) {
  354.   if (get_user_wstats(id,a,stats,body)) {
  355.    if (equal(szszState,"one")) copy(szszState,3,"two")
  356.    else copy(szszState,3,"one")
  357.    get_weaponname(a,name,31)
  358.    pos += format(g_Buffer[pos],2047-pos,"<tr class=^"%s^"><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td></tr>",
  359.    szszState,name[7],stats[4],stats[5],stats[6],stats[0],stats[1])
  360.   }
  361. }
  362. copy(g_Buffer[pos],2047-pos,"</table></body></html>")
  363. #else
  364. pos = format(g_Buffer,2047,"%6s: %d^n%6s: %d^n%6s: %d^n%6s: %d^n%6s: %d^n^n",
  365. "殺敵",stats[0],"被殺",stats[1],"傷害",stats[6],"擊中",stats[5],"射擊",stats[4])
  366. pos += format(g_Buffer[pos],2047-pos, "%-12.11s  %6s  %6s  %6s  %6s  %6s^n",
  367. "weapon","shots","hits","damage","kills","deaths")
  368. for(new a = 1; a < 31; ++a) {
  369.   if (get_user_wstats(id,a,stats,body)){
  370.    get_weaponname(a,name,31)
  371.    pos += format(g_Buffer[pos],2047-pos,"%-12.11s  %6d  %6d  %6d  %6d  %6d^n",
  372.    name[7],stats[4],stats[5],stats[6],stats[0],stats[1])
  373.   }
  374. }
  375. #endif
  376. get_user_name(id,name,31)
  377. show_motd(dest,g_Buffer,name)
  378. return PLUGIN_CONTINUE
  379. }
  380. public cmdRank(id){
  381. if ( !SayRank ){
  382.   client_print(id,print_chat, g_disabledMsg )
  383.   return PLUGIN_HANDLED
  384. }
  385. displayRank(id,id)
  386. return PLUGIN_CONTINUE
  387. }
  388. displayRank(id,dest) {
  389. new pos, name[32], stats[8], body[8]
  390. new rank_pos = get_user_stats(id,stats,body)
  391. #if !defined NO_STEAM
  392.         pos = copy(g_Buffer,2047,"<html><head><META content='charset=UTF-8'><body><style type=^"text/css^">")
  393. pos += copy(g_Buffer[pos],2047-pos,"body{font-family:Arial,sans-serif;font-size:12px;color:#FFCC99;background-color:#000000;margin-left:8px;margin-top:3px}.header{background-color:#800080;}.one{background-color:#1E90FF;}.two{background-color:#00BFFF;}")
  394. pos += format(g_Buffer[pos],2047-pos,"</style></head><body><table><tr><td colspan=2>%s的排名是 %d 人中的第 %d 名</td></tr>",(id==dest)?"你的":"他的",get_statsnum(), rank_pos)
  395. pos += format(g_Buffer[pos],2047-pos,"<tr class=^"one^"><td>殺敵:</td><td>%d</td></tr><tr class=^"two^"><td>死亡:</td><td>%d</td></tr><tr class=^"one^"><td>傷害:</td><td>%d</td></tr><tr class=^"two^"><td>擊中:</td><td>%d</td></tr><tr class=^"one^"><td>射擊:</td><td>%d</td></tr><tr><td> </td><td> </td></tr>",
  396. stats[0],stats[1],stats[6],stats[5],stats[4])
  397. pos += format(g_Buffer[pos],2047-pos,"<tr class=^"header^"><td colspan=2>擊中位置</td></tr><tr class=^"one^"><td>%s:</td><td>%d</td></tr><tr class=^"two^"><td>%s:</td><td>%d</td></tr><tr class=^"one^"><td>%s:</td><td>%d</td></tr><tr class=^"two^"><td>%s:</td><td>%d</td></tr><tr class=^"one^"><td>%s:</td><td>%d</td></tr><tr class=^"two^"><td>%s:</td><td>%d</td></tr><tr class=^"one^"><td>%s:</td><td>%d</td></tr>",
  398. g_bodyParts[1],body[1],g_bodyParts[2],body[2],g_bodyParts[3],body[3], g_bodyParts[4],body[4],
  399. g_bodyParts[5],body[5],g_bodyParts[6],body[6],g_bodyParts[7],body[7])
  400. copy(g_Buffer[pos],2047-pos,"</table></body></html>")
  401. #else
  402. pos = format(g_Buffer,2047,"%s rank is %d of %d^n^n",(id==dest)?"Your":"His", rank_pos,get_statsnum())
  403. pos += format(g_Buffer[pos],2047-pos,"%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d^n^n",
  404. "Kills",stats[0],"Deaths",stats[1],"Damage",stats[6],"Hits",stats[5],"Shots",stats[4])
  405. pos += format(g_Buffer[pos],2047-pos,"%10s:^n%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d^n%10s: %d",
  406. "Hits",g_bodyParts[1],body[1],g_bodyParts[2],body[2],g_bodyParts[3],body[3], g_bodyParts[4],body[4],
  407. g_bodyParts[5],body[5],g_bodyParts[6],body[6],g_bodyParts[7],body[7])
  408. #endif
  409. get_user_name(id,name,31)
  410. show_motd(dest,g_Buffer,name)
  411. }
  412. public cmdTop15(id) {
  413. if ( !SayTop15 ){
  414.   client_print(id,print_chat, g_disabledMsg )
  415.   return PLUGIN_HANDLED
  416. }
  417. getTop15()
  418. show_motd(id,g_Buffer,".*香港平安夜伺服*.排行榜")
  419. return PLUGIN_CONTINUE
  420. }
  421. public endGameStats(){
  422. if ( EndPlayer ){
  423.   new players[32], inum
  424.   get_players(players,inum)
  425.   for(new i = 0; i < inum; ++i)
  426.    displayStats(players[i],players[i])
  427. }
  428. else if ( EndTop15 ) {
  429.   new players[32], inum
  430.   get_players(players,inum)
  431.   getTop15()
  432.   for(new i = 0; i < inum; ++i)
  433.    show_motd(players[i],g_Buffer,".*香港平安夜伺服*.排行榜")
  434. }
  435. }
  436. public eInterMission()
  437. set_task(1.0,"endGameStats")
  438. public cmdStats(id){
  439. if ( !SayStatsAll ){
  440.   client_print(id,print_chat, g_disabledMsg )
  441.   return PLUGIN_HANDLED
  442. }
  443. showStatsMenu(id,g_userPosition[id]=0)
  444. return PLUGIN_CONTINUE
  445. }
  446. public actionStatsMenu(id,key){
  447. switch(key){
  448.   case 7: {
  449.    g_userszszState[id] = 1 - g_userszszState[id]
  450.    showStatsMenu(id,g_userPosition[id])
  451.   }
  452.   case 8: showStatsMenu(id,++g_userPosition[id])
  453.    case 9: showStatsMenu(id,--g_userPosition[id])
  454.    default:{
  455.    new option = g_userPosition[id] * 7 + key
  456.    new index = g_userPlayers[id][option]
  457.    if (is_user_connected(index)){
  458.     if (g_userszszState[id])
  459.      displayRank(index,id)
  460.     else
  461.      displayStats(index,id)
  462.    }
  463.    showStatsMenu(id,g_userPosition[id])
  464.   }
  465. }
  466. return PLUGIN_HANDLED
  467. }
  468. showStatsMenu(id,pos){
  469. if (pos < 0) return PLUGIN_HANDLED
  470. new menu_body[512], inum, k = 0, start = pos * 7
  471. get_players(g_userPlayers[id],inum)
  472. if (start >= inum) start = pos = g_userPosition[id] = 0
  473. new len = format(menu_body,511,"\yServer Stats\R%d/%d^n\w^n",pos + 1,((inum/7)+((inum%7)?1:0)))
  474. new name[32], end = start + 7, keys = (1<<9)|(1<<7)
  475. if (end > inum) end = inum
  476. for(new a = start; a < end; ++a){
  477.   get_user_name(g_userPlayers[id][a],name,31)
  478.   keys |= (1<<k)
  479.   len += format(menu_body[len],511-len,"%d. %s^n\w",++k,name)
  480. }
  481. len += format(menu_body[len],511-len,"^n8. %s^n\w",g_userszszState[id] ? "Show rank" : "Show stats" )
  482. if (end != inum){
  483.   format(menu_body[len],511-len,"^n9. More...^n0. %s" , pos ? "Back" : "Exit" )
  484.   keys |= (1<<8)
  485. }
  486. else format(menu_body[len],511-len,"^n0. %s" , pos ? "Back" : "Exit" )
  487. show_menu(id,keys,menu_body)
  488. return PLUGIN_HANDLED
  489. }
复制代码
游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表