请版主帮看看,如何让它一局结束后重新统计累杀功能?谢谢..
#include <amxmodx>#include <amxmisc>
#define KEY8 (1<<7)
#define KEY9 (1<<8)
new kill // 接连杀数目记数
new votekill// 投票连杀数目
new bool:g_voting // 一个正在进行的投票
new bool:isVoted // 正在被投票
new g_voteCount
new g_voteResStr = {"是","不是"}
public plugin_init(){
register_plugin("conkill","1.0", "Oh ye~")
register_event("DeathMsg", "death", "a")
register_logevent("newRound", 2, "0=World triggered", "1=Round_Start") // 回合
register_menucmd(register_menuid("VoteMenu"), KEY8|KEY9, "actionMenu")
register_cvar("amx_conkill_vote","13") // 投票连杀数目(默认:13)
register_cvar("amx_conkill_voterate","0.5") // 投票成功比例(默认:0.5)
register_cvar("amx_conkill_kick","1") // 接连杀踢或封禁(默认:1踢)
register_cvar("amx_conkill_bantime","11.0") // 封禁时间(默认:11.0)
register_cvar("amx_conkill_show","1") // 显示踢、封信息(默认:1是)
}
public client_color( playerid, colorid, msg[]){
message_begin( playerid?MSG_ONE:MSG_ALL, get_user_msgid("SayText"), {0,0,0}, playerid)
write_byte(colorid)
write_string(msg)
message_end()
}
//数据初始化
public client_connect(id){
kill = 0
votekill = 0
return PLUGIN_CONTINUE
}
public client_disconnect(id){
if( isVoted ){
new ipStr,pname
get_user_ip( id, ipStr, 15, 1 )
get_user_name( id, pname, 31)
new Msg
format( Msg, 127, "^x01* 注意:^x03%s^x01中途离开,将被封禁", pname)
client_color(0, id, Msg)
new Float:bantime = get_cvar_float("amx_conkill_bantime")
server_cmd("addip %.2f %s;wait;writeip", bantime, ipStr) // 封IP
if( isVoted)
isVoted = false
}
return PLUGIN_CONTINUE
}
public newRound(){
new players,num
get_players( players, num)
for( new i = 0; i < num; i++ )
kill] = 0
}
public death(){
new killer = read_data(1)
new victim = read_data(2)
if( killer != victim ){
new players,num
get_players( players, num)
for( new i = 0; i < num; i++ ){
if(victim == players){
votekill] = 0
}
if( ( killer == players ) && !access( players, ADMIN_IMMUNITY) ){
votekill]++ // for vote连续
if( votekill] >= get_cvar_num("amx_conkill_vote") ){
InitVote(players)
votekill] = 0
}
}
}
}
return PLUGIN_CONTINUE
}
public InitVote(target){
if( !is_user_connected(target) || access( target, ADMIN_IMMUNITY) || g_voting )
return PLUGIN_HANDLED
g_voteCount=0
g_voteCount=0
isVoted = true // 正在被投票
g_voting = true // 一个正在进行的投票
new menuBody,pname
get_user_name(target,pname,31)
new len=format(menuBody,511,"\y系统<2>自动检查: %s,他是在作弊吗?^n", pname, get_cvar_num("amx_conkill_vote") )
len+=format(menuBody,511-len,"\w8.是^n")
len+=format(menuBody,511-len,"\w9.不是^n")
show_menu( 0, KEY8|KEY9, menuBody, 11,"anyVoteMenu")
set_task( 11.0 + 1.0,"showResult",target)
return PLUGIN_HANDLED
}
public actionMenu(id,key){
g_voteCount++
new pname,msg
get_user_name(id,pname,31)
format(msg,127,"^x01* ^x03%s^x01选^x04%s",pname,g_voteResStr)
client_color( 0, id, msg)
return PLUGIN_HANDLED
}
public showResult(target){
isVoted = false
g_voting = false
new Float:result = 0.0
new msg
result = ( g_voteCount+g_voteCount ) ? (float(g_voteCount) / float( g_voteCount+g_voteCount ) ) : 0.0
if( result >= get_cvar_float("amx_conkill_voterate") ){
format(msg,127,"^x01* 投票结果:^x03%0.1f^x01.同意^x04是^x03%d^x01,同意^x04不是^x03%d^x01,作弊者将立刻被封禁...",result,g_voteCount,g_voteCount)
new ipStr
get_user_ip( target, ipStr, 15, 1 )
if( get_cvar_num("amx_conkill_kick") ){
server_cmd( "kick #%d ^"你连续杀了%d个而没有阵亡,太牛了^"", target, votekill)
}
else{
new Float:bantime = get_cvar_float("amx_conkill_bantime")
server_cmd("addip %.2f %s;wait;writeip", bantime, ipStr) // 封IP
}
}
else
format(msg,127,"^x01* 投票结果:^x03%0.1f^x04是^x03%d^x04,不是^x03%d",result,g_voteCount,g_voteCount)
client_color( 0, target, msg)
return PLUGIN_HANDLED
}
页:
[1]