搜索
查看: 1619|回复: 0

请版主帮看看,如何让它一局结束后重新统计累杀功能?谢谢..

[复制链接]
发表于 2008-1-10 20:20:28 | 显示全部楼层 |阅读模式 来自 中国–广西–百色
#include <amxmodx>
#include <amxmisc>

#define KEY8 (1<<7)
#define KEY9 (1<<8)

new kill[33] // 接连杀数目记数
new votekill[33]  // 投票连杀数目
new bool:g_voting   // 一个正在进行的投票
new bool:isVoted[33] // 正在被投票
new g_voteCount[2]

new g_voteResStr[2][12] = {"是","不是"}
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[id] = 0
votekill[id] = 0
return PLUGIN_CONTINUE
}

public client_disconnect(id){
if( isVoted[id] ){
  new ipStr[16],pname[32]
  get_user_ip( id, ipStr, 15, 1 )
  get_user_name( id, pname, 31)

  new Msg[128]
  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[id])
   isVoted[id] = false
}
return PLUGIN_CONTINUE
}

public newRound(){
new players[32],num
get_players( players, num)
for( new i = 0; i < num; i++ )
  kill[players] = 0
}

public death(){
new killer = read_data(1)
new victim = read_data(2)

if( killer != victim ){
  new players[32],num
  get_players( players, num)
  for( new i = 0; i < num; i++ ){

   if(victim == players){
    votekill[players] = 0
   }

   if( ( killer == players ) && !access( players, ADMIN_IMMUNITY) ){
    votekill[players]++ // for vote连续
    if( votekill[players] >= get_cvar_num("amx_conkill_vote") ){
     InitVote(players)
     votekill[players] = 0
    }
   }

  }
}
return PLUGIN_CONTINUE
}

public InitVote(target){
if( !is_user_connected(target) || access( target, ADMIN_IMMUNITY) || g_voting )
  return PLUGIN_HANDLED
g_voteCount[0]=0
g_voteCount[1]=0
isVoted[target] = true // 正在被投票
g_voting = true     // 一个正在进行的投票

new menuBody[512],pname[32]
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[len],511-len,"\w8.是^n")
len+=format(menuBody[len],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[key-7]++
new pname[32],msg[128]
get_user_name(id,pname,31)
format(msg,127,"^x01* ^x03%s^x01选^x04%s",pname,g_voteResStr[key-7])
client_color( 0, id, msg)
return PLUGIN_HANDLED
}
public showResult(target){
isVoted[target] = false
g_voting = false
new Float:result = 0.0
new msg[128]
result = ( g_voteCount[0]+g_voteCount[1] ) ? (float(g_voteCount[0]) / float( g_voteCount[0]+g_voteCount[1] ) ) : 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[0],g_voteCount[1])
  new ipStr[16]
  get_user_ip( target, ipStr, 15, 1 )
  if( get_cvar_num("amx_conkill_kick") ){
   server_cmd( "kick #%d ^"你连续杀了%d个而没有阵亡,太牛了^"", target, votekill[target])
  }
  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[0],g_voteCount[1])
client_color( 0, target, msg)
return PLUGIN_HANDLED
}
游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

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