|
发表于 2007-11-30 17:45:19
|
显示全部楼层
|阅读模式
来自 中国–浙江–温州
如果这个搭配sxei_required2.amxx这个插件使用,当人满时候OP/VIP进入服务器,先自动踢出
[NO-sXe-I] 的ID呢?请大家帮我修改个!
/* AMX Mod X script.
* 如果OP通道插件未启用,本插件奖自动设置amx_reservation为 1 ,即保留一个通道。
* 使用方法:
* 在amxx.cfg里加入
* amx_kickmode <参数>
* 参数为 <1> 或者 <2> 。
* 1 表示 - 当服务器人满时,有OP或者VIP登陆时则踢掉一个在线时间最短的玩家。
* 2 表示 - 当服务器人满时,有OP或者VIP登陆时则踢掉一个ping值最高的玩家。
* 内网IP地址设置方法:
* amx_netbarip "IP地址的前面7位"
* 例: amx_netbarip "192.168"
*/
#include <amxmodx>
#include <amxmisc>
public plugin_init()
{
register_plugin("Slots Reservation","1.0","Lu0007")
register_cvar("amx_kickmode","2") //踢Ping高的,设1 为踢时间短的
register_cvar("amx_reservation","1")
//预留的通道数,没有权限的玩家进入此通道时会被kick
register_cvar("amx_netbarip","192.168") // 网吧IP段
//默认内网IP段
register_cvar("amx_rd_server","x.x.x.x") //要转向的目的服务器,自己修改.
register_cvar("amx_rd_serverport","27016") //端口,自己修改
register_cvar("amx_rd_serverpw","") //密码,留空为无密码,自己修改
}
//玩家进入初始化
public client_authorized(id) {
new userip[17]
new ips[8]
new ips2[16]
new name[33]
new g_amx_netbarip[8]
get_user_ip(id,userip,16,1)
copy(ips,7,userip) //前2段IP地址
copy(ips2,16,userip) //全IP地址
get_cvar_string("amx_netbarip",g_amx_netbarip,7)
get_user_name(id,name,32) //返回玩家名
new rd_serverport = get_cvar_num("amx_rd_serverport")
new rd_server[64], rd_serverpw[32]
get_cvar_string("amx_rd_server",rd_server,63)
get_cvar_string("amx_rd_serverpw",rd_serverpw,31)
new maxplayers = get_maxplayers() //返回游戏最大人数
new players = get_playersnum( 1 ) //统计人数 ,连正在连接的也算
new limit = maxplayers - get_cvar_num("amx_reservation") //服最大人数 减去预留人数
new resType = get_cvar_num( "amx_kickmode" ) //踢人模式 是高Ping 还是时间最短的
new who
//当超过限制人数时
if ( players > limit )
{
//进入的VIP&&OP 或是内网地址如192.168 或是如大内网IP段的如 10.0
if ( get_user_flags(id) & ADMIN_RESERVATION || (equali(ips,g_amx_netbarip)) || (contain(ips,g_amx_netbarip)==0))
{
set_user_flags(id, get_user_flags(id)|ADMIN_IMMUNITY)
//set_user_flags(id,read_flags("b"))
//设置玩家标记,b 为可通过预留通道加入服务器
switch(resType) {
case 1:
who = kickFresh() //踢时间短
case 2:
who = kickLag() //踢高Ping
}
if(who) {
get_user_name( who, name , 31 )
client_cmd(id,"echo ^"* %s 已被KICK或是转移!^"" ,name )
}
return PLUGIN_CONTINUE
}
//如是外网普通用户进入
if ( is_user_bot(id) ) //如是机器人,直接踢机器人
server_cmd("kick #%d 服务器人满! 请稍后再进入。", get_user_userid(id) )
else { //是人的,提示并踢除
//server_cmd("kick #%d 服务器人满! 请稍后再进入。", get_user_userid(id) )
if ( !equal(rd_serverpw,"") )
client_cmd(id,"echo ^"Redirection - Set Password to %s^";password %s",rd_serverpw,rd_serverpw)
client_cmd(id,"echo ^"Redirection - Redirecting to %s:%d^";connect %s:%d",rd_server,rd_serverport,rd_server,rd_serverport)
}
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
//踢Ping高的
kickLag() {
new rd_serverport = get_cvar_num("amx_rd_serverport")
new rd_server[64], rd_serverpw[32]
get_cvar_string("amx_rd_server",rd_server,63)
get_cvar_string("amx_rd_serverpw",rd_serverpw,31)
new who = 0, ping, loss, worst = -1
new maxplayers = get_maxplayers()
for(new i = 1; i <= maxplayers; ++i) {
if ( !is_user_connected(i) && !is_user_connecting(i) )
continue // not used slot
if (get_user_flags(i)&ADMIN_RESERVATION)
continue // has reservation, skip him
get_user_ping(i,ping,loss) // get ping
if ( ping > worst ) { //找出Ping最大的
worst = ping
who = i
}
}
if(who)
if ( is_user_bot(who) ) //如是机器人的
server_cmd("kick #%d [OP通道] 服务器踢高ping! 请稍后再进入。" , get_user_userid(who) )
else { //如是人的
//server_cmd("kick #%d [OP通道] 服务器踢高ping! 请稍后再进入。" , get_user_userid(who) )
if ( !equal(rd_serverpw,"") )
client_cmd(who,"echo ^"Redirection - Set Password to %s^";password %s",rd_serverpw,rd_serverpw)
client_cmd(who,"echo ^"Redirection - Redirecting to %s:%d^";connect %s:%d",rd_server,rd_serverport,rd_server,rd_serverport)
}
return who
}
//踢时间短的
kickFresh() {
new rd_serverport = get_cvar_num("amx_rd_serverport")
new rd_server[64], rd_serverpw[32]
get_cvar_string("amx_rd_server",rd_server,63)
get_cvar_string("amx_rd_serverpw",rd_serverpw,31)
new who = 0, itime, shortest = 0x7fffffff
new maxplayers = get_maxplayers()
for(new i = 1; i <= maxplayers; ++i){
if ( !is_user_connected(i) && !is_user_connecting(i) )//不是连接和不是正连接
continue // not used slot
if (get_user_flags(i)&ADMIN_RESERVATION) //是管理员的
continue // has reservation, skip him
itime = get_user_time(i) // get user playing time with connection duration
if ( shortest > itime ) {
shortest = itime
who = i
}
}
if(who) //如找到最短时间的
if ( is_user_bot(who) ) //如是个机器人
server_cmd("kick #%d [OP通道] 服务器预留OP通道! 请稍后再进入。", get_user_userid(who) )
else { //如是个人的
//server_cmd("kick #%d [OP通道] 服务器预留OP通道! 请稍后再进入。", get_user_userid(who) )
if ( !equal(rd_serverpw,"") )
client_cmd(who,"echo ^"Redirection - Set Password to %s^";password %s",rd_serverpw,rd_serverpw)
client_cmd(who,"echo ^"Redirection - Redirecting to %s:%d^";connect %s:%d",rd_server,rd_serverport,rd_server,rd_serverport)
}
return who |
|