|
发表于 2007-5-26 20:02:33
|
显示全部楼层
来自 中国–辽宁–沈阳
回复: 关于锁定OP名字的alias name指令和两个音效缺失的问题
以前我上传过一次原代码 现在无法上传了
我把原代码复制在下面
===========================================================
#include <amxmodx>
#include <amxmisc>
#define ADMIN_NAMELOCK_LEVEL ADMIN_LEVEL_B
#define MAX_NAME_LENGTH 33
new player_name[33][MAX_NAME_LENGTH];
new player_is_locked[33];
new is_plugin_on = -1;
new locked_name_length = -1;
public plugin_init()
{
register_plugin("Name Locker","1.17","Twilight Suzuka")
is_plugin_on = register_cvar("amx_namelock","1")
locked_name_length = register_cvar("amx_namelock_maxlen","32")
register_concmd("amx_namel","admin_rename",ADMIN_NAMELOCK_LEVEL,"amx_namel <nick|#userid|steamid|ip> <newname> - renames client, than locks their name.")
register_concmd("amx_nameul","admin_unlock",ADMIN_NAMELOCK_LEVEL,"amx_nameul <nick|#userid|steamid|ip> - unlocks clients name.")
register_concmd("amx_lock_name","admin_lock",ADMIN_NAMELOCK_LEVEL,"amx_lock_name <player> - locks clients name.")
register_concmd("amx_unlock_name","admin_unlock",ADMIN_NAMELOCK_LEVEL,"amx_unlock_name <player> - unlocks clients name.")
}
public admin_rename(id,level,cid)
{
if(!cmd_access(id,level,cid,3) ) return PLUGIN_HANDLED;
new arg[MAX_NAME_LENGTH]
read_argv(1,arg,MAX_NAME_LENGTH)
new tid = cmd_target(id,arg, 3)
if(tid == 0) return PLUGIN_HANDLED;
read_argv(2,arg,MAX_NAME_LENGTH)
lock_name(tid, arg, get_min_name_length())
new name[33],tname[33]
get_user_name(id,name,32)
get_user_name(tid,tname,32)
show_activity(id,name,"renamed %s",tname)
return PLUGIN_HANDLED;
}
public admin_lock(id,level,cid)
{
if(!cmd_access(id,level,cid,2) ) return PLUGIN_HANDLED;
new arg[MAX_NAME_LENGTH]
read_argv(1,arg,MAX_NAME_LENGTH)
new tid = cmd_target(id,arg, 3)
if(tid == 0) return PLUGIN_HANDLED;
player_is_locked[tid] = 1;
new name[33],tname[33]
get_user_name(id,name,32)
get_user_name(tid,tname,32)
show_activity(id,name,"locked %s's name",tname)
return PLUGIN_HANDLED;
}
public admin_unlock(id,level,cid)
{
if(!cmd_access(id,level,cid,2) ) return PLUGIN_HANDLED;
new arg[MAX_NAME_LENGTH]
read_argv(1,arg,MAX_NAME_LENGTH)
new tid = cmd_target(id,arg, 3)
if(tid == 0) return PLUGIN_HANDLED;
player_is_locked[tid] = 0;
new name[33],tname[33]
get_user_name(id,name,32)
get_user_name(tid,tname,32)
show_activity(id,name,"unlocked %s's name",tname)
return PLUGIN_HANDLED;
}
public client_putinserver(id)
{
player_is_locked[id] = 0;
check_name(id)
}
public client_infochanged(id)
{
return check_name_change(id);
}
public check_name(id)
{
if(!get_pcvar_num(is_plugin_on) || access(id,ADMIN_NAMELOCK_LEVEL) ) return PLUGIN_CONTINUE;
new name_length = get_min_name_length()
get_user_info(id, "name", player_name[id], MAX_NAME_LENGTH )
if(strlen(player_name[id]) > name_length) lock_name(id, player_name[id], name_length)
return PLUGIN_HANDLED;
}
public lock_name(id, name[], len)
{
player_is_locked[id] = 1;
format(player_name[id],len,"%s",name)
block_name_change(id)
}
public check_name_change(id)
{
if(!get_pcvar_num(is_plugin_on) || access(id,ADMIN_NAMELOCK_LEVEL) ) return PLUGIN_CONTINUE;
if(player_is_locked[id] == 0 ) return check_name(id);
new newname[MAX_NAME_LENGTH]
get_user_info(id, "name", newname, MAX_NAME_LENGTH )
if(!equal(newname,player_name[id],strlen(player_name[id]) ) ) block_name_change(id)
return PLUGIN_HANDLED;
}
public block_name_change(id)
{
client_print(id,print_chat,"You may not change your name at this time.")
set_user_info(id,"name",player_name[id])
}
stock get_min_name_length()
{
new ptr_name_length = get_pcvar_num(locked_name_length)
return min(MAX_NAME_LENGTH, ptr_name_length )
}
========================================================== |
|