Rulzy老大还有问题请教,请进,谢谢。
想弄个队伍平衡插件,可不知道怎么获取换队伍和加入队伍的事件,看了好多相关插件还是不懂,比如register_event("TextMsg","team_join","a","1=1","2&Game_join_te","2&Game_join_ct") 是吗?然后public team_join(id) {new team
read_data( 1, team, 1 )
g_teamScore[ (team=='C') ? 1 : 0 ] = read_data(2)
if ( g_teamScore > g_teamScore + 5 )
{
new players, Tcount
cs_set_user_team(players,CS_TEAM_T)
Tcount++
}
}可以通过吗?换队伍和加入队伍的事件可以归到一个事件里吗?谢谢。
回复: Rulzy老大还有问题请教,请进,谢谢。
register_logevent("team_join",3,"1=joined team","2=TERRORIST","2=CT","2=SPECTATOR")public team_join()
{
new user
read_logargv(0, user, 127)
new name, oldteam={0}
parse_loguser(user, name, 31, _, _, _, oldteam, 11)
new id = get_user_index(name)
new newteam
read_logargv(2,newteam, 15)
if(equal(newteam,"SPECTATOR")) //加入观察员
{
if(equal(oldteam, "TERRORIST")) //从T加入观察员
{
....
}else if(equal(oldteam, "CT")){ //从CT加入观察员
....
}else{//进入服务器就加入观察员
....
}
}else if(equal(newteam,"TERRORIST")){//加入T队伍
if(equal(oldteam,"SPECTATOR")){//从观察员加入T
....
}else if(equal(oldteam,"CT")){//从CT加入T
....
}else if(oldteam==0){//连接到服务器就加入T或CT
....
}
}else if(equal(newteam,"CT")){//加入CT队伍
if(equal(oldteam,"TERRORIST")){//从T加入CT
....
}else if(equal(oldteam,"SPECTATOR")){//从观察员加入CT
....
}else if(oldteam==0){//连接到服务器就加入CT
....
}
}
}
可以这样得到,但这只是得到,并不能阻止,要想阻止,用下面的方法:
register_menucmd(-2,(1<<0)|(1<<1)|(1<<4)|(1<<5),"team_select")
register_menucmd(register_menuid("Team_Select", 1),(1<<0)|(1<<1)|(1<<4)|(1<<5),"team_select")
public team_select(id, key){
//这里的key对应选择队伍时的菜单项,但key值小1。
//即key为0指选择菜单项1(选择T),key为1指选择菜单项2(选择CT),
//即key为4指选择菜单项5(自动选择),key为5指选择菜单项6(选择观察员)
//如果阻止,return PLUGIN_HANDLED;否则 return PLUGIN_CONTINUE
}
public client_command(id)
{
new command
read_argv(0, command, 31)
if(equali(command, "jointeam"))
{
new num, snum
read_argv(1, snum, 2)
num = str_to_num(snum)
return team_select(id, num-1)
}
return PLUGIN_CONTINUE
}
回复: Rulzy老大还有问题请教,请进,谢谢。
谢谢老大,第二个这里public team_select(id, key){//这里的key对应选择队伍时的菜单项,但key值小1。
//即key为0指选择菜单项1(选择T),key为1指选择菜单项2(选择CT),
//即key为4指选择菜单项5(自动选择),key为5指选择菜单项6(选择观察员)
//如果阻止,return PLUGIN_HANDLED;否则 return PLUGIN_CONTINUE
}谜糊得很,就用第一个了。还有请问
new team
read_data( 1, team, 1 )
g_teamScore[ (team=='C') ? 1 : 0 ] = read_data(2)
if ( g_teamScore > g_teamScore + 5 )
{
new players, Tcount
cs_set_user_team(players,CS_TEAM_T)
Tcount++
}
}这里是不是错了,我的本意是当土匪胜的局数大于5时就把人分配到警察那边,但是好像运行不成功。麻烦你了。
回复: Rulzy老大还有问题请教,请进,谢谢。
if ( g_teamScore > g_teamScore + 5 )这个条件可能成立吗???
回复: Rulzy老大还有问题请教,请进,谢谢。
:embarrass:embarrass:embarrass不好意思,搞错。谢谢。调试去了。
页:
[1]