搜索
查看: 15780|回复: 26

怎么让玩家的名字前缀战队标签?

[复制链接]
发表于 2008-1-29 16:22:08 | 显示全部楼层 |阅读模式 来自 中国–广西–梧州
最近我找到了flag_name.amxx(玩家姓名前加标签)这个插件,功能就是可以在内网玩家的名字前加上一个标签:

如 amx_flag BLUE 则表示在内网玩家的名字前都加上BLUE这个标签。(此命令仅适用于内网玩家,外网玩家不适用)所以,我想请高手们再修改一下这个源代码,让CT方和T方的名字前能分别加上不同的标签,增加如下指令:

amx_flag_CT BLUE 和 amx_flag_T RED

即让服务器里所有的CT玩家名字前都加上BLUE这个标签,让所有的T玩家名字前都加上RED
这个标签。(呵呵,这样一来就比较符合标准的比赛形式了。)

另外,我想取消插件的内网和外网的限制,即只要玩家进入了本服务器,则不管他是内网玩家还是外网玩家, 一律在名字前加上标签。
[php]/*************************************************************************************
data: 2005.9.11 6:15 v0.1 by Enigmaya
v0.2 9.11 20:10
add new funciton, you can add userid before a players'name.
add amx_flag to change flag in players' name at once.
v0.3 9.12 17:33
judge is the players an admin.
add amx_ip to change players' name at once when his part of ip doesn't match the amx_ip_cvar.
================================
use: add flag(userid) before a players' name. ( player who have the same part of ip. )
admin command:
amx_flagname 1 enable or disable this plugin.and set to add flag or add userid.
amx_flagname_cvar 1
amx_flag FLAG the flag which will added.you can change it.
this cmd will change the flag in players' name at once when you type in console .

amx_ip loop the ip which will added.you can change it.
also this cmd will change the players' name at once when you type in console .


amx_flag_cvar FLAG flag's cvar.
amx_ip_cvar loop ip's cvar.

*************************************************************************************/
#include <amxmodx>
#include <amxmisc>
#define MAXFLAGLEN 10
#define MAXIPLEN 11
new newname[32]
new len
new uid
new str[MAXFLAGLEN],cvar_fgstr[MAXFLAGLEN]
new players[32],num,temp

public plugin_init()
{
register_plugin("flagname","0.3","Enigmaya")
register_cvar("amx_flagname_cvar","2") // 0-disable,1-enable and add flag ,2-enable and add userid
register_cvar("amx_flag_cvar","FLAG")
register_cvar("amx_ip_cvar","loop")
register_concmd("amx_flagname", "admin_flagname",ADMIN_LEVEL_A,"< 0-disable,1-add flag,2-add userid >")
register_concmd("amx_flag", "set_flag_cvar",ADMIN_LEVEL_A)
register_concmd("amx_ip", "set_ip_cvar",ADMIN_LEVEL_A)
}

public client_connect(id)
{
if ( !get_cvar_num("amx_flagname_cvar") )
return PLUGIN_HANDLED
check_it(id)

return PLUGIN_HANDLED
}

