连续杀人踢出代码求教
使用老友记的一个连续杀人语音奖励修改成几秒内连续杀人KICK的插件,插件正常杀人下可以正常执行插件功能,但对于1.5魔兽下一个BUG虚假的杀人信息他不统计进去,如果将虚拟杀人用get_user_frags统计到插件中#define PLUGIN"Consecutive Killer"#define VERSION "0.3.16"
#define AUTHOR"iG_os"
#include <amxmodx>
#include <cstrike>
new g_KillSum //连续杀人数量记录
new g_HeatshotSum //爆头记录
new Float:g_Time //保存杀人开始,结束时间
public plugin_init()
{
register_plugin(PLUGIN,VERSION,AUTHOR)
register_event("DeathMsg","DeathEven","a")
}
public DeathEven()
{
new victimId = read_data(2) //被杀者
//ID死亡,结束已经开始计时的连杀计数//
/*if (task_exists(2006+victimId)){
remove_task(2006+victimId)
new param
param = victimId
TimeEnd(param)
}*/
new killerId = read_data(1) //杀人者
if (!killerId || killerId==victimId)
return PLUGIN_CONTINUE//排除自杀
if (get_user_team(killerId)==get_user_team(victimId))
return PLUGIN_CONTINUE //排除队友伤害
g_HeatshotSum += read_data(3) //爆头记录
if (task_exists(2006+killerId))
remove_task(2006+killerId)
Killer_Count(killerId)
return PLUGIN_CONTINUE
}
//杀人计数,计时
public Killer_Count(id)
{
//执行保存时间,数量.//
new Float:TimeNow = get_gametime()
if (g_KillSum<=0){
g_Time = TimeNow
g_Time = TimeNow
}
else g_Time = TimeNow
g_KillSum++ //杀人数加1//
new param
param = id
set_task(15.0, "TimeEnd", 2006+id, param, 1)//设定间隔时间5s//
}
//计时结束,执行显示数据//
public TimeEnd(param[])
{
new id = param
if (g_KillSum>2)//连续杀人超过3个才执行奖励
{
//计算时间//
new time_total = floatround(g_Time - g_Time)
if (time_total<1) //预防time_total小于0
time_total = 1
server_cmd("kick #%d", get_user_userid(id));
}
client_connected(id)
}
//数据初始化//
public client_connected(id)
{
g_KillSum = 0
g_HeatshotSum = 0
g_Time = 0.0
g_Time = 0.0
return PLUGIN_CONTINUE
}
public client_disconnect(id)
{
if (task_exists(2006+id))
remove_task(2006+id)
}
页:
[1]