搜索
查看: 3620|回复: 2

Admin_radar插件的问题

[复制链接]
发表于 2013-7-6 13:28:48 | 显示全部楼层 |阅读模式 来自 中国–福建–厦门
就是管理员在雷达上看到所有人的插件
在CS1.6里能用,没什么问题

但是到CS1.5里用这个插件,一当土匪就自动退出,显示如下图

按确定就退了


求大神们解答
  1. /* * * * * * * * * * * * * * * * * * * * * * * *
  2. *    Admin_radar, by BlueRaja (AMX Mod X)     *
  3. *                                             *
  4. *      Special thanks to Damaged Soul         *
  5. * - not just for helping me when I needed it, *
  6. *    but for putting up with all my shit ^_^  *
  7. *                                             *
  8. *          (c) Copyright 2004                 *
  9. * This file is provided as is (no warranties) *
  10. * * * * * * * * * * * * * * * * * * * * * * * */


  11. //Includes
  12. #include <amxmodx>
  13. #include <cstrike> //used for cs_get_user_team

  14. //Defines
  15. #define ACCESS_LEVEL ADMIN_RCON //Default required admin level - don't want too many admins to have it, for the sake of speed
  16. #define REFRESH_TIME 1.0        //Amount of time, in seconds, between radar-refreshings

  17. //Messages
  18. new gmsgBombDrop                //Dropping of the bomb
  19. new gmsgHostagePos        //Position of hostage(s)
  20. new gmsgHostageK                //Hostage has been killed

  21. //Globals
  22. new g_aAdminList[32], g_iAdminNum
  23. new g_aCTList[32], g_iCTNum
  24. new g_aTList[32], g_iTNum
  25. new g_iEnemyCounter, g_iHostageCounter //Both are used for keeping track of the enemy
  26. new g_iHostageModNum //Number with which to modulus hostage number; used to,
  27.                      //if there are less than 4 T's, kill a fake-hostage blip.
  28. new bool:g_bBombHeld

  29. //Refreshes the list of admins
  30. public refresh_admin()
  31. {
  32.         new aTemp[32], iTempNum
  33.         get_players(aTemp, iTempNum, "c")//Skip bots

  34.         g_iAdminNum=0
  35.         for (new i=0; i<iTempNum; i++) {
  36.                 if (get_user_flags(aTemp[i])&ACCESS_LEVEL) {
  37.                         g_aAdminList[g_iAdminNum]=aTemp[i]
  38.                         g_iAdminNum++
  39.                 }//end if
  40.         }//end for
  41.         return PLUGIN_HANDLED
  42. }//end refresh_admin

  43. //Refresh list of terrorists
  44. public refresh_t() {
  45.         get_players(g_aTList, g_iTNum, "ae", "TERRORIST")
  46.         if (g_iTNum<4 && g_iHostageModNum!=g_iTNum) {
  47.                 g_iHostageModNum=g_iTNum //Only modulus with this number now

  48.                 //If there are three players left, then we want to fake-kill the fourth fake-hostage,
  49.                 //so that there aren't two blips on the radar for one player
  50.                 for(new i=0; i<g_iAdminNum; i++) {
  51.                         if (cs_get_user_team(g_aAdminList[i])==CS_TEAM_CT) {
  52.                                 message_begin(MSG_ONE, gmsgHostageK, {0,0,0}, g_aAdminList[i])
  53.                                 write_byte(g_iTNum+1)        //Hostage to take off of radar
  54.                                 message_end()
  55.                         }//end if
  56.                 }//end for
  57.         }//end if
  58. }//end refresh_t()

  59. //Refresh list of CT's
  60. #define refresh_ct() get_players(g_aCTList, g_iCTNum, "ae", "CT")
  61.         //I wanted the above to be an inline function, but I don't think Small supports that,
  62.         // so I used a macro instead

  63. //This function will be called every second; it should display a single blip for a certain player
  64. public radar_event(id)
  65. {
  66.         if(!g_iAdminNum || !g_iCTNum || !g_iTNum) return PLUGIN_HANDLED

  67.         new iEnemyT = g_aTList[g_iEnemyCounter%g_iTNum] //Cycle through the living Ts
  68.         new iCoordsT[3]
  69.         get_user_origin(iEnemyT, iCoordsT)

  70.         new iEnemyCT = g_aCTList[g_iEnemyCounter++%g_iCTNum]
  71.         new iCoordsCT[3]
  72.         get_user_origin(iEnemyCT, iCoordsCT)

  73.         new iHostageNum = (g_iHostageCounter++)%g_iHostageModNum + 1

  74.         for(new i=0; i<g_iAdminNum; i++)
  75.         {
  76.                 //At this point, we know we want to send the message to the admin
  77.                 if (cs_get_user_team(g_aAdminList[i])==CS_TEAM_T) {                       
  78.                         if (g_bBombHeld) { //If bomb is on the ground, the admins need to see it on their radar
  79.                                 message_begin(MSG_ONE, gmsgBombDrop, {0,0,0}, g_aAdminList[i])
  80.                                 write_coord(iCoordsCT[0])        //X Coordinate
  81.                                 write_coord(iCoordsCT[1])        //Y Coordinate
  82.                                 write_coord(iCoordsCT[2])        //Z Coordinate
  83.                                 write_byte(0)                        //?? This byte seems to always be 0...so, w/e
  84.                                 message_end()
  85.                         }
  86.                 }
  87.                 else { //assume player is CT
  88.                         message_begin(MSG_ONE, gmsgHostagePos, {0,0,0}, g_aAdminList[i])
  89.                         write_byte(1)                        //No idea what this byte does; I think it has something to do with whether or not the hostage is following someone
  90.                         write_byte(iHostageNum)                //The number of the hostage, 1-4
  91.                         write_coord(iCoordsT[0])        //X Coordinate
  92.                         write_coord(iCoordsT[1])        //Y Coordinate
  93.                         write_coord(iCoordsT[2])        //Z Coordinate
  94.                         message_end()
  95.                 }//end if
  96.         }//end for
  97.         return PLUGIN_HANDLED
  98. }//end radar_event

  99. //Called at round start
  100. public RoundStart()
  101. {
  102.         new Float:fRoundTime = get_cvar_float("mp_roundtime") * 60.0
  103.         new iTimeLeft = read_data(1)

  104.         if (fRoundTime == iTimeLeft) { //Roundstart after freezetime
  105.                 g_iHostageCounter = 0
  106.                 g_iEnemyCounter   = 0
  107.                 g_iHostageModNum  = 4
  108.                 g_bBombHeld       = true
  109.                 refresh_t()
  110.                 refresh_ct()

  111.                 //The hostage "killed" is only #(g_iTNum+1); however, apparently when the engine receieves a HostagePos message,
  112.                 //It assumes there are four hostages.  Therefore, when playing with less than three people, the hostages not represented
  113.                 //by players and not yet killed are set, by default, at the center of the map.  To fix this, I'll have to kill hostage #4
  114.                 //(if there are two players) or hostages #3 & #4 (if there is only one player)
  115.                 if (g_iTNum<3) {
  116.                         for (new i=g_iTNum+2; i<=4; i++) {
  117.                                 for(new j=0; j<g_iAdminNum; j++) {
  118.                                         message_begin(MSG_ONE, gmsgHostageK, {0,0,0}, g_aAdminList[j])
  119.                                         write_byte(i)        //Hostage to take off of radar
  120.                                         message_end()
  121.                                 }//end for
  122.                         }//end for
  123.                 }//end if
  124.         }//end if
  125.         return PLUGIN_CONTINUE
  126. }//end RoundStart

  127. //Initialization
  128. public plugin_init()
  129. {
  130.         gmsgBombDrop   = get_user_msgid("BombDrop")
  131.         gmsgHostagePos = get_user_msgid("HostagePos")
  132.         gmsgHostageK   = get_user_msgid("HostageK")
  133.         register_event("RoundTime", "RoundStart", "bc")
  134.         register_event("BombDrop", "Bomb_Drop", "bc")
  135.         register_event("BombPickup", "Bomb_Pickup", "bc")
  136.         register_plugin("Admin Radar","1.1","BlueRaja")
  137.         register_concmd("amx_refresh","refresh_admin",ACCESS_LEVEL," - refresh admin slots(adminradar)")
  138.         set_task(REFRESH_TIME, "radar_event", _, _, _, "b")
  139.         return PLUGIN_CONTINUE
  140. }

  141. //refresh list on client connect/disconnect
  142. public client_authorized(id)
  143. {
  144.         refresh_admin()
  145. }
  146. public client_disconnect(id)
  147. {
  148.         refresh_admin()
  149.         refresh_t()
  150.         refresh_ct()
  151. }

  152. //Refresh list of players on client death
  153. public client_kill(id)//Called when a player kills himself
  154. {
  155.         if (cs_get_user_team(id)==CS_TEAM_T) {
  156.                 refresh_t()
  157.         }
  158.         else{
  159.                 refresh_ct()
  160.         }
  161. }

  162. public client_death(killer, victim, weapon, hitplace, TK) //Called when a player dies
  163. {
  164.         if (cs_get_user_team(victim)==CS_TEAM_T) {
  165.                 refresh_t()
  166.         }
  167.         else{
  168.                 refresh_ct()
  169.         }
  170. }

  171. public Bomb_Drop()
  172. {
  173.         g_bBombHeld = false
  174. }

  175. public Bomb_Pickup()
  176. {
  177.         g_bBombHeld = true
  178. }
复制代码
插件源码如上,这是什么问题,如何解决?

本帖子中包含更多资源

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

×
发表于 2013-8-7 14:05:23 | 显示全部楼层 来自 中国–上海–上海
对1.5没有研究,不知道
回复

使用道具 举报

发表于 2013-10-16 08:06:27 | 显示全部楼层 来自 中国–北京–北京
从来没研究过1.5 1.6到是可以实现
回复

使用道具 举报

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

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