搜索
查看: 3463|回复: 6

【已解决】死亡模式队伍平衡插件。

[复制链接]
发表于 2011-11-21 09:58:04 | 显示全部楼层 |阅读模式 来自 四川成都
本帖最后由 homework 于 2012-10-27 01:08 编辑

求个死亡模式下用的特殊功能队伍平衡功能插件。

插件用途:用于死亡模式服务器的队伍平衡。
插件功能:能在服务器出现CT、T两边人数相差2人时(或以上)自动平衡两边人数
特殊功能:能在玩家都活着的时候平衡两边队伍人数

问题描述:
1、死亡模式大家都知道死后马上复活,而且一局不会结束,一般的队伍平衡插件是在一局结束后进行判断然后平衡队伍人数;所以一般的队伍平衡插件使用在死亡F上没有实际效果。
2、还有这样的情况,死亡服务器上添加的有进入服务器后自动加入队伍插件,这样就可以避免玩家选择偏爱队伍造成不平衡。但是,比如现在CT、T队伍现在是8:8,突然一方退出2位玩家,就变成了6:8,而后一直没有玩家加入服务器,就造成了2边人数势力不平衡;所以需要一种能在人物活着的时候平衡队伍人数。

一点构思:
1、如果写这个插件可以用时间间隔来判断队伍人数(定时、循环),比如每30秒等,可以设置。
2、判定双方人数不平衡后(相差2人或以上)不管活着死亡(除观察员、正在连接玩家以外)自动平衡。
3、死亡模式可以设置玩家死亡后的复活时间,一般服务器设置为1-5秒,如果可以利用这段时间来平衡队伍可能会更人性化,不会让玩家被平衡的时候觉得太突然,但是估计会很麻烦,呵呵。

希望哪位大大帮忙发个此类插件 或 写个,不胜感激;小弟懂点点源码,但要写还有十分大的一段距离。

期待高手,希望此贴也能造福DT,和需要此插件的服务器管理员们,再次感谢。
 楼主| 发表于 2011-11-22 14:55:07 | 显示全部楼层 来自 四川成都
顶一下!!!!!!:) 希望有高手关注。
回复

使用道具 举报

发表于 2011-11-22 15:24:02 | 显示全部楼层 来自 安徽宿州
顶一个··
回复

使用道具 举报

发表于 2011-11-22 22:26:53 | 显示全部楼层 来自 云南西双版纳州景洪
试试这个插件

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注个册吧

×
回复

使用道具 举报

 楼主| 发表于 2011-11-29 10:41:13 | 显示全部楼层 来自 四川成都
感谢zhangsheng大大的关注,听说zhangsheng大大已经转向CSOL了,呵呵,
所以特别感谢。

您提供的插件我已经下载放服务器上测试,有测试结果我即时发出来。
回复

使用道具 举报

 楼主| 发表于 2011-12-6 11:34:26 | 显示全部楼层 来自 四川成都
