lianbang 发表于 2010-8-19 09:45:50

哪位大哥帮我把stats加入/ME的命令,谢谢了

哪位大哥帮我把stats加入/ME的命令,谢谢了,本人实在太菜了,下面源码:

Cs.K 发表于 2010-8-19 14:58:20

把源码贴上来吧,这样人家帮你还要下载浪费DT币呢。

31394904 发表于 2010-8-19 18:55:23

人家要帮你改东西 还要浪费钱去下你附件、

不过话说回来了点通人越来越少倒是和DTB有关、

rsdtt 发表于 2010-8-19 19:32:19

/me应该在OP菜单里设置吧

lianbang 发表于 2010-8-19 19:54:45

本帖最后由 lianbang 于 2010-8-19 20:00 编辑

4# rsdtt


菜单里已经开启了,就是这个插件里没有/ME这个命令代码,我也不会移植,从statsx里移植就行了,但是真的不知道怎么弄。stats代码:
#include <amxmodx>
#include <amxmisc>
#include <csstats>

// 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 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
new g_Buffer
new g_userPosition
new g_userszszState
new g_userPlayers
new g_bodyParts[] = {"全身","头部","胸部","腹部","左臂","右臂","左腿","右腿"}
new bool:g_specMode
new g_teamScore

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")
}

public eTeamScore(){
        new team
        read_data( 1, team, 1 )
        g_teamScore[ (team=='C') ? 1 : 0 ] = read_data(2)
}

public setSpecMode(id) {
        new arg
        read_data( 2 , arg , 11 )
        g_specMode[ id ] = ( arg == '2' )
}

public showRank(id)
        if ( SpecRankInfo && g_specMode ){
        new a = read_data(2)
        if ( is_user_connected( a ) ){
                new name, data
                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)
        }
}

/* build list of attackers */
getAttackers(id) {
        new name,wpn, stats,body,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)
                                format(wpn,31," -- %s",wpn)
                        else
                                wpn = 0
                        get_user_name(a,name,31)
                        pos += format(g_Buffer,2047-pos,"%s --击中%d 次/ %d 点伤害,武器 %s^n",name,stats,stats,wpn)
                }
        }
        return found
}

/* build list of victims */
getVictims(id) {
        new name,wpn, stats,body,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)
                                format(wpn,31," -- %s",wpn)
                        else
                                wpn = 0
                        get_user_name(a,name,31)
                        pos += format(g_Buffer,2047-pos,"%s -- 你使用武器 %s 击中他%d 次/ 造成%d点伤害,^n",name,wpn,stats,stats)
                }
        }
        return found
}

/* build list of hita for AV List */
getHits(id,killer) {
        new stats, body, pos = 0
        g_Buffer = 0
        get_user_astats(id,killer,stats,body)
        for(new a = 1; a < 8; ++a)
                if(body)
                pos += format(g_Buffer,2047-pos,"%s: %d^n",g_bodyParts,body)
}

/* get top 15 */
getTop15() {
        new pos, stats, body, name,szState
        //#if !defined NO_STEAM
        pos = format(g_Buffer,2047,"<meta charset=UTF-8><style>body{color:#FFCC99;background-color:black;margin-top:5}.one{background-color:#310000}.two{background-color:#630000}td{font-size:14px}</style><center><b><font size=4>TOP15</b><table width=500>")
        pos += format(g_Buffer,2047-pos,"%s","<tr bgcolor=#9C0000><td>#<td>昵称<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, "<", "&lt;" )
                //while( contain ( name, ">" ) != -1 )
                //replace( name, 32, ">", "&gt;" )
                pos += format(g_Buffer,2047-pos,
                "<tr class=%s><td>%d<td>%s<td>%d<td>%d<td>%d (%0.1f%)",szState,a+1,name,stats,stats,stats,100 * float( stats)/float( stats))
        }

}

lianbang 发表于 2010-8-19 19:55:51

本帖最后由 lianbang 于 2010-8-19 19:58 编辑

