|
发表于 2009-9-16 14:29:35
|
显示全部楼层
来自 中国–河南–许昌
请问楼主怎样把名字限制太长的从源码去掉?不要这功能! 谢谢楼主帮帮忙,跪求办法了,我不会改源码
/*
参数:
amx_reservation "1" //预留的通道数,没有权限的玩家进入此通道时会被kick
PreferenceIp "192.168" //优先IP,不包含端口号,默认内网
KickOption1 "" //筛选方式 1=PING最高者 2=得分最低者
KickOption1 "" //驱逐方式 1=踢出 2=转服
TargetIp "61.145.73.138:27016"//转服目标,必须包含端口号
amx_name_len "25"// 限制名字长度
*/
#include <amxmodx>
#include <csx>
#define PLUGIN_NAME "VIP内网优先"
#define PLUGIN_VERSION "0.1beta"
#define PLUGIN_AUTHOR "******"
new MemberPrivilege[33]
new showple[33]
new maxplayers
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
register_cvar("amx_reservation","1")//预留的通道数,没有权限的玩家进入此通道时会被kick
register_cvar("PreferenceIp","192.168")//优先IP,不包含端口号,默认内网
register_cvar("KickOption1","1")//筛选方式 1=PING最高者 2=负数王
register_cvar("KickOption2","2")//驱逐方式 1=踢出 2=转服
register_cvar("TargetIp","61.145.73.138:27016")//转服目标,必须包含端口号
register_cvar( "amx_name_len", "25")// 限制名字长度
register_cvar( "amx_MaxPing", "80")
register_cvar( "amx_MixPing", "30")
maxplayers = get_maxplayers()
}
public client_authorized(id)//(1)判断进服者
{
new name[33]
new msg[128]
get_user_name(id,name,32)
new ip1[17]
new ip2[8]
get_user_ip(id,ip1,15,1)
copy(ip2,7,ip1)
new barip[8]
get_cvar_string("PreferenceIp",barip,7)
if(get_user_flags(id) & ADMIN_RESERVATION || equal(ip2,barip)){
MemberPrivilege[id]=1
if(get_user_flags(id) & ADMIN_RESERVATION && showple[id] == 0)
format(msg,sizeof msg - 1,"^x01【^x03VIP*^x01】^x04 %s ^x03[^x01%s^x03] ^x01正在进入...",name,ip1)
else if(showple[id] == 0)
format(msg,sizeof msg - 1,"^x01【^x03贵宾^x01】^x04 %s ^x03[^x01%s^x03] ^x01正在进入...",name,ip1)
}
else{
MemberPrivilege[id]=0
if(showple[id] == 0){
format(msg,sizeof msg - 1,"^x01【^x03玩家^x01】^x04 %s ^x03[^x01%s^x03] ^x01正在连接...",name,ip1)
showple[id] = 1
new param[1]
param[0] = id
set_task(5.0, "showpp", 77777+id, param, 1)
}
}
client_color(0, id, msg)
new players = get_playersnum(1) //统计人数 ,连正在连接的也算
new limit = maxplayers - get_cvar_num("amx_reservation") //服最大人数 减去预留人数
if(strlen(name) > get_cvar_num("amx_name_len")){
server_cmd( "kick #%d 名称太长!本服限名称不得长于%d位字符", get_user_userid(id), get_cvar_num("amx_name_len"))
}
else if(players>limit){
if(MemberPrivilege[id]==1)
kickWho()
else{
new IdPing,IdLose
get_user_ping(id,IdPing,IdLose)
if(IdPing < get_cvar_num("amx_MixPing")){
new worstping,ping,lose,target
for(new i=1;i<=get_playersnum();i=i+1){
if(MemberPrivilege[i]==0 && is_user_connected(i)){
get_user_ping(i,ping,lose)
if (ping>worstping){
target=i
worstping=ping
}
}
}
if(ping > get_cvar_num("amx_MaxPing")){
new tarname[33]
get_user_name(target,tarname,32)
new PingKick[128]
format(PingKick,sizeof PingKick - 1,"^x01玩家^x03%s^x01因为Ping高于^x04%s^x01,而被外网玩家^x03%s^x04(Ping<%s)^x01挤出去",tarname,get_cvar_num("amx_MaxPing"),name,get_cvar_num("amx_MixPing"))
client_color(0, target, msg)
server_cmd("kick #%d 因为你的PING高于%s,被其他玩家挤了出来", get_user_userid(target),get_cvar_num("amx_MaxPing"))
}
else
kick(id,"")
}
else
kick(id,"")
}
}
}
public kickWho()//(2)选取被踢或被转服的人
{
new TargetId
new WhyKick[128]
switch (get_cvar_num("KickOption1"))
{//筛选方式
case 1:
{//PING最高
new worstping,ping,lose,target
for (new i=1;i<=get_playersnum();i=i+1)
{
if (MemberPrivilege[i]==0 && is_user_connected(i))
{
get_user_ping(i,ping,lose)
if (ping>worstping)
{
target=i
worstping=ping
}
}
}
TargetId=target
format(WhyKick,sizeof WhyKick - 1,"^x03PING最高:^x04%d",worstping)
}
case 2:
{//负数王
new worstfrag,frag,target
worstfrag = 80
for (new i=1;i<=get_playersnum();i=i+1)
{
if (MemberPrivilege[i]==0 && is_user_connected(i))
{
frag = get_user_frags(i) - get_user_deaths(i)
if (frag<worstfrag)
{
target=i
worstfrag=frag
}
}
}
TargetId=target
format(WhyKick,sizeof WhyKick - 1,"^x03是负分王:^x04得分 %d",worstfrag)
}
}
kick(TargetId,WhyKick)
}
//(3)踢人或转服
public kick(id,reasonMsg[]){
new name[55]
new msg[300]
new ip[22]
get_cvar_string("TargetIp",ip,22)
get_user_name(id,name,32)
switch (get_cvar_num("KickOption2"))
{//驱逐方式
case 1:
{//踢出
if(strlen(reasonMsg) > 0){
format(msg,sizeof msg - 1,"^x04【^x03预留通道^x04】^x01为保留预留通道^x03 %s ^x01被踢出^x04::^x01因为他%s",name,reasonMsg)
client_color(0, id, msg)
server_cmd("kick #%d 不好意思啦!预留通道将你请出:因为你%s", get_user_userid(id),reasonMsg)
}
else{
client_print(0, print_console,"【预留通道】 %s 进入时被踢",name)
server_cmd("kick #%d 不好意思啦!你不能用预留通道进入", get_user_userid(id))
}
}
case 2:
{//转服
format(msg,sizeof msg - 1,"^x04【^x03通道转服^x04】^x01:为保留预留通道^x03 %s ^x01被转向^x04[^x03%s^x04]^x03::^x01因为他%s",name,ip,reasonMsg)
if(strlen(reasonMsg) > 0)
client_color(0, id, msg)
else
client_print(0, print_console,"【通道转服】 %s 进入时被转向[%s]",name,ip)
client_cmd(id,"connect %s",ip)
}
}
}
//(4)当玩家改名时重新判断
public client_infochanged(id){
new newname[32], oldname[32]
get_user_info( id, "name", newname, 31)
get_user_name( id, oldname, 31)
if (!equal( oldname, newname)){
new param[1]
param[0] = id
set_task(1.0, "changedname", 1354+id, param, 1)
}
}
public changedname(param[]){
new id = param[0]
client_authorized(id)
}
public showpp(param[]){
new id = param[0]
showple[id] = 0
}
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()
client_print(playerid, print_console,msg)
} |
|