|
new g_Buffer[2048]
new iRankPos
new jf
new iFlags[32]
new rank[32]
new g_bodyParts[8][] = {"全身","头部","胸部","腹部","左臂","右臂","左腿","右腿"}
new g_userPosition[33]
new g_userszszState[33]
new g_userPlayers[33][32]
public plugin_init() {
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
server_print("^n^t==========================================================^n^t %s %s, Copyright (C) 2012 by %s^n^t==========================================================^n",PLUGIN_NAME,PLUGIN_VERSION,PLUGIN_AUTHOR);
register_clcmd("say /jf15","cmdTopjf15",0,"- 显示积分前15名")
register_clcmd("say /kd15","cmdTopkd15",0,"- 显示杀亡比前15名")
register_clcmd("say /top15","cmdTop15",0,"- 显示杀手榜15名")
register_clcmd("say /Ctop15","cmdCTop15",0,"- 显示菜鸟榜前15名")
register_clcmd("say /rank","cmdRank",0,"- 显示个人信息")
register_clcmd("say /stats","cmdStats",0,"- 显示其他人的数据统计")
register_event("SendAudio", "eEndRound", "a", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw")
register_event("CS_DeathMsg","eCSDeathMsg","a")
register_menucmd(register_menuid("在线玩家统计数据"),1023,"actionStatsMenu")
}
/*-----------
算法
-------------*/
get_jf(stats[],c4[])
{
return 2*stats[0]-stats[1]+c4[3]*3+c4[1]*3
}
get_kd(stats[])
{
return 1.0*( float(stats[0])/ float(stats[1]))
}
/*
积分TOP15
*/
getjftop15()
{
new pos, stats[8], body[8], name[32],szstate[4],c4[4],count
static sort[101][2]
pos = format(g_Buffer,2047,"<meta charset=UTF-8><style>body{color:#FFFFFF;background-color:black;margin-top:5}.one{background-color:#565759}.two{background-color:#3D3D3D}td{font-size:14px}</style><center><b><font size=4>灬FourKing灬最佳玩家榜</b><table width=500>")
pos += format(g_Buffer[pos],2047-pos,"%s","<tr bgcolor=#9C0000><td>#<td>昵称<td>杀敌<td>死亡<td>雷包成功<td>雷包拆除<td>积分</tr>")
new imax = get_statsnum()
if (imax > 100) imax = 100
for(new a = 0;a<imax;a++)
{
get_stats(a,stats,body,name,31)
get_stats2(a,c4)
sort[count][0] = a
sort[count][1] = get_jf(stats,c4)
count++
}
SortCustom2D(sort,count,"stats_custom_compare");
for(new a = 0; a < 15; a++){
get_stats(sort[a][0],stats,body,name,31)
get_stats2(sort[a][0],c4)
if (equal(szstate,"one")) copy(szstate,3,"two")
else copy(szstate,3,"one")
while( contain ( name, "<" ) != -1 )
replace( name, 32, "<", "[" )
while( contain ( name, ">" ) != -1 )
replace( name, 32, ">", "]" )
pos += format(g_Buffer[pos],2047-pos,
"<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],c4[3],c4[1],sort[a][1])
}
copy(g_Buffer[pos],2047-pos,"</table><hr size=1 color=blue></font>积分算法:杀敌2分 雷包成功与拆除3分 死亡扣1分")
}
/*
杀亡比TOP15
*/
public getkdtop15()
{
new pos, stats[8], body[8], name[32],szstate[4],count,g_max
new g_num = 0
static sort[101][2]
pos = format(g_Buffer,2047,"<meta charset=UTF-8><style>body{color:#FFFFFF;background-color:black;margin-top:5}.one{background-color:#565759}.two{background-color:#3D3D3D}td{font-size:14px}</style><center><b><font size=4>灬FourKing灬最佳枪法榜</b><table width=500>")
pos += format(g_Buffer[pos],2047-pos,"%s","<tr bgcolor=#9C0000><td>#<td>昵称<td>杀亡比</tr>")
new imax = get_statsnum()
if (imax > 100)
g_max = 100
else
g_max = imax
do
{
get_stats(g_num,stats,body,name,31)
if(stats[1] != 0)
{
sort[count][0] = g_num
sort[count][1] = get_kd(stats)
count++
}
g_num++
}while((g_num <g_max)||(count<g_max))
SortCustom2D(sort,count,"stats_custom_compare");
for(new a = 0; a < 15; a++){
get_stats(sort[a][0],stats,body,name,31)
if (equal(szstate,"one")) copy(szstate,3,"two")
else copy(szstate,3,"one")
while( contain ( name, "<" ) != -1 )
replace( name, 32, "<", "[" )
while( contain ( name, ">" ) != -1 )
replace( name, 32, ">", "]" )
pos += format(g_Buffer[pos],2047-pos,
"<tr class=%s><td>%d<td>%s<td>%0.2f",szstate,a+1,name,sort[a][1])
}
copy(g_Buffer[pos],2047-pos,"</table><hr size=1 color=blue></font>FourKing Team")
}
/*
杀手榜TOP15
*/
getTop15() {
new pos, stats[8], body[8], name[32],szstate[4]
pos = format(g_Buffer,2047,"<meta charset=UTF-8><style>body{color:#FFFFFF;background-color:black;margin-top:5}.one{background-color:#565759}.two{background-color:#3D3D3D}td{font-size:14px}</style><center><b><font size=4>灬FourKing灬最佳杀手榜</b><table width=500>")
pos += format(g_Buffer[pos],2047-pos,"%s","<tr bgcolor=#9C0000><td>#<td>CSID<td>杀敌<td>阵亡<td>杀亡比</tr>")
new imax = get_statsnum()
if (imax > 15) imax = 15
for(new a = 0; a < imax; ++a){
if (equal(szstate,"one")) copy(szstate,3,"two")
else copy(szstate,3,"one")
get_stats(a,stats,body,name,31)
while( contain ( name, "<" ) != -1 )
replace( name, 32, "<", "[" )
while( contain ( name, ">" ) != -1 )
replace( name, 32, ">", "]" )
pos += format(g_Buffer[pos],2047-pos,
"<tr class=%s><td>%d<td>%s<td>%d<td>%d<td>%0.2f",szstate,a+1,name,stats[0],stats[1],get_kd(stats))
}
}
/*
菜鸟TOP15
*/
getCTop15() {
new pos, stats[8], body[8], name[32],szstate[4]
pos = format(g_Buffer,2047,"<meta charset=UTF-8><style>body{color:#FFFFFF;background-color:black;margin-top:5}.one{background-color:#565759}.two{background-color:#3D3D3D}td{font-size:14px}</style><center><b><font size=4>灬FourKing灬最佳菜鸟榜</b><table width=500>")
pos += format(g_Buffer[pos],2047-pos,"%s","<tr bgcolor=#9C0000><td>#<td>CSID<td>杀敌<td>阵亡<td>杀亡比</tr>")
new imax = get_statsnum()
new a = imax -1
new count = 1
if (imax > 15) imax = 15
do{
get_stats(a,stats,body,name,31)
if(stats[0]==0&&stats[1]==0){}
else{
if (equal(szstate,"one")) copy(szstate,3,"two")
else copy(szstate,3,"one")
while( contain ( name, "<" ) != -1 )
replace( name, 32, "<", "[" )
while( contain ( name, ">" ) != -1 )
replace( name, 32, ">", "]" )
pos += format(g_Buffer[pos],2047-pos,
"<tr class=%s><td>%d<td>%s<td>%d<td>%d<td>%0.2f",szstate,count,name,stats[0],stats[1],get_kd(stats))
count++
}
a--
}while(count<=imax)
}
/*
CMD Area
*/
public cmdTopjf15(id){
getjftop15()
show_motd(id,g_Buffer,"灬FourKing灬积分榜")
return PLUGIN_CONTINUE
}
public cmdTopkd15(id){
getkdtop15()
show_motd(id,g_Buffer,"灬FourKing灬KD榜")
return PLUGIN_CONTINUE
}
public cmdTop15(id){
getTop15()
show_motd(id,g_Buffer,"灬FourKing灬杀手榜")
return PLUGIN_CONTINUE
}
public cmdCTop15(id){
getCTop15()
show_motd(id,g_Buffer,"灬FourKing灬菜鸟榜")
return PLUGIN_CONTINUE
}
public cmdRank(id){
displayRank(id,id)
return PLUGIN_CONTINUE
}
public cmdStats(id){
showStatsMenu(id,g_userPosition[id]=0)
return PLUGIN_CONTINUE
}
/*
排序算法
*/
public stats_custom_compare(elem1[],elem2[])
{
if(elem1[1] > elem2[1]) return -1;
else if(elem1[1] < elem2[1]) return 1;
return 0;
}
displayRank(id,dest) {
flags(id)
new izStats[8], izBody[8],szMsg[126];
iRankPos = get_user_stats( id, izStats, izBody);
new pos, name[32], stats[8], body[8],c4[4]
get_user_stats2(id,c4)
new rank_pos = get_user_stats(id,stats,body)
iRank()
jf = get_jf(stats,c4)
#if !defined NO_STEAM
pos += copy(g_Buffer[pos],2047-pos,"<meta charset=UTF-8><style>body{font-family:Arial,sans-serif;font-size:12px;color:#FFFFFF;background-color:#000000;margin-left:8px;margin-top:3px}.header{background-color:#D66284;}.one{background-color:#8C2543;}.two{background-color:#64192F;}")
pos += format(g_Buffer[pos],2047-pos,"</style></head><body><table><tr><td colspan=2>%s排名第%d,總共%d人,兄弟继续加油阿.</td></tr>",(id==dest)?"你的":"他的",rank_pos, get_statsnum())
pos += format(g_Buffer[pos],2047-pos,"<tr class=^"one^"><td>职务:<td><font color = yellow><b>%s</font><tr class=^"two^"><td>军衔:<td><font color = red><b>%s</font><tr class=^"one^"><td>杀敌:</td><td><b>%d</td></tr><tr class=^"two^"><td>死亡:</td><td><b>%d</td></tr><tr class=^"one^"><td>积分:</td><td><font color = green><b>%d点(活动)</font></td></tr></tr><tr class=^"two^"><td>K D:</td><td><b>%0.2f</td></tr><tr class=^"one^"><td>命中率:</td><td><b>%0.2f‰</td></tr><tr><td> ",
iFlags,rank,stats[0],stats[1],jf,1.0* float( stats[0]) / float( stats[1]),100* float( stats[5]) / float( stats[4]))
pos += format(g_Buffer[pos],2047-pos,"<tr class=^"header^"><td colspan=2><font color = orange><b>雷包</font></td></tr><tr class=^"one^"><td>安装:</td><td><font color = orange><b>%d</font></td></tr><tr class=^"two^"><td>爆炸:</td><td><font color = orange><b>%d</font></td></tr><tr class=^"one^"><td>解除:</td><td><font color = orange><b>%d</font></td></tr><tr><td> ",
c4[2],c4[3],c4[1])
pos += format(g_Buffer[pos],2047-pos,"<tr class=^"header^"><td colspan=2><font color = yellow><b>击中</font></td></tr><tr class=^"one^"><td>%s:</td><td><b>%d</td></tr><tr class=^"two^"><td>%s:</td><td><b>%d</td></tr><tr class=^"one^"><td>%s:</td><td><b>%d</td></tr><tr class=^"two^"><td>%s:</td><td><b>%d</td></tr><tr class=^"one^"><td>%s:</td><td><b>%d</td></tr>",
g_bodyParts[1],body[1],g_bodyParts[2],body[2],g_bodyParts[3],body[3], g_bodyParts[4],body[4],
g_bodyParts[5],body[5],g_bodyParts[6],body[6],g_bodyParts[7],body[7])
copy(g_Buffer[pos],2047-pos,"<table></body></html>")
#endif
get_user_name(id,name,31)
format(szMsg,125,"灬%s灬个人数据",name)
show_motd(dest,g_Buffer,szMsg)
}
/*
权限标志
*/
public flags(id)
{
if (get_user_flags(id) & ADMIN_LEVEL_A)
{
iFlags = "高管"
}
else if (get_user_flags(id) & ADMIN_LEVEL_B)
{
iFlags = "OP"
}
else if (get_user_flags(id) & ADMIN_LEVEL_C)
{
iFlags = "VIP"
}
else if (get_user_flags(id) & ADMIN_USER)
{
iFlags = "散兵"
}
return iFlags
}
public iRank(){
if(iRankPos<=2)
rank = "五星上将"
else
{
if(iRankPos<=10)
rank = "上将"
else
{
if(iRankPos<=20)
rank = "中将"
else
{
if(iRankPos<=30)
rank = "少将"
else
{
if(iRankPos<=50)
rank = "准将"
else
{
if(iRankPos<=100)
rank = "上校"
else
{
if(iRankPos<=150)
rank = "中校"
else
{
if(iRankPos<=200)
rank = "少校"
else
{
if(iRankPos<=250)
rank = "大尉"
else
{
if(iRankPos<=300)
rank = "上尉"
else
{
if(iRankPos<=350)
rank = "中尉"
else
{
if(iRankPos<=400)
rank = "少尉"
else
{
if(iRankPos<=450)
rank = "准尉"
else
{
if(iRankPos<=500)
rank = "军士长"
else
{
if(iRankPos<=600)
rank = "参谋军士"
else
{
if(iRankPos<=700)
rank = "上士"
else
{
if(iRankPos<=800)
rank = "中士"
else
{
if(iRankPos<=900)
rank = "下士"
else
{
if(iRankPos<=1000)
rank = "上等兵"
else
{
if(iRankPos<=1500)
rank = "三等兵"
else
{
if(iRankPos<=2000)
rank = "二等兵"
else
{
if(iRankPos<=3000)
rank = "一等兵"
else
rank = "未授衔士兵"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return rank
}
public displayStats(id,dest) {
new pos, name[32], stats[8], body[8], szMsg[126]
get_user_wstats(id,0,stats,body)
#if !defined NO_STEAM
new szszState[4]
pos += copy(g_Buffer[pos],2047-pos,"<meta charset=UTF-8><style>body{font-family:Arial,sans-serif;font-size:12px;color:#FFFFFF;background-color:#000000;margin-left:8px;margin-top:3px}.header{background-color:#D66284;}.one{background-color:#8C2543;}.two{background-color:#64192F;}")
pos += format(g_Buffer[pos],2047-pos,"</style></head><body><table><tr class=^"one^"><td><font color = yellow><b>杀敌:</font></td><td><b>%d</td></tr><tr class=^"two^"><td><font color = yellow><b>被杀:</font></td><td><b>%d</td></tr><tr class=^"one^"><td><font color = yellow><b>伤害:</font></td><td><b>%d</td></tr><tr class=^"two^"><td><font color = yellow><b>击中:</font></td><td><b>%d</td></tr><tr class=^"one^"><td><font color = yellow><b>开枪:</font></td><td><b>%d</td></tr></table><br><br>",
stats[0],stats[1],stats[6],stats[5],stats[4])
pos += copy(g_Buffer[pos],2047-pos,"<table><tr class=^"header^"><td><font color = yellow><b>武器</font></td><td><font color = yellow><b>开枪</font></td><td><font color = yellow><b>击中</font></td><td><font color = yellow><b>伤害</font></td><td><font color = yellow><b>杀敌</font></td><td><font color = yellow><b>死亡</font></td></tr>")
for(new a = 1; a < 31; ++a) {
if (get_user_wstats(id,a,stats,body)) {
if (equal(szszState,"one")) copy(szszState,3,"two")
else copy(szszState,3,"one")
get_weaponname(a,name,31)
pos += format(g_Buffer[pos],2047-pos,"<tr class=^"%s^"><td><font color = green><b>%s</font></td><td><b>%d</td><td><b>%d</td><td><b>%d</td><td><b>%d</td><td><b>%d</td></tr>",
szszState,name[7],stats[4],stats[5],stats[6],stats[0],stats[1])
}
}
copy(g_Buffer[pos],2047-pos,"</table></body></html>")
#else
pos = format(g_Buffer,2047,"%6s: %d^n%6s: %d^n%6s: %d^n%6s: %d^n%6s: %d^n^n",
"杀敌",stats[0],"被杀",stats[1],"伤害",stats[6],"击中",stats[5],"开枪",stats[4])
pos += format(g_Buffer[pos],2047-pos, "%-12.11s %6s %6s %6s %6s %6s^n",
"weapon","shots","hits","damage","kills","deaths")
for(new a = 1; a < 31; ++a) {
if (get_user_wstats(id,a,stats,body)){
get_weaponname(a,name,31)
pos += format(g_Buffer[pos],2047-pos,"%-12.11s %6d %6d %6d %6d %6d^n",
name[7],stats[4],stats[5],stats[6],stats[0],stats[1])
}
}
#endif
get_user_name(id,name,31)
format(szMsg,125,"灬%s灬当局数据",name)
show_motd(dest,g_Buffer,szMsg)
return PLUGIN_CONTINUE
}
/*
每局最佳杀手 杀人王
*/
public eEndRound()
{
remove_task(8038)
set_task(1.0, "MostKill", 2132, "", 1)
}
public MostKill()
{
new i,maxkillcount,pos
maxkillcount=0
new stats[8],bodyhits[8],kmsg[126]
g_Buffer[0] = 0
/* 获取服务器当局最多杀人数*/
for(i=1;i<33;i++){
if(is_user_connected(i))
{
get_user_rstats( i,stats, bodyhits )
if(stats[0]&&stats[0]>maxkillcount)
maxkillcount=stats[0]
}
}
new money = 500*maxkillcount
if(maxkillcount >= 3){
pos += format(g_Buffer[pos],2047-pos,"杀人王宝座(歼敌%d):^n_________________",maxkillcount)
for(i=1;i<33;i++){
if(is_user_connected(i)){
get_user_rstats( i,stats, bodyhits )
if(stats[0] == maxkillcount){
cs_set_user_money2(i, cs_get_user_money2(i) + money)
new Rname[32]
get_user_name(i, Rname, 31)
pos += format(g_Buffer[pos],2047-pos,"^n%s",Rname)
}
}
format(kmsg,125,"^x03灬杀人王灬^x01本局获得赏金(^x03人头^x03%d X $500^x01)共$%d",maxkillcount,money)
}
}
else{
pos += format(g_Buffer[pos],2047-pos,"杀人王宝座(空缺):^n__________________",maxkillcount)
pos += format(g_Buffer[pos],2047-pos,"^n玩家最多歼敌少于3人,杀人王空缺")
format(kmsg,125,"^x03灬杀人王灬^x01本局无人获得赏金,江湖需要一个领袖崛起")
}
set_hudmessage(255,50,50,0.08,0.22,0, 0.01, 5.0, 0.01, 0.01, 4)
show_hudmessage( 0 ,g_Buffer)
for(i=1;i<33;i++){
if(is_user_connected(i)){
client_color(i,i,kmsg)
}
}
}
/*
创建一个我打中的,还有一个打中我的lIST
*/
/* 打中我的 */
getAttackers(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_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
}
/* 我打中的 */
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)){
found = 1
if (stats[1])
format(wpn,31," -- %s",wpn)
else
wpn[0] = 0
get_user_name(a,name,31)
pos += format(g_Buffer[pos],2047-pos,"%s -- 你使用武器 %s 击中他%d 次/ 造成%d点伤害,^n",name,wpn,stats[5],stats[6])
}
}
return found
}
/* 死亡事件 显示本局自己的数据*/
public eCSDeathMsg() {
new killer = read_data(1)
new victim = read_data(2)
if ( killer == victim ) return
if (getVictims(victim) ){
set_hudmessage(0,80,220,0.55,0.60,0, 6.0, 12.0, 1.0, 2.0, 2)
show_hudmessage(victim,g_Buffer)
}
if (getAttackers(victim)){
set_hudmessage(220,80,0,0.55,0.35,0, 6.0, 12.0, 1.0, 2.0, 3)
show_hudmessage(victim,g_Buffer)
}
}
/*
菜单
*/
public actionStatsMenu(id,key){
switch(key){
case 7: {
g_userszszState[id] = 1 - g_userszszState[id]
showStatsMenu(id,g_userPosition[id])
}
case 8: showStatsMenu(id,++g_userPosition[id])
case 9: showStatsMenu(id,--g_userPosition[id])
default:{
new option = g_userPosition[id] * 7 + key
new index = g_userPlayers[id][option]
if (is_user_connected(index)){
if (g_userszszState[id])
displayRank(index,id)
else
displayStats(index,id)
}
showStatsMenu(id,g_userPosition[id])
}
}
return PLUGIN_HANDLED
}
showStatsMenu(id,pos){
if (pos < 0) return PLUGIN_HANDLED
new menu_body[512], inum, k = 0, start = pos * 7
get_players(g_userPlayers[id],inum)
if (start >= inum) start = pos = g_userPosition[id] = 0
new len = format(menu_body,511,"\y在线玩家统计数据\R%d/%d^n\w^n",pos + 1,((inum/7)+((inum%7)?1:0)))
new name[32], end = start + 7, keys = (1<<9)|(1<<7)
if (end > inum) end = inum
for(new a = start; a < end; ++a){
get_user_name(g_userPlayers[id][a],name,31)
keys |= (1<<k)
len += format(menu_body[len],511-len,"%d. %s^n\w",++k,name)
}
len += format(menu_body[len],511-len,"^n8. %s^n\w",g_userszszState[id] ? "\r综合统计" : "\r当局统计" )
if (end != inum){
format(menu_body[len],511-len,"^n9. 更多...^n0. %s" , pos ? "返回" : "退出" )
keys |= (1<<8)
}
else format(menu_body[len],511-len,"^n0. %s" , pos ? "返回" : "退出" )
show_menu(id,keys,menu_body)
return PLUGIN_HANDLED
}
/*
文字打印
*/
public client_color(playerid, colorid, msg[])
{
message_begin(playerid?MSG_ONE:MSG_ALL,get_user_msgid("SayText"),_,playerid)
write_byte(colorid)
write_string(msg)
message_end()
client_print(playerid, print_console,msg)
}
|
|