/* build list of hits for say hp */
getMyHits(id,killed) {
        new name, stats, body
        get_user_name(killed,name,31)
        new pos = format(g_Buffer,2047,"你击中 %s 的:",name)
        get_user_vstats(id,killed,stats,body)
        for(new a = 1; a < 8; ++a){
                if(body)
                        pos += format(g_Buffer,2047-pos," %s: %d ",g_bodyParts,body)
        }
}

/* save hits and damage */
public eCSDeathMsg() {
        new killer = read_data(1)
        new victim = read_data(2)
        if ( killer == victim ) return
        new vorigin, korigin
        get_user_origin(victim,vorigin)
        get_user_origin(killer,korigin)
        g_Killers = killer
        g_Killers = get_user_health(killer)
        g_Killers = get_user_armor(killer)      
        g_Killers = get_distance(vorigin,korigin)
        if ( ShowKiller ){
                new name, stats, body, wpn, mstats, mbody
                get_user_name(killer,name,31)
                get_user_astats(victim,killer,stats,body,wpn,31)
                if ( !get_user_vstats(victim,killer,mstats,mbody) )
                        mstats = mstats = 0
                set_hudmessage(220,80,0,0.05,0.15,0, 6.0, 12.0, 1.0, 2.0, 1)
                getHits(victim,killer)
                show_hudmessage(victim,"%s 用 %s 将你击毙^n距离你 %.2f 米.^n他对你造成 %d 的伤害,打中你 %d 次^n他还有 %d生命值 和 %d护甲.^n你对他造成了 %d 的伤害, 击中他 %d次.^n他击中了你下列部位:^n%s",
                name,wpn,float(g_Killers) * 0.0254,stats,stats,   g_Killers,g_Killers,
                mstats,mstats,g_Buffer )
        }
        if ( ShowVictims && getVictims(victim) ){
                set_hudmessage(0,80,220,0.55,0.60,0, 6.0, 12.0, 1.0, 2.0, 4)
                show_hudmessage(victim,g_Buffer)
        }
        if ( ShowAttackers&& 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)
        }
        if (KillerHpAp ){
                new name, kmsg
                get_user_name(killer,name,31)
                format(kmsg,127,"%s 还有 %d生命值 和 %d护甲",name,g_Killers,g_Killers)
                client_print(victim,print_console,kmsg)
                set_hudmessage(255,255,255,0.02,0.85,2, 1.5, 3.0, 0.02, 5.0, 1)
                show_hudmessage(victim,kmsg)
        }
}

public eResetHud( id )
        g_Killers[ id ] = 0

public eRoundEnd()
        set_task( 0.3 , "eRoundEndTask" )

public eRoundEndTask() {
        if (ShowVictims || ShowAttackers ) {
                new players, pnum
                get_players( players , pnum, "a")
                for(new i = 0; i < pnum; ++i ) {
                        if ( ShowVictims &&getVictims( players[ i ] )){
                                set_hudmessage(0,80,220,0.55,0.60,0, 6.0, 12.0, 1.0, 2.0, 4)
                                show_hudmessage( players[ i ] ,g_Buffer)
                        }
                        if ( ShowAttackers && getAttackers( players[ i ] ) ){
                                set_hudmessage(220,80,0,0.55,0.35,0, 6.0, 12.0, 1.0, 2.0, 3)
                                show_hudmessage( players[ i ] ,g_Buffer)
                        }
                }
        }
        if ( EndMostKills || EndTeamScore || EndMostDamage){
                new players, pnum, stats,bodyhits, len = 0
                get_players( players , pnum )
                g_Buffer = 0
                if ( EndMostKills ){
                        new kills = 0, who = 0, hs = 0
                        for(new i = 0; i < pnum; ++i){
                                get_user_rstats( players,stats, bodyhits )
                                if ( stats > kills ){
                                        who = players
                                        kills = stats
                                        hs = stats
                                }
                        }
                        if ( is_user_connected(who) ) {
                                new name
                                get_user_name( who, name, 31 )
                                len += format(g_Buffer , 512 - len ,
                                "最佳杀手: %s^n杀敌 %d 个 / 爆头%d 个^n", name , kills , hs )
                        }
                }

lianbang 发表于 2010-8-19 19:59:17

if ( EndMostDamage ) {
                        new damage = 0, who = 0, hits = 0
                        for(new i = 0; i < pnum; ++i){
                                get_user_rstats( players,stats, bodyhits )
                                if ( stats > damage ){
                                        who = players
                                        hits = stats
                                        damage = stats
                                }
                        }
                        if ( is_user_connected(who) ) {
                                new name
                                get_user_name( who, name, 31 )
                                len += format(g_Buffer , 512 - len ,
                                "_________________________________^n最具杀伤力: %s^n击中敌人%d 次/造成 %d 伤害^n", name , hits , damage)
                        }
                }
                if ( EndTeamScore )
                        format(g_Buffer , 512 - len , "_________________________________^n匪徒%d次胜利-- 警察%d次胜利^n", g_teamScore , g_teamScore )
                set_hudmessage(128,128,255,-1.0,0.70,2, 0.01, 5.0, 0.01, 0.01, 3 )
                show_hudmessage( 0 , g_Buffer )
        }
}