zhangsheng大大,插件起到了平衡的作用。
想再请教几个问题,这个插件里面功能这样解释正确不,如下:
  1. /*        Copyright ?2008, ConnorMcLeod

  2.         Instant AutoTeamBalance is free software;
  3.         you can redistribute it and/or modify it under the terms of the
  4.         GNU General Public License as published by the Free Software Foundation.

  5.         This program is distributed in the hope that it will be useful,
  6.         but WITHOUT ANY WARRANTY; without even the implied warranty of
  7.         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  8.         GNU General Public License for more details.

  9.         You should have received a copy of the GNU General Public License
  10.         along with Instant AutoTeamBalance; if not, write to the
  11.         Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  12.         Boston, MA 02111-1307, USA.
  13. */

  14. #include <amxmodx>
  15. #include <cstrike>

  16. #define VERSION "DM 0.4.0"

  17. #define BALANCE_IMMUNITY                ADMIN_RCON

  18. #define MAX_PLAYERS        32

  19. enum {
  20.         aTerro,
  21.         aCt
  22. }

  23. new bool:g_bImmuned[MAX_PLAYERS+1]

  24. new Float:g_fJoinedTeam[MAX_PLAYERS+1] = {-1.0, ...}

  25. new g_pcvarCount, g_pcvarImmune, g_pCvarMessage

  26. new g_iCounter
  27. new mp_limitteams, mp_autoteambalance

  28. public plugin_init()
  29. {
  30.         register_plugin("AutoTeamBalance", VERSION, "ConnorMcLeod")

  31.         g_pcvarCount = register_cvar("atb_death_freq", "50")
  32.         g_pcvarImmune = register_cvar("atb_admins_immunity", "1")
  33.         g_pCvarMessage = register_cvar("iatb_message", "* 系统已自动平衡两队人数 *")

  34.         register_logevent("LogEvent_JoinTeam", 3, "1=joined team")
  35.         register_event("DeathMsg", "Event_DeathMsg", "a")

  36.         mp_limitteams = get_cvar_pointer("mp_limitteams")
  37.         mp_autoteambalance = get_cvar_pointer("mp_autoteambalance")
  38. }

  39. public Event_DeathMsg()
  40. {
  41.         new iFreq = get_pcvar_num(g_pcvarCount)
  42.         if( !iFreq || !get_pcvar_num(mp_autoteambalance) )
  43.                 return

  44.         if( ++g_iCounter < iFreq )
  45.                 return

  46.         g_iCounter = 0
  47.         balance_teams()
  48. }

  49. public LogEvent_JoinTeam()
  50. {
  51.         new loguser[80], name[32], id
  52.         read_logargv(0, loguser, 79)
  53.         parse_loguser(loguser, name, 31)
  54.         id = get_user_index(name)

  55.         g_fJoinedTeam[id] = get_gametime()
  56. }

  57. public client_authorized(id)
  58. {
  59.         g_bImmuned[id] = bool:(get_user_flags(id) & BALANCE_IMMUNITY)
  60. }

  61. public client_disconnect(id)
  62. {
  63.         g_iCounter = max(0, get_pcvar_num(g_pcvarCount) - 1)
  64. }

  65. balance_teams()
  66. {
  67.         new iPlayers[MAX_PLAYERS], iNum
  68.         new aTeams[2][MAX_PLAYERS], aNum[2], id

  69.         get_players(iPlayers, iNum, "h")

  70.         for(new i; i<iNum; i++)
  71.         {
  72.                 id = iPlayers[i]

  73.                 switch( cs_get_user_team(id) )
  74.                 {
  75.                         case CS_TEAM_T:
  76.                         {
  77.                                 aTeams[aTerro][aNum[aTerro]++] = id
  78.                         }
  79.                         case CS_TEAM_CT:
  80.                         {
  81.                                 aTeams[aCt][aNum[aCt]++] = id
  82.                         }
  83.                 }
  84.         }

  85.         new iCheck
  86.         new iTimes = aNum[aCt] - aNum[aTerro]

  87.         if(iTimes > 0)
  88.         {
  89.                 iCheck = aCt
  90.         }
  91.         else if(iTimes < 0)
  92.         {
  93.                 iCheck = aTerro
  94.         }
  95.         else
  96.         {
  97.                 return
  98.         }

  99.         iTimes = abs(iTimes)

  100.         // at this place iTimes is the players num difference between teams
  101.         if( iTimes < 2 || iTimes <= get_pcvar_num(mp_limitteams) )
  102.         {
  103.                 return
  104.         }

  105.         iTimes /= 2

  106.         new bool:bTransfered[MAX_PLAYERS+1],
  107.                 bool:bAdminsImmune = bool:get_pcvar_num(g_pcvarImmune)

  108.         new iLast, iCount
  109.         while( iTimes > 0 )
  110.         {
  111.                 iLast = 0
  112.                 for(new i=0; i <aNum[iCheck]; i++)
  113.                 {
  114.                         id = aTeams[iCheck][i]
  115.                         if( g_bImmuned[id] && bAdminsImmune )
  116.                         {
  117.                                 continue
  118.                         }
  119.                         if(bTransfered[id])
  120.                         {
  121.                                 continue
  122.                         }
  123.                         if(g_fJoinedTeam[id] > g_fJoinedTeam[iLast])
  124.                         {
  125.                                 iLast = id
  126.                         }
  127.                 }

  128.                 if(!iLast)
  129.                 {
  130.                         return
  131.                 }

  132.                 if( iCheck )
  133.                 {
  134.                         cs_set_user_team(iLast, CS_TEAM_T)
  135.                 }
  136.                 else
  137.                 {
  138.                         cs_set_user_team(iLast, CS_TEAM_CT)
  139.                 }

  140.                 bTransfered[iLast] = true
  141.                 iCount++
  142.                 iTimes--
  143.         }

  144.         new szMessage[128]
  145.         get_pcvar_string(g_pCvarMessage, szMessage, charsmax(szMessage))
  146.         client_print(0, print_center, szMessage)
  147. }
复制代码
g_pcvarImmune = register_cvar("atb_admins_immunity", "1") 这里1表示不平衡管理员权限人员,如果改成0,是不是就表示 管理员权限 也会被平衡?
g_pcvarCount = register_cvar("atb_death_freq", "50") 这里50是不是表示间隔多少时间平衡一次?
回复

使用道具 举报

发表于 2013-6-24 21:01:57 | 显示全部楼层 来自 辽宁鞍山
谢谢  
楼主分享~~~~:)
回复

使用道具 举报

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

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