搜索
查看: 1916|回复: 1

还有个问题请教一下,关于限制某些名字

[复制链接]
发表于 2008-2-2 15:58:16 | 显示全部楼层 |阅读模式 来自 中国–广东–深圳–福田区
下面是限制某些名字的代码
我想增加一个读取用户名字,里面包含限制的名字,然后读取相应的权限,如果改用户有这个权限,就跳过检查的.
比方说我再 配置文件加入 wNv的 队标,如果用户权限里面包含这个人的话,就跳过检查

[php]/*
* 限制 改名 名称 长度
* v 1.0
*
* 在amxx的configs建立noname.ini文件,每一行一个限制名称
*
* 限制名字长度默认:16 位
*
*
*
* rewrited by 朱敏 QQ:103449085
*/
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "禁止 改名 名称 长度"
#define VERSION "1.0"
#define AUTHOR "Oh ye~"
new g_motdFile[64]
new bool:dontcheck[33] // 禁止改名
public plugin_init(){
register_plugin(PLUGIN, VERSION, AUTHOR)
get_configsdir(g_motdFile, 63)
format(g_motdFile, 63, "%s/noname.ini", g_motdFile)
register_cvar( "amxx_name_len", "16") // 限制名字长度
register_cvar("amxx_namejoin", "1") // 限制
register_cvar("amxx_namelen", "1") // 长度
register_cvar("amxx_namechanged", "1") // 改名
return PLUGIN_CONTINUE
}
public client_connect(id){
// 限制名字
if (file_exists(g_motdFile) && get_cvar_num("amxx_namejoin")){
new name[32],usrip[32],message[192], len, line = 0
get_user_name( id, name, 31)
get_user_ip( id, usrip, 31, 1)
while(read_file( g_motdFile, line++, message, 191, len)){
if( containi( name, message) != -1 ){
new userid = get_user_userid( id)
server_cmd( "kick #%d ^"你的名称不受欢迎,含有%s^"", userid, message)
}
}
}
// 限制长名
if ( !get_cvar_num("amxx_namelen"))
return PLUGIN_CONTINUE
new name[32]
get_user_info( id, "name", name, 31)
new nMaxLen = get_cvar_num("amxx_name_len")
if( strlen( name) > nMaxLen){
new userid = get_user_userid( id)
server_cmd( "kick #%d ^"请确定你的名字小于%d位^"", userid, nMaxLen)
}
return PLUGIN_HANDLED
}
// 禁止改名
public client_infochanged(id){
if( !get_cvar_num("amxx_namechanged"))
return PLUGIN_CONTINUE
if(dontcheck[id]){
dontcheck[id] = false
}
else if (is_user_connected(id)){
new newname[32], oldname[32]
get_user_info( id, "name", newname, 31)
get_user_name( id, oldname, 31)
if (!equal( oldname, newname)){
dontcheck[id] = true
new Msg[128]
format( Msg, 127,"^x01* 宝贝^x03%s^x01,游戏中禁止改名...", oldname)
client_color(0, id, Msg)
set_user_info( id, "name", oldname)
}
}
return PLUGIN_CONTINUE
}
public client_color(playerid, colorid, msg[]){
message_begin(playerid?MSG_ONE:MSG_ALL,get_user_msgid("SayText"),_,playerid)
write_byte(colorid)
write_string(msg)
message_end()
}[/php]

这样改行不?
[PHP]public client_connect(id){
// 限制名字
if (file_exists(g_motdFile) && get_cvar_num("amxx_namejoin")){
  new name[32],usrip[32],message[192], len, line = 0
  if (get_user_flags(id)&ADMIN_VOTE)
   return PLUGIN_CONTINUE
  get_user_name( id, name, 31)
  get_user_ip( id, usrip, 31, 1)
  while(read_file( g_motdFile, line++, message, 191, len)){
   if( containi( name, message) != -1 ){
    new userid = get_user_userid( id)
    server_cmd( "kick #%d ^"你的名称不受欢迎,含有%s^"", userid, message)
   }
  }
}[/PHP]
发表于 2008-2-2 19:05:55 | 显示全部楼层 来自 中国–广东–惠州–惠城区

回复: 还有个问题请教一下,关于限制某些名字

检查用户权限应该要在client_authorized()以后来检测,admin.amxx插件里设置用户权限也是在client_authorized()这时候发生的.client_connect()要比client_authorized()要早些触发,所以当时用户还是没有任何权限的.
回复

使用道具 举报

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

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