Osker Lee 发表于 2008-3-10 15:18:30

回复: 插件修改:当双方都只剩下一人时强制用小刀PK插件

解决方法跟W3C的解决方法一样,自己试下吧
再添加一个"HLTV"之类的"EVENT_NewRound"触发事件吗?我改了一下,不过就无法编译插件了。
#include <amxmodx>
#include <amxmisc>
#include <engine>
#define PLUGIN "Automatic Knife Duel"
#define VERSION "1.0"
#define AUTHOR "Administrator"
new bool:knifematic=false
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("CurWeapon", "event_holdwpn", "be", "1=1")
register_event("DeathMsg", "event_death", "a")

// 增加的部分
register_event( "HLTV", "EVENT_NewRound", "a", "1=0", "2=0")

register_event("SendAudio","event_round_end","a","2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
}
public event_death()
{
if(get_playersnum(0)<2) return

new Tnum=0,CTnum=0
new playerlist,num
get_players(playerlist,num,"a")
for(new i=0;i<num;i++)
{
new team=get_user_team(playerlist)
if(team==1)
++Tnum
else
++CTnum
}
//log_amx("T is %d,CT is %d",Tnum,CTnum)
if(Tnum==1&&CTnum==1)
{
knifematic=true
new players,snum
get_players(players,snum,"a")
for(new i=0;i<snum;i++)
{
engclient_cmd(players,"weapon_knife")
set_hudmessage(32, 202, 32, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, -1)
show_hudmessage(0,"双方现在进入小刀PK模式")
}
}
}
public event_holdwpn(id)
{
new wpnid=read_data(2)
if(wpnid!=CSW_KNIFE && knifematic)
engclient_cmd(id,"weapon_knife")
}
public event_round_end()
{
knifematic=false
}

// 增加的部分
public EVENT_NewRound()
}
knifematic=false
}

zwfgdlc 发表于 2008-3-10 15:23:36

回复: 插件修改:当双方都只剩下一人时强制用小刀PK插件

// 增加的部分
public EVENT_NewRound()
} //花括号错了,应该是{
knifematic=false
}

Osker Lee 发表于 2008-3-10 15:41:24

回复: 插件修改:当双方都只剩下一人时强制用小刀PK插件

:cold: 汗~ 我真是太粗心了,细节决定成败啊!再次谢谢zwfgdlc楼主,问题终于解决了。

jim_yang 发表于 2008-3-11 21:16:47

回复: 插件修改:当双方都只剩下一人时强制用小刀PK插件

补充一句,其实不用检查t 或者 ct的人数,只要检查活着的人是不是2个就行了。

jim_yang 发表于 2008-3-11 21:32:11

回复: 插件修改:当双方都只剩下一人时强制用小刀PK插件


#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Automatic Knife Duel"
#define VERSION "1.0"
#define AUTHOR "Administrator"
new bool:g_knifematic
new g_maxplayers
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_maxplayers = get_maxplayers()
register_event("CurWeapon", "event_holdwpn", "be", "1=1", "2!29")
register_event("DeathMsg", "event_death", "a")
register_logevent("reset", 2, "0=World triggered", "1=Round_Start")
register_logevent("reset", 2, "0=World triggered", "1=Round_End")
}
public reset()
{
g_knifematic = false
}
public event_death()
{
if(get_playersnum(0) < 2)
return
new players, num
get_players(players, num, "a")
if(num == 2)
{
g_knifematic = true
engclient_cmd(players, "weapon_knife")
engclient_cmd(players, "weapon_knife")
set_hudmessage(32, 202, 32, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, -1)
show_hudmessage(0,"双方现在进入小刀PK模式")
}
}
public event_holdwpn(id)
{
if(knifematic)
engclient_cmd(id, "weapon_knife")
}

zxp001 发表于 2011-11-10 01:17:58

sadasdsadasdas

ckn911 发表于 2011-11-10 23:08:54

都是高手啊、。、
页: 1 [2]
查看完整版本: 插件修改:当双方都只剩下一人时强制用小刀PK插件