tlxch 发表于 2009-2-28 16:32:53

发几个预留通道的源码,暂时解决netbar.amxx 和中文ID 冲突~

先来第一个:

/* AMX Mod X script.
*
* (c) 2006, OLO
* This file is provided as is (no warranties).
*
* Set you server max_players to 1 above the desirered value (ie. 21 or 33).
* Query programs will see max_players -1 as max. Admins with reservation
* can connect when there is 20/20 and player with worst ping or least play time
* will be kicked.
*
* 如果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"
*
* IP联盟地址设置方法:
* amx_netbarip1 "IP地址"
* amx_netbarip2 "IP地址"
* amx_netbarip3 "IP地址"
* amx_netbarip4 "IP地址"
* amx_netbarip5 "IP地址"
* 例:
* amx_netbarip1 "192.168.0.1"
* amx_netbarip2 "222.218.124.96"
* amx_netbarip3 "125.83.0.45"
* amx_netbarip4 "221.127.245.22"
* amx_netbarip5 "222.83.176.68"
*
*
*/

#include <amxmodx>
#include <amxmisc>


public plugin_init()
{
        register_plugin("Slots Reservation","1.0","KuaiLn")
        register_cvar("amx_kickmode","1")
        register_cvar("amx_reservation","2")
        register_cvar("amx_netbarip","192.168")
        register_cvar("amx_netbarip1","192.168.0.1")
        register_cvar("amx_netbarip2","192.168.0.2")
        register_cvar("amx_netbarip3","192.168.0.3")
        register_cvar("amx_netbarip4","192.168.0.4")
        register_cvar("amx_netbarip5","192.168.0.5")
       
}

public client_authorized(id) {

        new userip
        new ips
        new ips2
        new name
        new g_amx_netbarip
        new g_amx_netbarip1
        new g_amx_netbarip2
        new g_amx_netbarip3
        new g_amx_netbarip4
        new g_amx_netbarip5
        get_user_ip(id,userip,16,1)
        copy(ips,7,userip)
        copy(ips2,16,userip)
        get_cvar_string("amx_netbarip",g_amx_netbarip,7)
        get_cvar_string("amx_netbarip1",g_amx_netbarip1,16)
        get_cvar_string("amx_netbarip2",g_amx_netbarip2,16)
        get_cvar_string("amx_netbarip3",g_amx_netbarip3,16)
        get_cvar_string("amx_netbarip4",g_amx_netbarip4,16)
        get_cvar_string("amx_netbarip5",g_amx_netbarip5,16)
        get_user_name(id,name,32)
       
        new maxplayers = get_maxplayers()
        new players = get_playersnum( 1 )
        new limit = maxplayers - get_cvar_num("amx_reservation")
        new resType = get_cvar_num( "amx_kickmode" )
        new who



        if ( players > limit ) //21/20
        {
                if ( get_user_flags(id) & ADMIN_RESERVATION || (equali(ips,g_amx_netbarip)) || (equali(ips2,g_amx_netbarip1)) || (equali(ips2,g_amx_netbarip2)) || (equali(ips2,g_amx_netbarip3)) || (equali(ips2,g_amx_netbarip4)) || (equali(ips2,g_amx_netbarip5)))
                {
                        set_user_flags(id,read_flags("b"))
                        switch(resType) {   
                                case 1:
                                        who = kickFresh()
                                case 2:
                                        who = kickLag()
                        }
                        if(who){
                                //new name
                                   get_user_name( who, name , 31 )
                                   client_cmd(id,"echo ^"* %s was kicked to free this slot^"" ,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))
                       
                return PLUGIN_HANDLED
        }
        return PLUGIN_CONTINUE
}

kickLag() {
        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 ) {
                        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))
        return who
}

kickFresh() {
        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))
        return who
}

tlxch 发表于 2009-2-28 16:33:57

在来一个


