让有某一权限的人无法改名的插件如何写?
比如说让具有users.ini中的“p”权限的人无法改名,这样的插件如何写?原来有一个让所有人都无法改名字的插件是这样写的:
/* AMX Mod script.
*
* (c) Copyright 2002, OLO
* This file is provided as is (no warranties).
*
*/
#include <amxmod>
new bool:dontcheck
public client_infochanged(id){
if (dontcheck){
dontcheck = false
}
else if (is_user_connected(id)){
new newname, oldname
get_user_info(id, "name", newname,31)
get_user_name(id,oldname,31)
if (!equal(oldname,newname)){
dontcheck = 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
} /* AMX Mod script.
*
* (c) Copyright 2002, OLO
* This file is provided as is (no warranties).
*
*/
#include <amxmod>
new bool:dontcheck
public client_infochanged(id){
if(get_user_flags(id)&ADMIN_LEVEL_D) return PLUGIN_CONTINUE
if (dontcheck){
dontcheck = false
}
else if (is_user_connected(id)){
new newname, oldname
get_user_info(id, "name", newname,31)
get_user_name(id,oldname,31)
if (!equal(oldname,newname)){
dontcheck = 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
}
其中添加了一行
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事件继续进行下去,从而达到让玩家修改自己的名字的目的。 好的~ 我试试看。:)
页:
[1]