HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <zombieplague>
  3.  
  4. #define PLUGIN_NAME "[ZP] Descriptive 'Fire in the hole!'"
  5. #define PLUGIN_VERSION "0.1"
  6. #define PLUGIN_AUTHOR "VEN"
  7.  
  8. // EDITABLE: grenade description
  9. new const g_grenade_description[][] = {
  10. " [Napalm granat]",
  11. " [Fagyaszto granat]",
  12. " [Vilagito granat]"
  13. }
  14.  
  15. enum color {
  16. COLOR_NORMAL,
  17. COLOR_RED,
  18. COLOR_BLUE,
  19. COLOR_GRAY,
  20. COLOR_GREEN
  21. }
  22.  
  23. // EDITABLE: grenade description text color
  24. new const g_grenade_desccolor[] = {
  25. COLOR_RED,
  26. COLOR_BLUE,
  27. COLOR_GREEN
  28. }
  29.  
  30. new const g_grenade_weaponid[] = {
  31. CSW_HEGRENADE,
  32. CSW_FLASHBANG,
  33. CSW_SMOKEGRENADE
  34. }
  35.  
  36. #define COLORCODE_NORMAL 0x01
  37. #define COLORCODE_TEAM 0x03
  38. #define COLORCODE_LOCATION 0x04
  39.  
  40. new const g_color_code[_:color] = {
  41. COLORCODE_NORMAL,
  42. COLORCODE_TEAM,
  43. COLORCODE_TEAM,
  44. COLORCODE_TEAM,
  45. COLORCODE_LOCATION
  46. }
  47.  
  48. new const g_color_teamname[_:color][] = {
  49. "",
  50. "TERRORIST",
  51. "CT",
  52. "SPECTATOR",
  53. ""
  54. }
  55.  
  56. #define RADIOTEXT_MSGARG_NUMBER 5
  57.  
  58. enum radiotext_msgarg {
  59. RADIOTEXT_MSGARG_PRINTDEST = 1,
  60. RADIOTEXT_MSGARG_CALLERID,
  61. RADIOTEXT_MSGARG_TEXTTYPE,
  62. RADIOTEXT_MSGARG_CALLERNAME,
  63. RADIOTEXT_MSGARG_RADIOTYPE,
  64. }
  65.  
  66. new const g_required_radiotype[] = "#Fire_in_the_hole"
  67. new const g_radiotext_template[] = "%s (RADIO): Fire in the hole!"
  68.  
  69. new g_msgid_saytext
  70. new g_msgid_teaminfo
  71.  
  72. public plugin_init() {
  73. register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
  74.  
  75. register_message(get_user_msgid("TextMsg"), "message_text")
  76.  
  77. g_msgid_saytext = get_user_msgid("SayText")
  78. g_msgid_teaminfo = get_user_msgid("TeamInfo")
  79. }
  80.  
  81. public message_text(msgid, dest, id) {
  82. if (get_msg_args() != RADIOTEXT_MSGARG_NUMBER || get_msg_argtype(RADIOTEXT_MSGARG_RADIOTYPE) != ARG_STRING)
  83. return PLUGIN_CONTINUE
  84.  
  85. static arg[32]
  86. get_msg_arg_string(RADIOTEXT_MSGARG_RADIOTYPE, arg, sizeof arg - 1)
  87. if (!equal(arg, g_required_radiotype))
  88. return PLUGIN_CONTINUE
  89.  
  90. get_msg_arg_string(RADIOTEXT_MSGARG_CALLERID, arg, sizeof arg - 1)
  91. new caller = str_to_num(arg)
  92. if (!is_user_alive(caller))
  93. return PLUGIN_CONTINUE
  94.  
  95. new clip, ammo, weapon
  96. weapon = get_user_weapon(caller, clip, ammo)
  97. for (new i; i < sizeof g_grenade_weaponid; ++i) {
  98. if (g_grenade_weaponid[i] == weapon) {
  99. static text[192]
  100. new pos = 0
  101. text[pos++] = g_color_code[COLOR_NORMAL]
  102.  
  103. get_msg_arg_string(RADIOTEXT_MSGARG_CALLERNAME, arg, sizeof arg - 1)
  104. pos += formatex(text[pos], sizeof text - pos - 1, g_radiotext_template, arg)
  105. copy(text[++pos], sizeof text - pos - 1, i == 0 ? (zp_get_user_zombie(id) ? " [Fertozo granat]" : " [Napalm granat]") : g_grenade_description[i])
  106.  
  107. new desccolor = (i == 0 ? (zp_get_user_zombie(id) ? g_grenade_desccolor[2] : g_grenade_desccolor[0]) : g_grenade_desccolor[i])
  108. if ((text[--pos] = g_color_code[desccolor]) == COLORCODE_TEAM) {
  109. static teamname[12]
  110. get_user_team(id, teamname, sizeof teamname - 1)
  111.  
  112. if (!equal(teamname, g_color_teamname[desccolor])) {
  113. msg_teaminfo(id, g_color_teamname[desccolor])
  114. msg_saytext(id, text)
  115. msg_teaminfo(id, teamname)
  116.  
  117. return PLUGIN_HANDLED
  118. }
  119. }
  120.  
  121. msg_saytext(id, text)
  122.  
  123. return PLUGIN_HANDLED
  124. }
  125. }
  126.  
  127. return PLUGIN_CONTINUE
  128. }
  129.  
  130. msg_teaminfo(id, teamname[]) {
  131. message_begin(MSG_ONE, g_msgid_teaminfo, _, id)
  132. write_byte(id)
  133. write_string(teamname)
  134. message_end()
  135. }
  136.  
  137. msg_saytext(id, text[]) {
  138. message_begin(MSG_ONE, g_msgid_saytext, _, id)
  139. write_byte(id)
  140. write_string(text)
  141. message_end()
  142. }
  143.