Osker Lee 发表于 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
这个标签。(呵呵,这样一来就比较符合标准的比赛形式了。)

另外,我想取消插件的内网和外网的限制,即只要玩家进入了本服务器,则不管他是内网玩家还是外网玩家, 一律在名字前加上标签。
/*************************************************************************************
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
new len
new uid
new str,cvar_fgstr
new players,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
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
temp=get_cvar_num("amx_flagname_cvar")
read_argv(id, Arg1,1)
if(Arg1!='1' && Arg1!='0' && Arg1!='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
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
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,ip_str, cvar_ipstr
new name
get_user_info( id, "name", newname,31 )

//---------amx_flagname_cvar==2-------------------------
if(get_cvar_num("amx_flagname_cvar")==2)
{
new id_str
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=='[' && newname==']' )
{
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)
{
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,right
strbreak(newname, left, len, right, 31)
set_user_info(players,"name",right)
}
}
else if(temp==2)
{
uid=get_user_userid ( players )
new s,s2
num_to_str(uid,s,4)
len=strlen(s)
copy(s2,len,s)
len+=5
if( containi(newname,s2)!=-1 )
{
new left,right
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
}

⑦O逅の崋イ孑 发表于 2013-5-7 11:44:12

刘半仙【仙】 发表于 2013-3-7 16:59 static/image/common/back.gif
然后呢。。!

然后没了!!!哈哈

Osker Lee 发表于 2008-2-3 03:58:32

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

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

KYO 发表于 2008-1-31 11:20:46

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

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

zwfgdlc 发表于 2008-1-30 03:08:50

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

呵呵,比赛不会总是有人频繁进进出出服务器的吧,

#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,name,tag,temp
read_data(2,team,31)
get_user_name(id,name,31)
copy(temp,6,name)
if(equal(team,"CT"))
{

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

zwfgdlc 发表于 2008-1-29 23:56:16

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

不用写那么长的代码吧,选择队伍后直接改名.简单点就行了

#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,name,tag
read_data(2,team,31)
get_user_name(id,name,31)
if(equal(team,"CT"))
{
format(tag,31,"%s",name)
}else{
format(tag,31,"%s",name)
}
set_user_info(id,"name",tag)
}

Rulzy 发表于 2008-1-30 01:28:01

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

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

Rulzy 发表于 2008-1-30 12:47:53

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

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

KYO 发表于 2008-1-31 11:20:06

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

这个想法很好   0 - 0

Osker Lee 发表于 2008-2-3 02:26:38

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

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

zwfgdlc 发表于 2008-2-3 03:26:09

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

好象没有捕捉到"TeamInfo"事件,你再试下

#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,name,tag,temp,team,userid,authid
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,""))
{
   return;
   }else if(contain(temp,"")!=-1){
   copy(temp,5,name);
   if(equal(temp,""))
    format(tag,31,"%s",name);
   }else{
   format(tag,31,"%s",name);
}
}else{
if(equal(temp,""))
{
   format(tag,31,"%s",name);
}else if(contain(temp,"")!=-1)
{
   copy(temp,5,name)
   if(equal(temp,""))
   return;
}else{
   format(tag,31,"%s",name);
}
}
set_user_info(id,"name",tag)
}
</SPAN>
页: [1] 2 3
查看完整版本: 怎么让玩家的名字前缀战队标签?