public cmdKiller(id) {
        if ( !SayHP ){
                client_print(id,print_chat, g_disabledMsg )
                return PLUGIN_HANDLED
        }
        if (g_Killers) {
                new name, stats, body, wpn, mstats, mbody
                get_user_name(g_Killers,name,31)
                get_user_astats(id,g_Killers,stats,body,wpn,31)
                client_print(id,print_chat,"%s 使用 %s 在 %.2f米外将你结束了",name,wpn,float(g_Killers) * 0.0254 )
                client_print(id,print_chat,"他击中你%d 枪,对你造成 %d 点伤害,并且他还有 %d生命和 %d护甲",
                stats,stats, g_Killers,g_Killers )
                if ( get_user_vstats(id,g_Killers,mstats,mbody) ){
                        client_print(id,print_chat,"你击中他 %d 枪,对他造成 %d 伤害",mstats, mstats)
                        getMyHits(id,g_Killers)
                        client_print(id,print_chat,g_Buffer)
                }
                else client_print(id,print_chat,"你没打着他..")
        }
        else {
                client_print(id,print_chat,"你还没有被杀...")
        }
        return PLUGIN_CONTINUE
}

public cmdStatsMe(id){
        if ( !SayStatsMe ){
                client_print(id,print_chat, g_disabledMsg )
                return PLUGIN_HANDLED
        }
        displayStats(id,id)
        return PLUGIN_CONTINUE
}

public displayStats(id,dest) {
        new pos, name, stats, body
        get_user_wstats(id,0,stats,body)
        #if !defined NO_STEAM
        new szszState
        pos += copy(g_Buffer,2047-pos,"<meta charset=UTF-8><style>body{font-family:Arial,sans-serif;font-size:12px;color:#FFCC99;background-color:#000000;margin-left:8px;margin-top:3px}.header{background-color:#9C0000;}.one{background-color:#310000;}.two{background-color:#630000;}")
        pos += format(g_Buffer,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 (%0.1f%)</td></tr><tr class=^"two^"><td>伤害:</td><td>%d</td></tr><tr class=^"one^"><td>击中:</td><td>%d</td></tr><tr class=^"one^"><td>开枪:</td><td>%d</td></tr></table><br><br>",
        stats,stats,stats,100 * float( stats)/float( stats),stats,stats,stats)
        pos += copy(g_Buffer,2047-pos,"<table><tr class=^"header^"><td>武器</td><td>开枪</td><td>击中</td><td>伤害</td><td>杀敌</td><td>死亡</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,2047-pos,"<tr class=^"%s^"><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td></tr>",
                        szszState,name,stats,stats,stats,stats,stats)
                }
        }
        copy(g_Buffer,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,"被杀",stats,"伤害",stats,"击中",stats,"开枪",stats)
        pos += format(g_Buffer,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,2047-pos,"%-12.11s%6d%6d%6d%6d%6d^n",
                        name,stats,stats,stats,stats,stats)
                }
        }
        #endif
        get_user_name(id,name,31)
        show_motd(dest,g_Buffer,name)
        return PLUGIN_CONTINUE
}

public cmdRank(id){
        if ( !SayRank ){
                client_print(id,print_chat, g_disabledMsg )
                return PLUGIN_HANDLED
        }
        displayRank(id,id)
        return PLUGIN_CONTINUE
}

