Rulzy老大请进,还是上个的问题,谢谢。
不好意思,下次再也不这样了,别人还以为我在故意加积分,我只是怕你看不我上贴的回复之后以后没事了我回了你又不道,只个这两个插件我很想弄出来才这样,我知道你一般都是晚上在的,麻烦你又帮你解决一下了。#include <amxmodx>#include <amxmisc>
#include <cstrike>
new g_teamScore
public plugin_init(){
register_plugin("team","0.1","yyy")
register_logevent("team_join",3,"1=joined team","2=TERRORIST","2=CT","2=SPECTATOR")
return PLUGIN_CONTINUE
}
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,"TERRORIST")){//加入T队伍
if(equal(oldteam,"SPECTATOR")){//从观察员加入T
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++
}
}else if(equal(oldteam,"CT")){//从CT加入T
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++
}
}else if(oldteam==0){//连接到服务器就加入T或CT
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++
}
}
}else if(equal(newteam,"CT")){//加入CT队伍
if(equal(oldteam,"TERRORIST")){//从T加入CT
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_CT)
Tcount++
}
}else if(equal(oldteam,"SPECTATOR")){//从观察员加入CT
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_CT)
Tcount++
}
}else if(oldteam==0){//连接到服务器就加入CT
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_CT)
Tcount++
}
}
}
}中的get_user_index解释是获取玩家索引,可在这中间没运用到啊,这代码编译出来试着用机器人测试可没有用,请问是哪个地方出错了还是什么?万分感谢。:burn:
回复: Rulzy老大请进,还是上个的问题,谢谢。
在这个事件中,使用read_data( 1, team, 1 )
是没有意义的,read_data用于register_event中定义的事件,使用register_logevent只能使用read_logargv函数。
回复: Rulzy老大请进,还是上个的问题,谢谢。
#include <amxmodx>#include <amxmisc>
#include <cstrike>
new g_teamScore
public plugin_init(){
register_plugin("team","0.1","sanxiao")
register_logevent("team_join",3,"1=joined team","2=TERRORIST","2=CT","2=SPECTATOR")
return PLUGIN_CONTINUE
}
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,"TERRORIST")){//加入T队伍
if(equal(oldteam,"SPECTATOR")){//从观察员加入T
new team
read_logargv( 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++
}
}else if(equal(oldteam,"CT")){//从CT加入T
new team
read_logargv( 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++
}
}else if(oldteam==0){//连接到服务器就加入T或CT
new team
read_logargv( 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++
}
}
}else if(equal(newteam,"CT")){//加入CT队伍
if(equal(oldteam,"TERRORIST")){//从T加入CT
new team
read_logargv( 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_CT)
Tcount++
}
}else if(equal(oldteam,"SPECTATOR")){//从观察员加入CT
new team
read_logargv( 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_CT)
Tcount++
}
}else if(oldteam==0){//连接到服务器就加入CT
new team
read_logargv( 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_CT)
Tcount++
}
}
}
}可还是不行,还得请你再看看,谢谢。
回复: Rulzy老大请进,还是上个的问题,谢谢。
哎,你好好看看其他插件的源代码吧,相差还是太远了。我跟你说不能使用read_data,只能使用read_logargv,并不是叫你用read_logargv代替read_data。回复: Rulzy老大请进,还是上个的问题,谢谢。
呵呵~~我看着都急啊,真佩服Rulzy的细心耐心~~~~:super: :em06:回复: Rulzy老大请进,还是上个的问题,谢谢。
:gogo: 没办法,继续研究代码去。谢谢老大能回复,只能怕我学的东西太少了。
页:
[1]