搜索
查看: 1772|回复: 0

求助,以下代码是否可行?

[复制链接]
发表于 2009-9-29 21:34:44 | 显示全部楼层 |阅读模式 来自 日本
本帖最后由 cityhonghu 于 2009-9-29 21:37 编辑

简单化了通道插件,帮忙看一下能否实现满人情况下只有b权限的用户才能使用管理员通道。

代码如下(bot不考虑)
  1. #include <amxmodx>
  2. #include <amxmisc>

  3. public plugin_init()
  4. {
  5.         register_plugin("Slots Reservation","0.9.7","f117bomb")
  6. }

  7. public client_authorized(id) {

  8.         new maxplayers = get_maxplayers()
  9.         new players = get_playersnum( 1 )
  10.         new limit = maxplayers - 1
  11.         new who
  12.        
  13.         if ( players > limit ) //21/20
  14.         {
  15.                 who = kickLag()
  16.                 if(!who && !access(id, ADMIN_RESERVATION)) {
  17.                         client_cmd(id,"echo ^"Server is Full.^";disconnect")
  18.                         return PLUGIN_HANDLED // block connect in other plugins (especially in consgreet)         
  19.                 }
  20.                 return PLUGIN_CONTINUE                        
  21.         }
  22.         return PLUGIN_CONTINUE
  23. }

  24. kickLag() {
  25.         new who = 0, ping, loss, worst = -1
  26.         new maxplayers = get_maxplayers()
  27.         for(new i = 1; i <= maxplayers; ++i) {
  28.                 if ( !is_user_connected(i) && !is_user_connecting(i) )
  29.                         continue // not used slot  
  30.                 if (get_user_flags(i)&ADMIN_RESERVATION)
  31.                         continue // has reservation, skip him
  32.                 get_user_ping(i,ping,loss) // get ping
  33.                 if (ping <=100)
  34.                         continue
  35.                 if ( ping > worst ) {
  36.                         worst = ping
  37.                         who = i
  38.                 }
  39.         }
  40.         if(who)
  41.                 client_cmd(who,"echo ^"Dropped due to high ping to free slot for an admin^";disconnect")
  42.         return who  
  43. }
复制代码
游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

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