public client_infochanged ( id )
{
if ( !get_cvar_num("amx_flagname_cvar") )
return PLUGIN_HANDLED

if( is_user_alive ( id ) )
{
new oldname[32]
get_user_name(id,oldname,31)
get_user_info( id, "name", newname,31 )

if(!equali(newname,oldname))
check_it(id)
}
return PLUGIN_HANDLED
}
public admin_flagname(id, level, cid)
{
if ( !cmd_access(id, level, cid, 2) )
return PLUGIN_HANDLED

new Arg1[1]
temp=get_cvar_num("amx_flagname_cvar")
read_argv(id, Arg1,1)
if(Arg1[0]!='1' && Arg1[0]!='0' && Arg1[0]!='2')
{
console_print(id,"********** input error ***********")
return PLUGIN_HANDLED
}

set_cvar_num( ("amx_flagname_cvar"),str_to_num(Arg1) )
get_cvar_string("amx_flag_cvar",str,MAXFLAGLEN-1)
check_all(temp,str)

return PLUGIN_HANDLED
}
public set_flag_cvar(id, level, cid)
{
if ( !cmd_access(id, level, cid, 2) )
return PLUGIN_HANDLED

if(get_cvar_num("amx_flagname_cvar")==2 || !get_cvar_num("amx_flagname_cvar"))
{
console_print(id,"********** not allowed ***********")
return PLUGIN_HANDLED
}

new Arg1[MAXFLAGLEN]
read_argv(id, Arg1,MAXFLAGLEN-1)
temp=get_cvar_num("amx_flagname_cvar")
get_cvar_string("amx_flag_cvar",str,MAXFLAGLEN-1)
set_cvar_string( "amx_flag_cvar",Arg1 )
check_all(temp,str)

return PLUGIN_HANDLED
}
public set_ip_cvar(id, level, cid)
{
if ( !cmd_access(id, level, cid, 2) )
return PLUGIN_HANDLED

if(get_cvar_num("amx_flagname_cvar")==2 || !get_cvar_num("amx_flagname_cvar"))
{
console_print(id,"********** not allowed ***********")
return PLUGIN_HANDLED
}

new Arg1[MAXIPLEN]
read_argv(id, Arg1,MAXIPLEN-1)
temp=get_cvar_num("amx_flagname_cvar")
get_cvar_string("amx_ip_cvar",str,MAXIPLEN-1)
set_cvar_string( "amx_ip_cvar",Arg1 )
check_all(temp,str)

return PLUGIN_HANDLED
}
check_it(id)
{
if( is_user_admin(id) )
return PLUGIN_HANDLED

new uip[15],ip_str[15], cvar_ipstr[MAXIPLEN]
new name[32]
get_user_info( id, "name", newname,31 )

//---------amx_flagname_cvar==2-------------------------
if(get_cvar_num("amx_flagname_cvar")==2)
{
new id_str[6]
uid=get_user_userid ( id )
format(id_str, 5, "#%i", uid)
if(containi(newname,id_str)!=0)
{
format(name, 31, "#%i %s", uid,newname)
set_user_info(id, "name", name)
}
return PLUGIN_CONTINUE
}

//----------amx_flagname_cvar==1-------------------------
get_cvar_string("amx_ip_cvar",cvar_ipstr,MAXIPLEN-1)
len=strlen(cvar_ipstr)
get_user_ip ( id, uip, 15,1)
copy(ip_str,len,uip)

get_cvar_string("amx_flag_cvar",str,MAXFLAGLEN-1)
len=strlen(str)
copy(cvar_fgstr,len,str)

if(equali(ip_str,cvar_ipstr))
{
if( containi(newname,cvar_fgstr)==1 && newname[0]=='[' && newname[len+1]==']' )
{
return PLUGIN_CONTINUE
}
format(name, 31, "[%s] %s",cvar_fgstr,newname)
set_user_info(id, "name", name)
}
else
{
if( containi(newname,cvar_fgstr)==-1 )
{
return PLUGIN_CONTINUE
}
client_print(id,print_chat,"** Don't use ^"%s^" in you name !",cvar_fgstr)
client_cmd(id,"name ^"empty^"")
}
return PLUGIN_CONTINUE
}
check_all(temp,str[MAXFLAGLEN])
{
get_players(players,num)
for(new i=0;i<num;i++)
{
get_user_info( players, "name", newname,31 )
if(temp==1)
{
get_user_info( players, "name", newname,31 )
len=strlen(str)
copy(cvar_fgstr,len,str)
len+=5
if( containi(newname,cvar_fgstr)!=-1 )
{
new left[MAXFLAGLEN],right[32]
strbreak(newname, left, len, right, 31)
set_user_info(players,"name",right)
}
}
else if(temp==2)
{
uid=get_user_userid ( players )
new s[5],s2[5]
num_to_str(uid,s,4)
len=strlen(s)
copy(s2,len,s)
len+=5
if( containi(newname,s2)!=-1 )
{
new left[5],right[32]
strbreak(newname, left, len, right, 31)
set_user_info(players,"name",right)
}
}
if(get_cvar_num("amx_flagname_cvar")!=0)
check_it(players)
}

return PLUGIN_HANDLED
} [/php]
发表于 2013-5-7 11:44:12 | 显示全部楼层 来自 中国–陕西–西安
刘半仙【仙】 发表于 2013-3-7 16:59
然后呢。。!

然后没了!!!哈哈
回复 1 0

使用道具 举报

 楼主| 发表于 2008-2-3 03:58:32 | 显示全部楼层 来自 中国–广西–梧州

回复: 怎么让玩家的名字前缀战队标签?

L 02/03/2008 - 03:50:40: Invalid player id 0
L 02/03/2008 - 03:50:40: [AMXX] Run time error 10 (plugin "flag_name.amxx") (native "set_user_info") - debug not enabled!
L 02/03/2008 - 03:50:40: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
L 02/03/2008 - 03:50:58: Invalid player id 0
L 02/03/2008 - 03:50:58: [AMXX] Run time error 10 (plugin "flag_name.amxx") (native "set_user_info") - debug not enabled!
L 02/03/2008 - 03:50:58: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
修改后的插件就没有任何效果了~  控制台还出现了debug信息。
回复 0 1

使用道具 举报

发表于 2008-1-31 11:20:46 | 显示全部楼层 来自 中国–重庆–重庆–荣昌区

回复: 怎么让玩家的名字前缀战队标签?

可以自定义个I.ini文件来控制就更好了
回复 1 0

使用道具 举报

发表于 2008-1-30 03:08:50 | 显示全部楼层 来自 中国–广东–惠州

回复: 怎么让玩家的名字前缀战队标签?

