|
最近我找到了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] |
|