关于OP通道插件问题
这个插件经过我的修改后可以转服为NO-SXE的,但有一个问题需要问下就是当服里面全部是开了sxe的话,
怎么定义插件返回来重新运行 "在线时间最短"或"ping值最高"
望高手指点一下
/* AMX Mod X script.
* 如果OP通道插件未启用,本插件奖自动设置amx_reservation为 1 ,即保留一个通道。
* 使用方法:
* 在amxx.cfg里加入
* amx_kickmode <参数>
* 参数为 <1> 或者 <2> 。
* 1 表示 - 当服务器人满时,有OP或者VIP登陆时则踢掉一个在线时间最短的玩家。
* 2 表示 - 当服务器人满时,有OP或者VIP登陆时则踢掉一个ping值最高的玩家。
新增加
* 3 表示 - 当服务器人满时,有OP或者VIP登陆时则踢掉一个没有开sxe的玩家。
* 内网IP地址设置方法:
* amx_netbarip "IP地址的前面7位"
* 例: amx_netbarip "192.168"
*/
#include <amxmodx>
#include <amxmisc>
// Comment if you don't want to hide true max_players
//#define HIDE_RESERVEDSLOTS
public plugin_init()
{
register_plugin("Slots Reservation","1.0","Lu0007")
register_cvar("amx_kickmode","3") //踢nosxe
register_cvar("amx_reservation","1") //预留的通道数,没有权限的玩家进入此通道时会被kick
register_cvar("amx_netbarip","10.0") //默认内网IP段
register_cvar("amx_rd_server","") //要转向的目的服务器.
register_cvar("amx_rd_serverport","") //端口
register_cvar("amx_rd_serverpw","") //密码,留空为无密码
#if defined HIDE_RESERVEDSLOTS
set_cvar_num( "sv_visiblemaxplayers" , get_maxplayers() - 1 )
#endif
}
//玩家进入初始化
public client_authorized(id) {
new userip
new ips
new ips2
new name
new g_amx_netbarip
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, rd_serverpw
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
case 3:
who = kicknosxe() //踢高nosxe
}
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, rd_serverpw
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 服务器踢高ping! 请稍后再进入。" , get_user_userid(who) )
else { //如是人的
//server_cmd("kick #%d 服务器踢高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, rd_serverpw
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通道! 请稍后再进入。", get_user_userid(who) )
else { //如是个人的
//server_cmd("kick #%d 服务器预留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
}
kicknosxe() {
new rd_serverport = get_cvar_num("amx_rd_serverport")
new rd_server, rd_serverpw
get_cvar_string("amx_rd_server",rd_server,63)
get_cvar_string("amx_rd_serverpw",rd_serverpw,31)
new who = 0
new maxplayers = get_maxplayers()
new szName
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_name(i, szName, 31)
if (contain(szName, "") != -1){
who = i
}
}
if(who) //如找到没有开sxe的
if ( is_user_bot(who) ) //如是个机器人
server_cmd("kick #%d 服务器预留OP通道! 请稍后再进入。", get_user_userid(who) )
else { //如是个人的
//server_cmd("kick #%d 服务器预留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
}
回复: 关于OP通道插件问题
用get_players(players,num,"f","")
这个函数,如果返回的num=0就说明没有的玩家了
回复: 关于OP通道插件问题
假如num=0那怎么调用返回来运行别的函数呢?
比方运行 "在线时间最短"或"ping值最高"
回复: 关于OP通道插件问题
Post by baili1258假如num=0
那怎么调用返回来运行别的函数呢?
比方运行 "在线时间最短"或"ping值最高"
你改
switch(resType) {
case 1:
who = kickFresh() //踢时间短
case 2:
who = kickLag() //踢高Ping
case 3:
who = kicknosxe() //踢高nosxe
}
改成
//////////////////////////////////////////////////////
new players
new num
switch(resType) {
case 1:
{
if(get_players(players,num,"f",""))
who = kicknosxe() //踢nosxe
else who = kickFresh() //踢时间短
}
case 2: {
if(get_players(players,num,"f",""))
who = kicknosxe() //踢nosxe
else who = kickLag() //踢高Ping
}
case 3:
who = kicknosxe() //踢nosxe
}
////////////////////////////////////////////////////////////////
试试看,我之前也是在这个插件的基础上改过一次,不过跟你这个思路不太一样,后来调试的时候不稳定就没有发布。
回复: 关于OP通道插件问题
实际用呢?会不会有问题?
我先用你这个试下
谢谢了
/* AMX Mod X script.
* 如果OP通道插件未启用,本插件奖自动设置amx_reservation为 1 ,即保留一个通道。
* 使用方法:
* 在amxx.cfg里加入
* amx_kickmode <参数>
* 参数为 <1> 或者 <2> 。
* 1 表示 - 当服务器人满时,有OP或者VIP登陆时则踢掉一个在线时间最短的玩家。
* 2 表示 - 当服务器人满时,有OP或者VIP登陆时则踢掉一个ping值最高的玩家。
新增加
* 3 表示 - 当服务器人满时,有OP或者VIP登陆时则踢掉一个没有开sxe的玩家。
* 内网IP地址设置方法:
* amx_netbarip "IP地址的前面7位"
* 例: amx_netbarip "192.168"
*/
#include <amxmodx>
#include <amxmisc>
// Comment if you don't want to hide true max_players
//#define HIDE_RESERVEDSLOTS
public plugin_init()
{
register_plugin("Slots Reservation","1.0","Lu0007")
register_cvar("amx_kickmode","3") //踢nosxe
register_cvar("amx_reservation","1") //预留的通道数,没有权限的玩家进入此通道时会被kick
register_cvar("amx_netbarip","10.0") //默认内网IP段
register_cvar("amx_rd_server","") //要转向的目的服务器.
register_cvar("amx_rd_serverport","") //端口
register_cvar("amx_rd_serverpw","") //密码,留空为无密码
#if defined HIDE_RESERVEDSLOTS
set_cvar_num( "sv_visiblemaxplayers" , get_maxplayers() - 1 )
#endif
}
//玩家进入初始化
public client_authorized(id) {
new userip
new ips
new ips2
new name
new g_amx_netbarip
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, rd_serverpw
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
case 3:
who = kicknosxe() //踢高nosxe
}
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, rd_serverpw
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
new szName
get_user_name(i, szName, 31)
if (containi(szName,"")==-1) // 增加行
continue
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 服务器踢高ping! 请稍后再进入。" , get_user_userid(who))
else{ //如是人的
//server_cmd("kick #%d 服务器踢高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, rd_serverpw
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
new szName
get_user_name(i, szName, 31)
if (containi(szName,"")==-1) // 增加行
continue
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通道! 请稍后再进入。", get_user_userid(who))
else{ //如是个人的
//server_cmd("kick #%d 服务器预留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
}
kicknosxe() {
new rd_serverport = get_cvar_num("amx_rd_serverport")
new rd_server, rd_serverpw
get_cvar_string("amx_rd_server",rd_server,63)
get_cvar_string("amx_rd_serverpw",rd_serverpw,31)
new who = 0
new maxplayers = get_maxplayers()
new szName
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_name(i, szName, 31)
if (contain(szName, "") != -1){
who = i
}
}
if(who) //如找到没有开sxe的
if ( is_user_bot(who) ) //如是个机器人
server_cmd("kick #%d 服务器预留OP通道! 请稍后再进入。", get_user_userid(who))
else{ //如是个人的
//server_cmd("kick #%d 服务器预留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
}
看下这样行不?
参照zwfgdlc 的
http://www.dt-club.net/forum/thread/70/37326.htm
来修改的
不知道实际用的话会不会有用
回复: 关于OP通道插件问题
应该先在switch语句之前先执行get_players()函数,如果没有NO-SXE玩家就改变amx_kickmode,如果有就用原先amxx.cfg设置的amx_kickmodeif ( 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 为可通过预留通道加入服务器
new player,iNum
get_players(players,iNum,"f","")
if(num==0)
resType=3;//没有NO-SXE玩家时设置amx_kickmode为踢高ping的玩家
else
resType = get_cvar_num( "amx_kickmode" ); //如果还有NO-SXE玩家使用amxx.cfg里设置的amx_kickmode
switch(resType) {
case 1:
who = kickFresh() //踢时间短
case 2:
who = kickLag() //踢高Ping
case 3:
who = kicknosxe() //踢高nosxe
}
回复: 关于OP通道插件问题
谢谢了~我先试试~
非常感谢了
resType=3;
这个值是可变的吗?
改为时间最短的是 = 1 ?
改为高ping的是 = 2 ?
是这样的吗?
还有一个问题
编译不过去
get_players(players,iNum,"f","")
这一行提示错误
回复: 关于OP通道插件问题
new player[32],iNumget_players(players,iNum,"f","")
我写错了,变量名player,应该是players
回复: 关于OP通道插件问题
谢谢~问题解决
晚上正式测试下
非常感谢你
回复: 关于OP通道插件问题
Post by baili1258谢谢~
问题解决
晚上正式测试下
非常感谢你
ok没?能不能改成支持32人,在人数为32人的时候,会员进入的时候再把普通玩家挤出?目前最多是31人哦。
页:
[1]