|
本帖最后由 visa567 于 2009-9-28 23:11 编辑
这是一个转F插件 不会与中文ID 冲突
但编译的时候会报错 AMXX 1.76C
下面是代码
- /* 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","2")
- //预留的通道数,没有权限的玩家进入此通道时会被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 teamname[5][] = { "", "TERRORIST", "CT", "SPECTATOR", ""}
- new szUserName[33]
- get_user_name(id, szUserName, 32)
- new szMessage[164]
- 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
- }
- if(get_user_flags(id) & ADMIN_BAN)
- {
- format(szMessage, 163, "^x01【^x03服务器OP^x01】%s 连接中...", szUserName)
- msg_teaminfo( 0, id, teamname[1])
- }
- msg_saytext( 0, id, szMessage)
- new team[32]
- get_user_team(id, team, 31)
- msg_teaminfo( 0, id, team)//此处恢复
- }
- //踢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
- new name[32] // 增加行
- get_user_name(i,name,31) // 增加行
- if(containi(name,"[NO-sXe-I]")==-1) // 增加行
- continue // 增加行
- get_user_ping(i,ping,loss) // get ping
- if ( ping > worst ) { //找出Ping最大的
- worst = ping
- who = i
- client_print(0,print_chat,"服务器为保留预留通道,将%s转服,ping值=%d.",who,ping)
- }
- }
- 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
- }
- //踢时间短的
- 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通道] 请稍后再进.", 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
- }
- public msg_teaminfo( playerid, colorid, msg[])
- {
- message_begin( playerid?MSG_ONE:MSG_ALL, get_user_msgid("TeamInfo"), {0,0,0}, playerid)
- write_byte(colorid)
- write_string(msg)
- message_end()
- }
- public msg_saytext( playerid, colorid, msg[])
- {
- message_begin( playerid?MSG_ONE:MSG_ALL, get_user_msgid("SayText"), {0,0,0}, playerid)
- write_byte(colorid)
- write_string(msg)
- message_end()
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注个册吧
×
|