搜索
查看: 1923|回复: 3

让有某一权限的人无法改名的插件如何写?

[复制链接]
发表于 2005-7-29 02:29:10 | 显示全部楼层 |阅读模式 来自 内蒙古呼伦贝尔
比如说让具有users.ini中的“p”权限的人无法改名,这样的插件如何写?

原来有一个让所有人都无法改名字的插件是这样写的:

[PHP]/* AMX Mod script.
*
* (c) Copyright 2002, OLO
* This file is provided as is (no warranties).
*
*/

#include <amxmod>

new bool:dontcheck[33]

public client_infochanged(id){
        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
                        client_print(id,print_chat,"** You are not allowed to change your name")
                        set_user_info(id,"name",oldname)
                }
        }
        return PLUGIN_CONTINUE
}

public plugin_init() {
        register_plugin("One Name","0.9","default")
        return PLUGIN_CONTINUE
}[/PHP]
发表于 2005-7-29 07:58:29 | 显示全部楼层 来自 北京
[PHP]/* AMX Mod script.
*
* (c) Copyright 2002, OLO
* This file is provided as is (no warranties).
*
*/

#include <amxmod>

new bool:dontcheck[33]

public client_infochanged(id){
    if  (get_user_flags(id)&ADMIN_LEVEL_D) 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
            client_print(id,print_chat,"** You are not allowed to change your name")
            set_user_info(id,"name",oldname)
        }
    }
    return PLUGIN_CONTINUE
}

public plugin_init() {
    register_plugin("One Name","0.9","default")
    return PLUGIN_CONTINUE
}
[/PHP]
回复

使用道具 举报

发表于 2005-7-29 10:53:45 | 显示全部楼层 来自 北京
其中添加了一行
if  (get_user_flags(id)&ADMIN_LEVEL_D) return PLUGIN_CONTINUE

get_user_flags 是用来获得指定玩家(用id表示)的权限。检测是否有这个权限,需要用"&"来进行判断。其中ADMIN_LEVEL_D就是“p”权限。如果有,那么get_user_flags(id)&ADMIN_LEVEL_D 返回“True”(真),使if 条件继续,执行 return PLUGIN_CONTINUE, return PLUGIN_CONTINUE的作用是终止过程,但是让client_infochanged事件继续进行下去,从而达到让玩家修改自己的名字的目的。
回复

使用道具 举报

 楼主| 发表于 2005-7-29 11:14:44 | 显示全部楼层 来自 内蒙古呼伦贝尔
好的~ 我试试看。:)
回复

使用道具 举报

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

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