displayRank(id,dest) {
        new pos, name, stats, body
        new rank_pos = get_user_stats(id,stats,body)
        #if !defined NO_STEAM
        pos += copy(g_Buffer,2047-pos,"<meta charset=UTF-8><style>body{font-family:Arial,sans-serif;font-size:12px;color:#FFCC99;background-color:#000000;margin-left:8px;margin-top:3px}.header{background-color:#9C0000;}.one{background-color:#310000;}.two{background-color:#630000;}")
        pos += format(g_Buffer,2047-pos,"</style></head><body><table><tr><td colspan=2>%s在%d人中排名第%d</td></tr>",(id==dest)?"你的":"他的",get_statsnum(), rank_pos)
        pos += format(g_Buffer,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 (%0.1f%)</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><td>&nbsp;</td><td>&nbsp;</td></tr>",
        stats,stats,stats,100 * float( stats)/float( stats),stats,stats,stats)
        pos += format(g_Buffer,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>",
        g_bodyParts,body,g_bodyParts,body,g_bodyParts,body, g_bodyParts,body,
        g_bodyParts,body,g_bodyParts,body,g_bodyParts,body)
        copy(g_Buffer,2047-pos,"</table></body></html>")
        #endif
        get_user_name(id,name,31)
        show_motd(dest,g_Buffer,name)
}

public cmdTop15(id) {
        if ( !SayTop15 ){
                client_print(id,print_chat, g_disabledMsg )
                return PLUGIN_HANDLED
        }
        getTop15()
        show_motd(id,g_Buffer,"Top 15")
        return PLUGIN_CONTINUE
}

public endGameStats(){
        if ( EndPlayer ){
                new players, inum
                get_players(players,inum)
                for(new i = 0; i < inum; ++i)
                        displayStats(players,players)
        }
        else if ( EndTop15 ) {
                new players, inum
                get_players(players,inum)
                getTop15()
                for(new i = 0; i < inum; ++i)
                        show_motd(players,g_Buffer,"Top 15")
        }
}

public eInterMission()
        set_task(1.0,"endGameStats")

public cmdStats(id){
        if ( !SayStatsAll ){
                client_print(id,print_chat, g_disabledMsg )
                return PLUGIN_HANDLED
        }
        showStatsMenu(id,g_userPosition=0)
        return PLUGIN_CONTINUE
}

public actionStatsMenu(id,key){
        switch(key){
                case 7: {
                        g_userszszState = 1 - g_userszszState
                        showStatsMenu(id,g_userPosition)
                }
                case 8: showStatsMenu(id,++g_userPosition)
                        case 9: showStatsMenu(id,--g_userPosition)
                        default:{
                        new option = g_userPosition * 7 + key
                        new index = g_userPlayers
                        if (is_user_connected(index)){
                                if (g_userszszState)
                                        displayRank(index,id)
                                else
                                        displayStats(index,id)
                        }
                        showStatsMenu(id,g_userPosition)
                }
        }
        return PLUGIN_HANDLED
}

showStatsMenu(id,pos){
        if (pos < 0) return PLUGIN_HANDLED
        new menu_body, inum, k = 0, start = pos * 7
        get_players(g_userPlayers,inum)
        if (start >= inum) start = pos = g_userPosition = 0
        new len = format(menu_body,511,"\y在线玩家数据查询\R%d/%d^n\w^n",pos + 1,((inum/7)+((inum%7)?1:0)))
        new name, 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,name,31)
                keys |= (1<<k)
                len += format(menu_body,511-len,"%d. %s^n\w",++k,name)
        }
        len += format(menu_body,511-len,"^n8. %s^n\w",g_userszszState ? "Show rank" : "Show stats" )
        if (end != inum){
                format(menu_body,511-len,"^n9. More...^n0. %s" , pos ? "Back" : "Exit" )
                keys |= (1<<8)
        }
        else format(menu_body,511-len,"^n0. %s" , pos ? "Back" : "Exit" )
        show_menu(id,keys,menu_body)
        return PLUGIN_HANDLED
}
页: [1]
查看完整版本: 哪位大哥帮我把stats加入/ME的命令,谢谢了