|
楼主 |
发表于 2009-1-8 11:26:18
|
显示全部楼层
来自 中国–广西–防城港
/* AMX Mod X
* CS Stats Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
* Modifications by: zhangsheng
*
* Chinese version by: zhangsheng
*/
#include <amxmodx>
#include <amxmisc>
#include <csstats>
#include <cstrike>
// You can also manualy enable these options by setting them to 1
// For example:
// public ShowAttackers = 1
// However amx_statscfg command is recommended
public ShowAttackers // shows attackers
public ShowVictims // shows victims
public ShowKiller // shows killer
public EndPlayer // displays player stats at the end of map
public EndTop15 // displays top15 at the end of map
public KillerHpAp // displays killer hp&ap to victim console and screen
public SpecRankInfo // displays rank info when spectating
public ShowSpecStatus // show specstatus
public ShowRatio // show ratio
public ShowMoney // show money
public ShowIp // show ip
public EndRoundTop5 // end round top5
public SayHP // displays information about user killer
public SayStatsAll // displays players stats and rank
public SayTop15 // displays first 15. players
public SayRank // displays user position in rank
public SayStatsMe // displays user stats
public EndTeamScore // displays at the end of round team score
public EndMostKills // displays at the end of who made most kills
public EndMostDamage // displays at the end of who made most damage
new g_Killers[33][4]
new g_Buffer[2048]
new g_userPosition[33]
new g_userszszState[33]
new g_userPlayers[33][32]
new g_bodyParts[8][] = {"全身","头部","胸部","腹部","左臂","右臂","左腿","右腿"}
new bool:g_specMode[33]
new g_teamScore[2]
new g_disabledMsg[] = "服务器禁止了这个参数"
public plugin_init() {
register_plugin("CS Stats","0.16","AMXX Dev Team")
register_event("CS_DeathMsg","eCSDeathMsg","a")
register_event("ResetHUD","eResetHud","b")
register_event("SendAudio","eRoundEnd","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
register_event("30","eInterMission","a")
register_clcmd("say /hp","cmdKiller",0,"- 显示杀你的人的状态")
register_clcmd("say /statsme","cmdStatsMe",0,"- 显示你的统计")
register_clcmd("say /stats","cmdStats",0,"- 显示其他人的数据统计")
register_clcmd("say /top15","cmdTop15",0,"- 显示排名榜前15名")
register_clcmd("say /rank","cmdRank",0,"- 显示你在这个服务器上的排名情况")
register_menucmd(register_menuid("在线玩家统计数据"),1023,"actionStatsMenu")
register_event("TextMsg","setSpecMode","bd","2&ec_Mod")
register_event("StatusValue","showRank","bd","1=2")
register_event( "TeamScore", "eTeamScore", "a" )
}
public plugin_cfg(){
new g_addStast[] = "amx_statscfg add ^"%s^" %s"
server_cmd(g_addStast,"Show Attackers","ShowAttackers")
server_cmd(g_addStast,"Show Victims","ShowVictims")
server_cmd(g_addStast,"Show killer","ShowKiller")
server_cmd(g_addStast,"Stats at the end of map","EndPlayer")
server_cmd(g_addStast,"Top15 at the end of map","EndTop15")
server_cmd(g_addStast,"Show killer hp&ap","KillerHpAp")
server_cmd(g_addStast,"Say /hp","SayHP")
server_cmd(g_addStast,"Say /stats","SayStatsAll")
server_cmd(g_addStast,"Say /top15","SayTop15")
server_cmd(g_addStast,"Say /rank","SayRank")
server_cmd(g_addStast,"Say /statsme","SayStatsMe")
server_cmd(g_addStast,"Spec. Rank Info","SpecRankInfo")
server_cmd(g_addStast,"Team Score","EndTeamScore")
server_cmd(g_addStast,"Most Kills","EndMostKills")
server_cmd(g_addStast,"Most Damage","EndMostDamage")
server_cmd(g_addStast,"Spec. status","ShowSpecStatus")
server_cmd(g_addStast,"Spec. hit body ratio","ShowRatio")
server_cmd(g_addStast,"display player's money","ShowMoney")
server_cmd(g_addStast,"display top5 on endround","EndRoundTop5")
server_cmd(g_addStast,"displayer player's ip","ShowIp")
}
public client_color(id,msg[]){
new playerslist[32],playerscount//,i
get_players(playerslist,playerscount,"c")
if(id==0){
message_begin(MSG_ALL, get_user_msgid("SayText"), {0,0,0},id)
write_byte(id)
write_string(msg)
message_end()
}
else{
message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, id)
write_byte(id)
write_string(msg)
message_end()
}
}
public eTeamScore(){
new team[2]
read_data( 1, team, 1 )
g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
}
public setSpecMode(id) {
new arg[12]
read_data( 2 , arg , 11 )
g_specMode[ id ] = ( arg[10] == '2' )
}
Float:getratio( temp[8],x,all ) {
if( all == 0 ) return ( 0.0 )
return ( 100.0 * float( temp[x] ) / float( all ) )
}
/*ShowSpecStatus*/
getspecstatus(id) {
new pos,stats[8],bodyhits[8],bodysum
if ( ShowSpecStatus ){
new name[32]
get_user_name(id,name,31)
new health = get_user_health(id)
new armor = get_user_armor(id)
new data[8]
new rank = get_user_stats(id,data,data)
pos += format(g_Buffer[pos],2047-pos,"名字: %s^n生命值: %d^n装甲值: %d^n排名: %d^n",name,health,armor,rank )
}
if ( ShowMoney ){
new money = cs_get_user_money(id)
pos += format(g_Buffer[pos],2047-pos,"金钱: $ %d^n",money )
}
if ( ShowRatio ){
get_user_stats(id,stats,bodyhits)
for( new i=1; i<8; ++i )
bodysum += bodyhits[i]
new Float:bodyratio[8]
for( new i=1; i<8; ++i )
bodyratio[i] = getratio( bodyhits, i, bodysum )
if ( stats[1] == 0 )
bodyratio[0] = 0.0
else
bodyratio[0] = ( float (stats[0]) / float (stats[1]) )
pos += format(g_Buffer[pos],2047-pos,"命中率 列表:^n")
for ( new i=1; i<8; ++i )
pos += format(g_Buffer[pos],2047-pos,"->%s : %.2f%%%%^n",g_bodyParts[i],bodyratio[i])
pos += format(g_Buffer[pos],2047-pos,"杀死/死亡 : %.2f^n",bodyratio[0])
}
if ( ShowIp ){
new ipaddress[16]
get_user_ip(id,ipaddress,16,1)
pos += format(g_Buffer[pos],2047-pos,"IP地址 :%s^n",ipaddress)
}
}
/*EndRoundTop5*/
gettop5(){
new pos = 0,name[32],stats[8],bodyhits[8]
pos += format(g_Buffer[pos],2047-pos,"排行榜前5名:^n————————————————")
new imax = get_statsnum()
if (imax > 5) imax = 5
for(new a = 0; a < imax; ++a){
get_stats(a, stats, bodyhits, name, 31)
pos += format(g_Buffer[pos],2047-pos,"^n%d. %s",a+1,name )
}
}
public showRank(id)
if ( SpecRankInfo && g_specMode[id] ){
new a = read_data(2)
if ( is_user_connected( a ) ){
new name[32], data[8]
get_user_name( a ,name,31)
new pos = get_user_stats( a ,data,data)
set_hudmessage(255,255,255,0.02,0.85,2, 0.05, 0.1, 0.01, 3.0, 1)
show_hudmessage(id,"%s的名次是 %d人中排第 %d",name,get_statsnum(),pos)
getspecstatus(a)
if ( ShowRatio ){
set_hudmessage( 150, 50, 255, 0.03, 0.31, 0, 6.0, 10.0, 0.1, 0.2, 9)
//set_hudmessage(random_num(0,255),random_num(0,255),random_num(0,255), 0.03, 0.31, 0, 6.0, 10.0, 0.1, 0.2, 2)
}else{
set_hudmessage( 150, 50, 255, 0.03, 0.50, 0, 6.0, 10.0, 0.1, 0.2, 9)
//set_hudmessage(random_num(0,255),random_num(0,255),random_num(0,255), 0.03, 0.50, 0, 6.0, 10.0, 0.1, 0.2, 2)
}
show_hudmessage(id,g_Buffer)
}
}
/* build list of attackers */
getAttackers(id) {
new name[32],wpn[32], stats[8],body[8],found=0
new pos = copy(g_Buffer,2047,"Attackers:^n")
new amax = get_maxplayers()
for(new a = 1; a <= amax; ++a){
if(get_user_astats(id,a,stats,body,wpn,31)){
found = 1
if (stats[0])
format(wpn,31," -- %s",wpn)
else
wpn[0] = 0
get_user_name(a,name,31)
pos += format(g_Buffer[pos],2047-pos,"%s -- 击中%d 次/ %d 点伤害,武器 %s^n",name,stats[5],stats[6],wpn)
}
}
return found
}
/* build list of victims */
getVictims(id) {
new name[32],wpn[32], stats[8],body[8],found=0
new pos = copy(g_Buffer,2047,"被你打中的:^n")
new amax = get_maxplayers()
for(new a = 1; a <= amax; ++a){
if(get_user_vstats(id,a,stats,body,wpn,31)){ |
|