/* 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高的
        register_cvar("amx_reservation","1")
      //预留的通道数,没有权限的玩家进入此通道时会被kick
        register_cvar("amx_netbarip","10.0")
        //默认内网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
        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
                                        }
                        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
}

tlxch 发表于 2009-2-28 16:35:33

继续来一个
AMXX.CFG文件中加入:

//需要转到的服务器IP

amx_rd_server "222.83.228.102"
//服务器端口
amx_rd_serverport "27015"
//无登陆密码就留空
amx_rd_serverpw ""

插件开始:


#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

new msg

public plugin_init() {
   register_plugin("NetBar","3.0","A.MI")
   register_cvar("amx_netbarip","192.168")
   register_cvar("amx_rd_server","x.x.x.x") //要转向的目的服务器.
   register_cvar("amx_rd_serverport","27015") //端口
   register_cvar("amx_rd_serverpw","") //密码,留空为无密码
   register_logevent("round_start", 2, "1=Round_Start")
   return PLUGIN_CONTINUE
}

public round_start(){
        new players,num
        get_players( players, num)
        for (new i = 0; i < num; i++){
        new player = players
       
        if( get_user_frags(player)<=3 ){
        if( get_user_frags(player)-get_user_deaths(player) <= -8 )
        server_cmd("kick #%d^"请您重新进入并努力杀敌^"", get_user_userid(player))
        }
        }
        return PLUGIN_HANDLED
}

public client_authorized(id){
        new userip
        new ips
        new name
        new g_amx_netbarip
        get_user_ip(id,userip,16,1)
        copy(ips,7,userip)
        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 SZplayer = get_playersnum(1)
       
        if ( (get_user_flags(id)&ADMIN_RESERVATION) || equali(ips,g_amx_netbarip) ){
       
        format( msg,127,"(欢迎会员):%s(%s)",name,userip);
        set_hudmessage(0, 255, 255, 0.01, 0.85, 0, 3.0, 4.0, 0.1, 1.0, 8);
        show_hudmessage(0, msg);
       
        if( SZplayer >= (maxplayers-1) ){
        kickFresh();
        }
       
        return PLUGIN_CONTINUE
        }
        if( SZplayer >= (maxplayers - 1) ){
        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_CONTINUE
        }
       
        format( msg,127,"(普通玩家):%s(%s)正在连线!",name,userip)
        set_hudmessage(248, 248, 255, 0.01, 0.9, 0, 3.0, 4.0, 0.1, 1.0, 8)
        show_hudmessage(0, msg)
       
        return PLUGIN_CONTINUE
}

public kickFresh() {
new name
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 players,num
get_players( players, num)
for (new i = 0; i < num; i++){
new player = players
if( get_user_frags(player)<=3 ){
if( get_user_frags(player)-get_user_deaths(player) <= -7 && !access(player,ADMIN_RESERVATION)){
get_user_name( player, name , 31 );

format( msg,127,"为了保留会员通道已把 %s 转服!",name);
set_hudmessage(0, 255, 255, 0.6, 0.7, 0, 3.0, 4.0, 0.1, 1.0, 8);
show_hudmessage(0, msg);

client_cmd(player,"echo ^"Redirection - Set Password to %s^";password %s",rd_serverpw,rd_serverpw)
client_cmd(player,"echo ^"Redirection -Redirecting to %s:%d^";connect %s:%d",rd_server,rd_serverport,rd_server,rd_serverport)

return PLUGIN_CONTINUE
}
if( get_user_frags(player)-get_user_deaths(player) <= -6 && !access(player,ADMIN_RESERVATION)){
get_user_name( player, name , 31 );

format( msg,127,"为了保留会员通道已把 %s 转服!",name);
set_hudmessage(0, 255, 255, 0.6, 0.7, 0, 3.0, 4.0, 0.1, 1.0, 8);
show_hudmessage(0, msg);

client_cmd(player,"echo ^"Redirection - Set Password to %s^";password %s",rd_serverpw,rd_serverpw)
client_cmd(player,"echo ^"Redirection -Redirecting to %s:%d^";connect %s:%d",rd_server,rd_serverport,rd_server,rd_serverport)

return PLUGIN_CONTINUE
}
if( get_user_frags(player)-get_user_deaths(player) <= -5 && !access(player,ADMIN_RESERVATION)){
get_user_name( player, name , 31 );

format( msg,127,"为了保留会员通道已把 %s 转服!",name);
set_hudmessage(0, 255, 255, 0.6, 0.7, 0, 3.0, 4.0, 0.1, 1.0, 8);
show_hudmessage(0, msg);

client_cmd(player,"echo ^"Redirection - Set Password to %s^";password %s",rd_serverpw,rd_serverpw)
client_cmd(player,"echo ^"Redirection -Redirecting to %s:%d^";connect %s:%d",rd_server,rd_serverport,rd_server,rd_serverport)

return PLUGIN_CONTINUE
}
if( get_user_frags(player)-get_user_deaths(player) <= -4 && !access(player,ADMIN_RESERVATION)){
get_user_name( player, name , 31 );

format( msg,127,"为了保留会员通道已把 %s 转服!",name);
set_hudmessage(0, 255, 255, 0.6, 0.7, 0, 3.0, 4.0, 0.1, 1.0, 8);
show_hudmessage(0, msg);

client_cmd(player,"echo ^"Redirection - Set Password to %s^";password %s",rd_serverpw,rd_serverpw)
client_cmd(player,"echo ^"Redirection -Redirecting to %s:%d^";connect %s:%d",rd_server,rd_serverport,rd_server,rd_serverport)

return PLUGIN_CONTINUE
}
if( get_user_frags(player)-get_user_deaths(player) <= -3 && !access(player,ADMIN_RESERVATION)){
get_user_name( player, name , 31 );

format( msg,127,"为了保留会员通道已把 %s 转服!",name);
set_hudmessage(0, 255, 255, 0.6, 0.7, 0, 3.0, 4.0, 0.1, 1.0, 8);
show_hudmessage(0, msg);

client_cmd(player,"echo ^"Redirection - Set Password to %s^";password %s",rd_serverpw,rd_serverpw)
client_cmd(player,"echo ^"Redirection -Redirecting to %s:%d^";connect %s:%d",rd_server,rd_serverport,rd_server,rd_serverport)

return PLUGIN_CONTINUE
}
if( get_user_frags(player)-get_user_deaths(player) <= -2 && !access(player,ADMIN_RESERVATION)){
get_user_name( player, name , 31 );

format( msg,127,"为了保留会员通道已把 %s 转服!",name);
set_hudmessage(0, 255, 255, 0.6, 0.7, 0, 3.0, 4.0, 0.1, 1.0, 8);
show_hudmessage(0, msg);

client_cmd(player,"echo ^"Redirection - Set Password to %s^";password %s",rd_serverpw,rd_serverpw)
client_cmd(player,"echo ^"Redirection -Redirecting to %s:%d^";connect %s:%d",rd_server,rd_serverport,rd_server,rd_serverport)

return PLUGIN_CONTINUE
}
if( get_user_frags(player)-get_user_deaths(player) <= -1 && !access(player,ADMIN_RESERVATION)){
get_user_name( player, name , 31 );

format( msg,127,"为了保留会员通道已把 %s 转服!",name);
set_hudmessage(0, 255, 255, 0.6, 0.7, 0, 3.0, 4.0, 0.1, 1.0, 8);
show_hudmessage(0, msg);

client_cmd(player,"echo ^"Redirection - Set Password to %s^";password %s",rd_serverpw,rd_serverpw)
client_cmd(player,"echo ^"Redirection -Redirecting to %s:%d^";connect %s:%d",rd_server,rd_serverport,rd_server,rd_serverport)
return PLUGIN_CONTINUE
}
}
}
return PLUGIN_CONTINUE
}

tlxch 发表于 2009-3-2 15:54:47

没人顶啊??????

axot 发表于 2009-3-2 16:47:21

传说中的netbar3.0? 这个跟中文id冲突是吧

Joseph 发表于 2009-3-2 17:05:46

也,这码很面熟,达哥弄的还真有用-。-

axot 发表于 2009-3-2 17:22:03

我测试了 register_plugin("NetBar","3.0","A.MI") 这个 跟中文id没冲突呀

wan482 发表于 2009-3-2 22:24:10

:(
由于冲突我服务器挂NN次了
单单只使用netbar和admin其他插件都没有开
使用axot的补丁一换中文名就挂掉

小白 发表于 2009-3-10 05:15:30

这个东东真不错

zwfgdlc 发表于 2009-3-10 08:50:37

不明白什么叫冲突,最多也就是没有之前权限,造成当有VIP权限玩家进来时被挤出去而已
页: [1] 2 3
查看完整版本: 发几个预留通道的源码,暂时解决netbar.amxx 和中文ID 冲突~