搜索
查看: 2736|回复: 6

这个插件编辑错误,高人帮忙看看

[复制链接]
发表于 2010-3-28 17:01:32 | 显示全部楼层 |阅读模式 来自 中国–广东–中山
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #if AMXX_VERSION_NUM < 180
  4. #define charsmax(%1) sizeof(%1) - 1
  5. #endif
  6. #define MAX_PLAYERS 32
  7. #define DEAD_FLAG (1<<0)
  8. #define OFFSET_TEAM 114
  9. enum {
  10. CS_TEAM_UNASSIGNED,
  11. CS_TEAM_T,
  12. CS_TEAM_CT,
  13. CS_TEAM_SPECTATOR
  14. }
  15. new bool:g_roundend
  16. new pcvar_percent
  17. new g_invisible[MAX_PLAYERS+1][2]
  18. new gmsgScoreAttrib, gmsgTeamInfo
  19. public plugin_init() {
  20. register_plugin("Invisible Spectator", "0.2", "ConnorMcLeod")
  21. pcvar_percent = register_cvar("amx_inv_dead_percent", "40")
  22. register_clcmd("amx_spectate", "make_invis")
  23. gmsgScoreAttrib = get_user_msgid("ScoreAttrib")
  24. gmsgTeamInfo = get_user_msgid("TeamInfo")
  25. register_message( gmsgScoreAttrib, "msg_ScoreAttrib")
  26. register_message( gmsgTeamInfo, "msg_TeamInfo")
  27. register_event("HLTV", "eNewRound", "a", "1=0", "2=0")
  28. register_logevent("eRoundEnd", 2, "1=Round_End")
  29. register_event("ResetHUD", "eResetHUD", "be")
  30. register_event("DeathMsg", "eDeathMsg", "a")
  31. }
  32. public make_invis(id) {
  33. if( !(get_user_flags(id) & ADMIN_RCON) )
  34. return PLUGIN_CONTINUE
  35. if(g_invisible[id][0])
  36. {
  37. client_print(id, print_console, "您不是无形的观众!")
  38. g_invisible[id][0] = 0
  39. return PLUGIN_HANDLED
  40. }

  41. if( is_user_alive(id) )
  42. {
  43. client_print(id, print_console, "你必须死后,才可以使用无形观众.")
  44. return PLUGIN_HANDLED
  45. }
  46. g_invisible[id][0] = 1
  47. client_print(id, print_console, "您现在一种无形的观众!")
  48. new team = get_pdata_int(id, OFFSET_TEAM)
  49. if( CS_TEAM_T <= team <= CS_TEAM_CT )
  50. {
  51. g_invisible[id][1] = team
  52. set_pdata_int(id, OFFSET_TEAM, CS_TEAM_SPECTATOR)
  53. }
  54. else
  55. {
  56. new players[MAX_PLAYERS], tnum, ctnum
  57. get_players(players, tnum, "e", "TERRORIST")
  58. get_players(players, ctnum, "e", "CT")
  59. g_invisible[id][1] = ctnum > tnum ? 1 : 2
  60. }
  61. send_ScoreAttrib(id, 0)
  62. new teamname[12]
  63. switch( g_invisible[id][1] )
  64. {
  65. case 1:formatex(teamname, charsmax(teamname), "TERRORIST")
  66. case 2:formatex(teamname, charsmax(teamname), "CT")
  67. }
  68. send_TeamInfo(id, teamname)
  69. return PLUGIN_HANDLED
  70. }
  71. public eDeathMsg() {
  72. if(g_roundend)
  73. return
  74. new players[MAX_PLAYERS], dead, inum, player, Float:percent = get_pcvar_float(pcvar_percent) / 100.0
  75. get_players(players, dead, "bh")
  76. get_players(players, inum, "h")
  77. if( float(dead) / float(inum) < percent)
  78. return
  79. for(new i; i < inum; i++)
  80. {
  81. player = players
  82. if( g_invisible[player][0] )
  83. send_ScoreAttrib(player, DEAD_FLAG)
  84. }
  85. }
  86. public eNewRound() {
  87. g_roundend = false
  88. new players[MAX_PLAYERS], inum, player
  89. get_players(players, inum)
  90. for(new i; i < inum; i++)
  91. {
  92. player = players
  93. if( g_invisible[player][0] )
  94. send_ScoreAttrib(player, 0)
  95. }
  96. }
  97. public eRoundEnd() {
  98. g_roundend = true
  99. new players[MAX_PLAYERS], inum, player
  100. get_players(players, inum)
  101. for(new i; i < inum; i++)
  102. {
  103. player = players
  104. if( g_invisible[player][0] )
  105. send_ScoreAttrib(player, DEAD_FLAG)
  106. }
  107. }
  108. public eResetHUD(id) {
  109. if( g_invisible[id][0] )
  110. g_invisible[id][0] = 0
  111. }
  112. // Doesn't seem to work so set flag to 0 at NewRound event.
  113. public msg_ScoreAttrib(msg_type, msg_dest, target) {
  114. if(!g_invisible[get_msg_arg_int(1)][0])
  115. return PLUGIN_CONTINUE
  116. new flags = get_msg_arg_int(2)
  117. if(flags & DEAD_FLAG)
  118. set_msg_arg_int(2, 0, flags & ~DEAD_FLAG)
  119. return PLUGIN_CONTINUE
  120. }
  121. public msg_TeamInfo(msg_type, msg_dest, target) {
  122. new id = get_msg_arg_int(1)
  123. if(!g_invisible[id][0])
  124. return PLUGIN_CONTINUE
  125. new teamname[12]
  126. get_msg_arg_string(2, teamname, charsmax(teamname))
  127. if( g_invisible[id][1] == CS_TEAM_T && strcmp(teamname, "TERRORIST") != 0 )
  128. set_msg_arg_string(2, "TERRORIST")
  129. else if( g_invisible[id][1] == CS_TEAM_CT && strcmp(teamname, "CT") != 0 )
  130. set_msg_arg_string(2, "CT")
  131. return PLUGIN_CONTINUE
  132. }
  133. send_ScoreAttrib(id, flags)
  134. {
  135. message_begin(MSG_ALL, gmsgScoreAttrib, _, 0)
  136. write_byte(id)
  137. write_byte(flags)
  138. message_end()
  139. }
  140. send_TeamInfo(id, teamname[])
  141. {
  142. message_begin(MSG_ALL, gmsgTeamInfo, _, 0)
  143. write_byte(id)
  144. write_string(teamname)
  145. message_end()
  146. }
复制代码

本帖子中包含更多资源

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

×
发表于 2010-3-29 16:34:23 | 显示全部楼层 来自 中国–浙江–杭州
你看着改

本帖子中包含更多资源

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

×
回复

使用道具 举报

 楼主| 发表于 2010-3-30 10:15:41 | 显示全部楼层 来自 中国–广东–中山
还是编辑不成功
回复

使用道具 举报

发表于 2010-3-30 10:59:47 | 显示全部楼层 来自 中国–广西–百色–那坡县
本帖最后由 心静如水 于 2010-3-30 12:07 编辑

试试看.................

谁忘了周爷爷....我跟谁急............

本帖子中包含更多资源

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

×
回复

使用道具 举报

发表于 2010-3-30 20:49:54 | 显示全部楼层 来自 中国–浙江–杭州
楼上的哪跟筋不对了
回复

使用道具 举报

发表于 2010-3-30 21:49:31 | 显示全部楼层 来自 中国–广西–南宁
你那些参数未定义
回复

使用道具 举报

发表于 2010-4-14 22:17:59 | 显示全部楼层 来自 中国–江西–南昌
路过,

咱不是高人
回复

使用道具 举报

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

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