呵呵,比赛不会总是有人频繁进进出出服务器的吧,
[php]
#include <amxmodx>
#include <amxmisc>
#define PLUGIN_NAME "New Plug-In"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "zwfgdlc"

public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
register_event("TeamInfo","join_team","b","2!UNASSIGNED","2!SPECTATOR")
}
public join_team(id)
{
new team[32],name[32],tag[32],temp[6]
read_data(2,team,31)
get_user_name(id,name,31)
copy(temp,6,name)
if(equal(team,"CT"))
{

if(equal(temp,"[BLUE]"))
{
return;
}else if(contain(temp,"[RED]")!=-1){
copy(temp,5,name);
if(equal(temp,"[RED]"))
format(tag,31,"[BLUE]%s",name[6]);
}else{
format(tag,31,"[BLUE]%s",name);
}
}else{
if(equal(temp,"[BLUE]"))
{
format(tag,31,"[RED]%s",name[6]);
}else if(contain(temp,"[RED]")!=-1)
{
copy(temp,5,name)
if(equal(temp,"[RED]"))
return;
} else{
format(tag,31,"[RED]%s",name);
}
}
set_user_info(id,"name",tag)
}

[/php]
回复 0 1

使用道具 举报

发表于 2008-1-29 23:56:16 | 显示全部楼层 来自 中国–广东–惠州–惠城区

回复: 怎么让玩家的名字前缀战队标签?

不用写那么长的代码吧,选择队伍后直接改名.简单点就行了
[php]
#include <amxmodx>
#include <amxmisc>
#define PLUGIN_NAME "New Plug-In"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "zwfgdlc"
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
register_event("TeamInfo","join_team","be","2!UNASSIGNED","2!SPECTATOR")
//在此处添加您的代码...
}

public join_team(id)
{
new team[32],name[32],tag[32]
read_data(2,team,31)
get_user_name(id,name,31)
if(equal(team,"CT"))
{
  format(tag,31,"[BLUE]%s",name)
}else{
  format(tag,31,"[RED]%s",name)
}
set_user_info(id,"name",tag)
}

[/php]
回复

使用道具 举报

发表于 2008-1-30 01:28:01 | 显示全部楼层 来自 中国–福建–漳州

回复: 怎么让玩家的名字前缀战队标签?

呵呵,还要加上判断,如果已经是战队标签了,就不要再加了,或是修改队标。如从T变为CT,需要把RED变成BLUE,而不是再加上BLUE
回复

使用道具 举报

发表于 2008-1-30 12:47:53 | 显示全部楼层 来自 中国–福建–漳州

回复: 怎么让玩家的名字前缀战队标签?

Post by zwfgdlc
呵呵,比赛不会总是有人频繁进进出出服务器的吧,
呵呵,换队伍是肯定是存在的。
回复

使用道具 举报

发表于 2008-1-31 11:20:06 | 显示全部楼层 来自 中国–重庆–重庆–荣昌区

回复: 怎么让玩家的名字前缀战队标签?

这个想法很好   0 - 0
回复

使用道具 举报

 楼主| 发表于 2008-2-3 02:26:38 | 显示全部楼层 来自 中国–广西–梧州

回复: 怎么让玩家的名字前缀战队标签?

无心睡眠,赶紧测试了一下,结果发现无论是CT还是T,名字前都是被前缀"[RED]"的,什么原因呢?(参见截图)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注个册吧

×
回复

使用道具 举报

发表于 2008-2-3 03:26:09 | 显示全部楼层 来自 中国–广东–惠州

回复: 怎么让玩家的名字前缀战队标签?

好象没有捕捉到"TeamInfo"事件,你再试下
[php]
#include <amxmodx>
#include <amxmisc>
#define PLUGIN_NAME "New Plug-In"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "zwfgdlc"
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
register_logevent("join_team",3,"1=joined team")
}
public join_team(id)
{
new log[64],name[32],tag[32],temp[6],team[16],userid,authid[32]
read_logdata(log,63)
parse_loguser(log,name,31,userid,authid,31,team,15)
copy(temp,6,name)
if(equal(team,"CT"))
{
  
  if(equal(temp,"[BLUE]"))
  {
   return;
   }else if(contain(temp,"[RED]")!=-1){
   copy(temp,5,name);
   if(equal(temp,"[RED]"))
    format(tag,31,"[BLUE]%s",name[6]);
   }else{
   format(tag,31,"[BLUE]%s",name);
  }
}else{
  if(equal(temp,"[BLUE]"))
  {
   format(tag,31,"[RED]%s",name[6]);
  }else if(contain(temp,"[RED]")!=-1)
  {
   copy(temp,5,name)
   if(equal(temp,"[RED]"))
   return;
  }else{
   format(tag,31,"[RED]%s",name);
  }
}
set_user_info(id,"name",tag)
}  
[/php]</SPAN>
回复

使用道具 举报

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

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