求助,以下代码是否可行?
本帖最后由 cityhonghu 于 2009-9-29 21:37 编辑简单化了通道插件,帮忙看一下能否实现满人情况下只有b权限的用户才能使用管理员通道。
代码如下(bot不考虑)#include <amxmodx>
#include <amxmisc>
public plugin_init()
{
register_plugin("Slots Reservation","0.9.7","f117bomb")
}
public client_authorized(id) {
new maxplayers = get_maxplayers()
new players = get_playersnum( 1 )
new limit = maxplayers - 1
new who
if ( players > limit ) //21/20
{
who = kickLag()
if(!who && !access(id, ADMIN_RESERVATION)) {
client_cmd(id,"echo ^"Server is Full.^";disconnect")
return PLUGIN_HANDLED // block connect in other plugins (especially in consgreet)
}
return PLUGIN_CONTINUE
}
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 <=100)
continue
if ( ping > worst ) {
worst = ping
who = i
}
}
if(who)
client_cmd(who,"echo ^"Dropped due to high ping to free slot for an admin^";disconnect")
return who
}
页:
[1]