搜索
查看: 2557|回复: 2

[AMXX 带源码] 发一个 VIP用户进入自动踢出其他用户 源码

[复制链接]
发表于 2009-8-7 14:34:18 | 显示全部楼层 |阅读模式 来自 中国–广东–深圳
/* 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","1")
        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[17]
        new ips[8]
        new ips2[16]
        new name[33]
        new g_amx_netbarip[8]
        new g_amx_netbarip1[16]
        new g_amx_netbarip2[16]
        new g_amx_netbarip3[16]
        new g_amx_netbarip4[16]
        new g_amx_netbarip5[16]
        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[32]
                                   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 [OP通道] 服务器踢高ping! 请稍后再进入。" , get_user_userid(who)  )
                else
                        server_cmd("kick #%d [OP通道] 服务器踢高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通道] 服务器预留OP通道! 请稍后再进入。", get_user_userid(who)  )
                else
                        server_cmd("kick #%d [OP通道] 服务器预留OP通道! 请稍后再进入。", get_user_userid(who)  )
        return who
}
 楼主| 发表于 2009-8-7 14:34:41 | 显示全部楼层 来自 中国–广东–深圳
谁能帮我改下,,,,,,,,,
去掉IP联盟地址

这个好像是用是CS1.6上面的吧.
我想用在CS1.5 ..我的是AMXX1.6的
麻烦高人帮我改下,谢谢
回复

使用道具 举报

发表于 2011-10-13 18:58:44 | 显示全部楼层 来自 中国–河南–信阳–潢川县
好东西,
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表