HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /***************************************************************************\
  2. =====================================
  3. * || [ZP] Classes In Chat v1.1 || *
  4. =====================================
  5.  
  6. -------------------
  7. *||DESCRIPTION||*
  8. -------------------
  9.  
  10. This plugins adds classes in chat for eg:
  11. If a person is survivor and he says something then this is what it
  12. would look like
  13. [Survivor] Player: Hi I am a survivor
  14. To make the chat more interesting, the chat is in colors
  15.  
  16. Original Plugin thread is located here:
  17. http://forums.alliedmods.net/showthread.php?t=120557
  18.  
  19. ---------------
  20. *||CREDITS||*
  21. ---------------
  22.  
  23. - MeRcyLeZZ ----> For some of the natives
  24. - My Sister ----> For taking the some screen shots
  25.  
  26. ------------------
  27. *||CHANGE LOG||*
  28. ------------------
  29.  
  30. v1.0 ====> - Initial Release
  31. v1.0 ====> - Re-wrote the whole plugin
  32. - Removed the color chat include and added a new color chat
  33. system.
  34. - Fixed almost, all the bugs which were reported
  35.  
  36. \***************************************************************************/
  37.  
  38. #include <amxmodx>
  39. #include <cstrike>
  40. #include <zombieplague>
  41.  
  42. // Variables
  43. new g_msg_saytext, g_msg_teaminfo, g_new_round
  44.  
  45. // Team names used by the team info message
  46. new const team_names[][] =
  47. {
  48. "UNASSIGNED",
  49. "TERRORIST",
  50. "CT",
  51. "SPECTATOR"
  52. }
  53.  
  54. // Color indexes for color chat message
  55. enum
  56. {
  57. RED = 1,
  58. BLUE,
  59. GREY
  60. }
  61.  
  62. public plugin_init()
  63. {
  64. // Register the plugin
  65. register_plugin("[ZP] Classes In Chat", "1.1", "@bdul!")
  66.  
  67. // Client say commands
  68. register_clcmd("say", "hook_say")
  69. register_clcmd("say_team", "hook_team_say")
  70.  
  71. // Round start event
  72. register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  73.  
  74. // Message IDs'
  75. g_msg_saytext = get_user_msgid("SayText")
  76. g_msg_teaminfo = get_user_msgid("TeamInfo")
  77.  
  78. // This var should be set true to prevent a bug
  79. g_new_round = true
  80. }
  81.  
  82. // Check for new round and update the var accordingly
  83. public event_round_start() g_new_round = true
  84. public zp_round_started() g_new_round = false
  85.  
  86. // Player's chat hook
  87. public hook_say(id)
  88. {
  89. // Retrieve the player's chat
  90. static chat[192], name[32], users_team
  91. read_args(chat, 191)
  92. remove_quotes(chat)
  93.  
  94. // Trying to fool us ?
  95. if(!chat[0])
  96. return PLUGIN_CONTINUE
  97.  
  98. // Retrieve player's name
  99. get_user_name(id, name, charsmax(name))
  100.  
  101. // Retrieve player's team
  102. users_team = _:cs_get_user_team(id)
  103.  
  104. // Alive user chat
  105. if (is_user_alive(id))
  106. {
  107. if (zp_get_user_zombie(id))
  108. color_chat(0, id, users_team, RED, "^3[%s]^4 %s:^1 %s", zp_get_user_nemesis(id) ? "Nemesis" : "Zombie", name, chat)
  109. else
  110. color_chat(0, id, users_team, BLUE, "^3[%s]^4 %s:^1 %s", zp_get_user_survivor(id) ? "Survivor" : "Human", name, chat)
  111. }
  112.  
  113. // Dead user's chat
  114. else color_chat(0, id, users_team, users_team, "^3[%s]^4 %s:^1 %s", users_team == _:CS_TEAM_SPECTATOR ? "SPEC" : "DEAD", name, chat)
  115.  
  116. return PLUGIN_HANDLED
  117. }
  118.  
  119. // Player's team say hook
  120. public hook_team_say(id)
  121. {
  122. // Retrieve the player's chat
  123. static chat[192], name[32], users_team
  124. read_args(chat, 191)
  125. remove_quotes(chat)
  126.  
  127. // Trying to fool us ?
  128. if(!chat[0])
  129. return PLUGIN_CONTINUE
  130.  
  131. // Retrieve player's name
  132. get_user_name(id, name, charsmax(name))
  133.  
  134. // Retrieve player's team
  135. users_team = _:cs_get_user_team(id)
  136.  
  137. // Alive user
  138. if (is_user_alive(id))
  139. {
  140. if (zp_get_user_zombie(id))
  141. color_chat(1, id, users_team, RED, "^3[%s](Team Message)^4 %s:^1 %s", zp_get_user_nemesis(id) ? "Nemesis" : "Zombie", name, chat)
  142. else
  143. color_chat(g_new_round ? 0 : 1, id, users_team, BLUE, "^3[%s](Team Message)^4 %s:^1 %s", zp_get_user_survivor(id) ? "Survivor" : "Human", name, chat)
  144. }
  145.  
  146. // Dead user's chat
  147. else color_chat(1, id, users_team, users_team, "^3[%s](Team Message)^4 %s:^1 %s", users_team == _:CS_TEAM_SPECTATOR ? "SPEC" : "DEAD", name, chat)
  148.  
  149. return PLUGIN_HANDLED
  150. }
  151.  
  152. // An improved color chat function
  153. color_chat(team_format, player, player_team, color, const chat_msg[], ...)
  154. {
  155. // Format the chat message
  156. static msg[192]
  157. vformat(msg, charsmax(msg) - 1, chat_msg, 6)
  158.  
  159. // We need to display the chat message to only the player's team
  160. if (team_format)
  161. {
  162. // Get amount of players present
  163. static id, i, players[32], count
  164. get_players(players, count, "e", team_names[player_team])
  165.  
  166. // Loop through them
  167. for (i = 0; i < count; i++)
  168. {
  169. // Save player's id so we dont re-index
  170. id = players[i]
  171.  
  172. // Just in case...
  173. if (!id) continue;
  174.  
  175. // Send the colored text message
  176. message_begin(MSG_ONE_UNRELIABLE, g_msg_saytext, _, id)
  177. write_byte(player)
  178. write_string(msg)
  179. message_end()
  180.  
  181. }
  182. }
  183. else
  184. {
  185. // Do we need to change the player's team ?
  186. if (player_team == color)
  187. {
  188. // Send the colored text message
  189. message_begin(MSG_BROADCAST, g_msg_saytext)
  190. write_byte(player)
  191. write_string(msg)
  192. message_end()
  193. }
  194. else
  195. {
  196. // Change his team first
  197. message_begin(MSG_BROADCAST, g_msg_teaminfo)
  198. write_byte(player)
  199. write_string(team_names[color])
  200. message_end()
  201.  
  202. // Send the colored text message
  203. message_begin(MSG_BROADCAST, g_msg_saytext)
  204. write_byte(player)
  205. write_string(msg)
  206. message_end()
  207.  
  208. // Restore player's team
  209. message_begin(MSG_BROADCAST, g_msg_teaminfo)
  210. write_byte(player)
  211. write_string(team_names[player_team])
  212. message_end()
  213. }
  214. }
  215. }