搜索
查看: 1724|回复: 5

Rulzy老大请进,还是上个的问题,谢谢。

[复制链接]
发表于 2007-5-26 00:58:15 | 显示全部楼层 |阅读模式 来自 中国–广西–柳州–柳北区
不好意思,下次再也不这样了,别人还以为我在故意加积分,我只是怕你看不我上贴的回复之后以后没事了我回了你又不道,只个这两个插件我很想弄出来才这样,我知道你一般都是晚上在的,麻烦你又帮你解决一下了。
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

new g_teamScore[2]

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[128]
    read_logargv(0, user, 127)
    new name[32], oldteam[12]={0}
    parse_loguser(user, name, 31, _, _, _, oldteam, 11)
    new id = get_user_index(name)

    new newteam[16]
    read_logargv(2,newteam, 15)
    if(equal(newteam,"TERRORIST")){  //加入T队伍
        if(equal(oldteam,"SPECTATOR")){  //从观察员加入T
          new team[2]
          read_data( 1, team, 1 )
          g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
          if ( g_teamScore[0] > g_teamScore[1] + 5 )
          {
          new players, Tcount
          cs_set_user_team(players,CS_TEAM_T)
          Tcount++
          }
        }else if(equal(oldteam,"CT")){  //从CT加入T
          new team[2]
          read_data( 1, team, 1 )
          g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
          if ( g_teamScore[0] > g_teamScore[1] + 5 )
          {
          new players, Tcount
          cs_set_user_team(players,CS_TEAM_T)
          Tcount++
          }
        }else if(oldteam[0]==0){  //连接到服务器就加入T或CT
          new team[2]
          read_data( 1, team, 1 )
          g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
          if ( g_teamScore[0] > g_teamScore[1] + 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[2]
          read_data( 1, team, 1 )
          g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
          if ( g_teamScore[1] > g_teamScore[0] + 5 )
          {
          new players, Tcount
          cs_set_user_team(players,CS_TEAM_CT)
          Tcount++
          }
        }else if(equal(oldteam,"SPECTATOR")){  //从观察员加入CT
          new team[2]
          read_data( 1, team, 1 )
          g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
          if ( g_teamScore[1] > g_teamScore[0] + 5 )
          {
          new players, Tcount
          cs_set_user_team(players,CS_TEAM_CT)
          Tcount++
          }
        }else if(oldteam[0]==0){  //连接到服务器就加入CT
          new team[2]
          read_data( 1, team, 1 )
          g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
          if ( g_teamScore[1] > g_teamScore[0] + 5 )
          {
          new players, Tcount
          cs_set_user_team(players,CS_TEAM_CT)
          Tcount++
          }
        }
    }
}
中的get_user_index解释是获取玩家索引,可在这中间没运用到啊,这代码编译出来试着用机器人测试可没有用,请问是哪个地方出错了还是什么?万分感谢。:burn:
发表于 2007-5-27 00:42:16 | 显示全部楼层 来自 中国–福建–漳州

回复: Rulzy老大请进,还是上个的问题,谢谢。

在这个事件中,使用
read_data( 1, team, 1 )
是没有意义的,read_data用于register_event中定义的事件,使用register_logevent只能使用read_logargv函数。
回复

使用道具 举报

 楼主| 发表于 2007-5-27 02:30:52 | 显示全部楼层 来自 中国–广西–柳州–柳南区

回复: Rulzy老大请进,还是上个的问题,谢谢。

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

new g_teamScore[2]

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[128]
    read_logargv(0, user, 127)
    new name[32], oldteam[12]={0}
    parse_loguser(user, name, 31, _, _, _, oldteam, 11)
    new id = get_user_index(name)

    new newteam[16]
    read_logargv(2,newteam, 15)
    if(equal(newteam,"TERRORIST")){  //加入T队伍
        if(equal(oldteam,"SPECTATOR")){  //从观察员加入T
        new team[2]
        read_logargv( 1, team, 1 )
        g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
        if ( g_teamScore[0] > g_teamScore[1] + 5 )
        {
        new players, Tcount
        cs_set_user_team(players,CS_TEAM_T)
        Tcount++
        }
        }else if(equal(oldteam,"CT")){  //从CT加入T
        new team[2]
        read_logargv( 1, team, 1 )
        g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
        if ( g_teamScore[0] > g_teamScore[1] + 5 )
        {
        new players, Tcount
        cs_set_user_team(players,CS_TEAM_T)
        Tcount++
        }
        }else if(oldteam[0]==0){  //连接到服务器就加入T或CT
        new team[2]
        read_logargv( 1, team, 1 )
        g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
        if ( g_teamScore[0] > g_teamScore[1] + 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[2]
        read_logargv( 1, team, 1 )
        g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
        if ( g_teamScore[1] > g_teamScore[0] + 5 )
        {
        new players, Tcount
        cs_set_user_team(players,CS_TEAM_CT)
        Tcount++
        }
        }else if(equal(oldteam,"SPECTATOR")){  //从观察员加入CT
        new team[2]
        read_logargv( 1, team, 1 )
        g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
        if ( g_teamScore[1] > g_teamScore[0] + 5 )
        {
        new players, Tcount
        cs_set_user_team(players,CS_TEAM_CT)
        Tcount++
        }
        }else if(oldteam[0]==0){  //连接到服务器就加入CT
        new team[2]
        read_logargv( 1, team, 1 )
        g_teamScore[ (team[0]=='C') ? 1 : 0 ] = read_data(2)
        if ( g_teamScore[1] > g_teamScore[0] + 5 )
        {
        new players, Tcount
        cs_set_user_team(players,CS_TEAM_CT)
        Tcount++
        }
        }
    }
}
可还是不行,还得请你再看看,谢谢。
回复

使用道具 举报

发表于 2007-5-27 09:38:40 | 显示全部楼层 来自 中国–福建–漳州

回复: Rulzy老大请进,还是上个的问题,谢谢。

哎,你好好看看其他插件的源代码吧,相差还是太远了。我跟你说不能使用read_data,只能使用read_logargv,并不是叫你用read_logargv代替read_data。
回复

使用道具 举报

发表于 2007-5-27 13:05:36 | 显示全部楼层 来自 中国–广东–潮州

回复: Rulzy老大请进,还是上个的问题,谢谢。

呵呵~~我看着都急啊,真佩服Rulzy的细心耐心~~~~:super: :em06:
回复

使用道具 举报

 楼主| 发表于 2007-5-27 19:47:37 | 显示全部楼层 来自 中国–广西–柳州

回复: Rulzy老大请进,还是上个的问题,谢谢。

:gogo: 没办法,继续研究代码去。谢谢老大能回复,只能怕我学的东西太少了。
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

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