HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <engine>
  5.  
  6. #define MAX_BS 2
  7.  
  8. new const site_name[][] =
  9. {
  10. "B Plant",
  11. "A Plant",
  12. "C Plant"
  13. //etc
  14. }
  15.  
  16. public plugin_init()
  17. {
  18. register_dictionary("bombaplant.txt")
  19. register_logevent("BombPlant", 3, "2=Planted_The_Bomb");
  20. }
  21.  
  22. public BombPlant()
  23. {
  24. new sites_ent[MAX_BS]
  25. new Float:sites_origin[MAX_BS][3]
  26. new Float:c4_origin[3]
  27. new sites = find_bs(sites_ent, sites_origin)
  28. new c4 = find_c4(c4_origin)
  29.  
  30. if(!sites || !c4)
  31. return
  32.  
  33. //new planted_site = sites_ent[0]
  34. new Float: planted_origin[3]
  35. planted_origin[0] = sites_origin[0][0]
  36. planted_origin[1] = sites_origin[0][1]
  37. planted_origin[2] = sites_origin[0][2]
  38. new site = 0
  39. for(new i = 1; i < sites; i++)
  40. {
  41. if(get_distance_f(c4_origin, planted_origin) > get_distance_f(c4_origin, sites_origin[i]))
  42. {
  43. planted_origin[0] = sites_origin[i][0]
  44. planted_origin[1] = sites_origin[i][1]
  45. planted_origin[2] = sites_origin[i][2]
  46. //planted_site = sites_ent[i]
  47. site = i
  48. }
  49. }
  50.  
  51. print_color (0, "%L", LANG_PLAYER, "BOMBAPLANTOLVA", site_name[site])
  52. }
  53.  
  54. stock find_bs(bs_ent[MAX_BS], Float:bs_origin[MAX_BS][3])
  55. {
  56. new bs_found = 0
  57. bs_ent[0] = -1
  58. for(new i = 0; i < MAX_BS; i++)
  59. {
  60. bs_ent[i] = engfunc(EngFunc_FindEntityByString, bs_ent[i], "classname", "func_bomb_target")
  61. if(i < MAX_BS - 1)
  62. bs_ent[i+1] = bs_ent[i]
  63. bs_found++
  64. get_brush_entity_origin(bs_ent[i], bs_origin[i])
  65. }
  66. return bs_found
  67. }
  68.  
  69. stock find_c4(Float:origin[3])
  70. {
  71. new ent = -1
  72. while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "grenade")) && (!(get_pdata_int(ent, 96) & (1<<8)))) { }
  73. if(ent)
  74. {
  75. pev(ent, pev_origin, origin)
  76. return 1
  77. }
  78. return 0
  79. }
  80. stock print_color(const id, const input[], any:...) {
  81. new count = 1, players[32]
  82. static msg[191]
  83. vformat(msg, 190, input, 3)
  84.  
  85. replace_all(msg, 190, "!g", "^4")
  86. replace_all(msg, 190, "!y", "^1")
  87. replace_all(msg, 190, "!t", "^3")
  88.  
  89. if (id) players[0] = id; else get_players(players, count, "ch")
  90. {
  91. for (new i = 0; i < count; i++)
  92. {
  93. if (is_user_connected(players[i]))
  94. {
  95. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
  96. write_byte(players[i])
  97. write_string(msg)
  98. message_end()
  99. }
  100. }
  101. }
  102. return PLUGIN_HANDLED
  103. }
  104.