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