搜索
查看: 2195|回复: 5

请教:改名插件中怎样加入KICK改名者?

[复制链接]
发表于 2008-5-4 20:43:24 | 显示全部楼层 |阅读模式 来自 湖南常德
[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]
 楼主| 发表于 2008-5-4 20:48:45 | 显示全部楼层 来自 湖南常德

回复: 请教:改名插件中怎样加入KICK改名者?

发现禁止改名插件有个小BUG,改成OP名后虽然不能显示,但具有OP权限。前提是知道OP密码。
这样的话,就会因密码泄露,而导致很多人都具有OP权限。
所以希望能把上面的源码修改一下,任何人只要一改名就自动KICK。
请高手支招。
回复

使用道具 举报

发表于 2008-5-4 20:52:04 | 显示全部楼层 来自 广东深圳

回复: 请教:改名插件中怎样加入KICK改名者?

Post by glacier45
[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 "...


[php]
// 禁止改名
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
}

[/php]

改成

[php]
// 禁止改名
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)
server_cmd("kick #%d [提示]游戏中禁止改名,您已经被请出服务器。",  get_user_userid( id))
}
}
return PLUGIN_CONTINUE
}

[/php]

你试试。经过zwfgdlc的提醒,我疏忽了。已更改。
回复

使用道具 举报

发表于 2008-5-4 20:55:54 | 显示全部楼层 来自 广东惠州

回复: 请教:改名插件中怎样加入KICK改名者?

[php]
if (!equal( oldname, newname))
{
          server_cmd("kick #%d ^"%s^"",get_user_userid(id),"服务器不允许玩家改名!!!!")
   }
[/php]
回复

使用道具 举报

发表于 2008-5-4 21:02:48 | 显示全部楼层 来自 广东惠州

回复: 请教:改名插件中怎样加入KICK改名者?

这里你搞错了
[php]
server_cmd("kick #%d [提示]游戏中禁止改名,您已经被请出服务器。", id )
[/php]
应该是玩家的userid,而不是玩家的索引.应该改为
[php]
server_cmd("kick #%d [提示]游戏中禁止改名,您已经被请出服务器。",get_user_userid( id) )
[/php]
回复

使用道具 举报

 楼主| 发表于 2008-5-4 21:57:32 | 显示全部楼层 来自 湖南常德

回复: 请教:改名插件中怎样加入KICK改名者?

非常感谢。已经搞定。
回复

使用道具 举报

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

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